LLVM  6.0.0svn
Nios2MCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- Nios2MCTargetDesc.cpp - Nios2 Target Descriptions -----------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides Nios2 specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "Nios2MCTargetDesc.h"
16 #include "Nios2MCAsmInfo.h"
17 #include "Nios2TargetStreamer.h"
18 #include "llvm/MC/MCInstrInfo.h"
19 #include "llvm/MC/MCRegisterInfo.h"
22 
23 using namespace llvm;
24 
25 #define GET_INSTRINFO_MC_DESC
26 #include "Nios2GenInstrInfo.inc"
27 
28 #define GET_SUBTARGETINFO_MC_DESC
29 #include "Nios2GenSubtargetInfo.inc"
30 
31 #define GET_REGINFO_MC_DESC
32 #include "Nios2GenRegisterInfo.inc"
33 
35  MCInstrInfo *X = new MCInstrInfo();
36  InitNios2MCInstrInfo(X); // defined in Nios2GenInstrInfo.inc
37  return X;
38 }
39 
42  InitNios2MCRegisterInfo(X, Nios2::R15); // defined in Nios2GenRegisterInfo.inc
43  return X;
44 }
45 
46 static MCSubtargetInfo *
48  if (CPU.empty() || CPU == "generic")
49  CPU = "nios2r1";
50  return createNios2MCSubtargetInfoImpl(TT, CPU, FS);
51  // createNios2MCSubtargetInfoImpl defined in Nios2GenSubtargetInfo.inc
52 }
53 
55  const Triple &TT) {
56  MCAsmInfo *MAI = new Nios2MCAsmInfo(TT);
57 
58  unsigned SP = MRI.getDwarfRegNum(Nios2::SP, true);
59  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, SP, 0);
60  MAI->addInitialFrameState(Inst);
61 
62  return MAI;
63 }
64 
66  unsigned SyntaxVariant,
67  const MCAsmInfo &MAI,
68  const MCInstrInfo &MII,
69  const MCRegisterInfo &MRI) {
70  return new Nios2InstPrinter(MAI, MII, MRI);
71 }
72 
75  MCInstPrinter *InstPrint,
76  bool isVerboseAsm) {
77  return new Nios2TargetAsmStreamer(S, OS);
78 }
79 
80 extern "C" void LLVMInitializeNios2TargetMC() {
82 
83  // Register the MC asm info.
85 
86  // Register the MC instruction info.
88 
89  // Register the MC register info.
91 
92  // Register the asm target streamer.
94 
95  // Register the MC subtarget info.
97  // Register the MCInstPrinter.
99 
100  // Register the asm backend.
102 }
static MCInstrInfo * createNios2MCInstrInfo()
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Target specific streamer interface.
Definition: MCStreamer.h:80
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
Target & getTheNios2Target()
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
static MCAsmInfo * createNios2MCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT)
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.h:582
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
static MCInstPrinter * createNios2MCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
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:56
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:169
unsigned const MachineRegisterInfo * MRI
static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it...
Definition: MCDwarf.h:377
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
static MCSubtargetInfo * createNios2MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
static MCRegisterInfo * createNios2MCRegisterInfo(const Triple &TT)
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target...
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
MCAsmBackend * createNios2AsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, StringRef CPU, const MCTargetOptions &Options)
static MCTargetStreamer * createNios2AsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Target - Wrapper for Target specific information.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:41
void LLVMInitializeNios2TargetMC()
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target. ...
MCSubtargetInfo - Generic base class for all target subtargets.
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49