LLVM  9.0.0svn
AVRMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- AVRMCTargetDesc.cpp - AVR Target Descriptions ---------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides AVR specific target descriptions.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "AVRELFStreamer.h"
14 #include "AVRMCAsmInfo.h"
15 #include "AVRMCELFStreamer.h"
16 #include "AVRMCTargetDesc.h"
17 #include "AVRTargetStreamer.h"
19 
20 #include "llvm/MC/MCAsmBackend.h"
21 #include "llvm/MC/MCELFStreamer.h"
22 #include "llvm/MC/MCCodeEmitter.h"
23 #include "llvm/MC/MCInstrInfo.h"
24 #include "llvm/MC/MCRegisterInfo.h"
27 
28 #define GET_INSTRINFO_MC_DESC
29 #include "AVRGenInstrInfo.inc"
30 
31 #define GET_SUBTARGETINFO_MC_DESC
32 #include "AVRGenSubtargetInfo.inc"
33 
34 #define GET_REGINFO_MC_DESC
35 #include "AVRGenRegisterInfo.inc"
36 
37 using namespace llvm;
38 
40  MCInstrInfo *X = new MCInstrInfo();
41  InitAVRMCInstrInfo(X);
42 
43  return X;
44 }
45 
48  InitAVRMCRegisterInfo(X, 0);
49 
50  return X;
51 }
52 
54  StringRef CPU, StringRef FS) {
55  return createAVRMCSubtargetInfoImpl(TT, CPU, FS);
56 }
57 
59  unsigned SyntaxVariant,
60  const MCAsmInfo &MAI,
61  const MCInstrInfo &MII,
62  const MCRegisterInfo &MRI) {
63  if (SyntaxVariant == 0) {
64  return new AVRInstPrinter(MAI, MII, MRI);
65  }
66 
67  return nullptr;
68 }
69 
71  std::unique_ptr<MCAsmBackend> &&MAB,
72  std::unique_ptr<MCObjectWriter> &&OW,
73  std::unique_ptr<MCCodeEmitter> &&Emitter,
74  bool RelaxAll) {
75  return createELFStreamer(Context, std::move(MAB), std::move(OW),
76  std::move(Emitter), RelaxAll);
77 }
78 
79 static MCTargetStreamer *
81  return new AVRELFStreamer(S, STI);
82 }
83 
86  MCInstPrinter *InstPrint,
87  bool isVerboseAsm) {
88  return new AVRTargetAsmStreamer(S);
89 }
90 
91 extern "C" void LLVMInitializeAVRTargetMC() {
92  // Register the MC asm info.
94 
95  // Register the MC instruction info.
97 
98  // Register the MC register info.
100 
101  // Register the MC subtarget info.
104 
105  // Register the MCInstPrinter.
108 
109  // Register the MC Code Emitter
111 
112  // Register the obj streamer
114 
115  // Register the obj target streamer.
118 
119  // Register the asm target streamer.
122 
123  // Register the asm backend (as little endian).
125 }
126 
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static MCSubtargetInfo * createAVRMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
LLVMContext & Context
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void LLVMInitializeAVRTargetMC()
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
MCCodeEmitter * createAVRMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
Creates a machine code emitter for AVR.
MCInstrInfo * createAVRMCInstrInfo()
Target specific streamer interface.
Definition: MCStreamer.h:83
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
A target streamer for textual AVR assembly code.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
Prints AVR instructions to a textual stream.
Target & getTheAVRTarget()
Context object for machine code objects.
Definition: MCContext.h:62
static MCTargetStreamer * createMCAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:55
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
Streaming machine code generation interface.
Definition: MCStreamer.h:188
unsigned const MachineRegisterInfo * MRI
static MCInstPrinter * createAVRMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
static MCStreamer * createMCStreamer(const Triple &T, MCContext &Context, std::unique_ptr< MCAsmBackend > &&MAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll)
MCStreamer * createELFStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll)
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:23
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target...
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
static MCRegisterInfo * createAVRMCRegisterInfo(const Triple &TT)
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
static MCTargetStreamer * createAVRObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:39
A target streamer for an AVR ELF object file.
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target. ...
Generic base class for all target subtargets.
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
RegisterMCAsmInfo - Helper template for registering a target assembly info implementation.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
MCAsmBackend * createAVRAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const llvm::MCTargetOptions &TO)
Creates an assembly backend for AVR.