LLVM  3.7.0
SparcMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- SparcMCTargetDesc.cpp - Sparc 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 Sparc specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "SparcMCTargetDesc.h"
16 #include "SparcMCAsmInfo.h"
17 #include "SparcTargetStreamer.h"
18 #include "llvm/MC/MCCodeGenInfo.h"
19 #include "llvm/MC/MCInstrInfo.h"
20 #include "llvm/MC/MCRegisterInfo.h"
24 
25 using namespace llvm;
26 
27 #define GET_INSTRINFO_MC_DESC
28 #include "SparcGenInstrInfo.inc"
29 
30 #define GET_SUBTARGETINFO_MC_DESC
31 #include "SparcGenSubtargetInfo.inc"
32 
33 #define GET_REGINFO_MC_DESC
34 #include "SparcGenRegisterInfo.inc"
35 
37  const Triple &TT) {
38  MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
39  unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
40  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 0);
41  MAI->addInitialFrameState(Inst);
42  return MAI;
43 }
44 
46  const Triple &TT) {
47  MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
48  unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
49  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 2047);
50  MAI->addInitialFrameState(Inst);
51  return MAI;
52 }
53 
55  MCInstrInfo *X = new MCInstrInfo();
56  InitSparcMCInstrInfo(X);
57  return X;
58 }
59 
62  InitSparcMCRegisterInfo(X, SP::O7);
63  return X;
64 }
65 
66 static MCSubtargetInfo *
68  if (CPU.empty())
69  CPU = (TT.getArch() == Triple::sparcv9) ? "v9" : "v8";
70  return createSparcMCSubtargetInfoImpl(TT, CPU, FS);
71 }
72 
73 // Code models. Some only make sense for 64-bit code.
74 //
75 // SunCC Reloc CodeModel Constraints
76 // abs32 Static Small text+data+bss linked below 2^32 bytes
77 // abs44 Static Medium text+data+bss linked below 2^44 bytes
78 // abs64 Static Large text smaller than 2^31 bytes
79 // pic13 PIC_ Small GOT < 2^13 bytes
80 // pic32 PIC_ Medium GOT < 2^32 bytes
81 //
82 // All code models require that the text segment is smaller than 2GB.
83 
87  CodeGenOpt::Level OL) {
88  MCCodeGenInfo *X = new MCCodeGenInfo();
89 
90  // The default 32-bit code model is abs32/pic32 and the default 32-bit
91  // code model for JIT is abs32.
92  switch (CM) {
93  default: break;
94  case CodeModel::Default:
95  case CodeModel::JITDefault: CM = CodeModel::Small; break;
96  }
97 
98  X->initMCCodeGenInfo(RM, CM, OL);
99  return X;
100 }
101 
104  CodeModel::Model CM,
105  CodeGenOpt::Level OL) {
106  MCCodeGenInfo *X = new MCCodeGenInfo();
107 
108  // The default 64-bit code model is abs44/pic32 and the default 64-bit
109  // code model for JIT is abs64.
110  switch (CM) {
111  default: break;
112  case CodeModel::Default:
114  break;
116  CM = CodeModel::Large;
117  break;
118  }
119 
120  X->initMCCodeGenInfo(RM, CM, OL);
121  return X;
122 }
123 
124 static MCTargetStreamer *
126  return new SparcTargetELFStreamer(S);
127 }
128 
131  MCInstPrinter *InstPrint,
132  bool isVerboseAsm) {
133  return new SparcTargetAsmStreamer(S, OS);
134 }
135 
137  unsigned SyntaxVariant,
138  const MCAsmInfo &MAI,
139  const MCInstrInfo &MII,
140  const MCRegisterInfo &MRI) {
141  return new SparcInstPrinter(MAI, MII, MRI);
142 }
143 
144 extern "C" void LLVMInitializeSparcTargetMC() {
145  // Register the MC asm info.
149 
151  // Register the MC instruction info.
153 
154  // Register the MC register info.
156 
157  // Register the MC subtarget info.
159 
160  // Register the MC Code Emitter.
162 
163  // Register the asm backend.
165 
166  // Register the object target streamer.
169 
170  // Register the asm streamer.
172 
173  // Register the MCInstPrinter
175  }
176 
177  // Register the MC codegen info.
184 }
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
MCCodeEmitter * createSparcMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
void LLVMInitializeSparcTargetMC()
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:73
static MCTargetStreamer * createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static MCRegisterInfo * createSparcMCRegisterInfo(const Triple &TT)
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
static MCTargetStreamer * createTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
Target TheSparcTarget
static MCCodeGenInfo * createSparcV9MCCodeGenInfo(const Triple &TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL)
MCAsmBackend * createSparcAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, StringRef CPU)
Reg
All possible values of the reg field in the ModR/M byte.
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.h:534
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:242
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:58
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:157
static MCInstPrinter * createSparcMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &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:354
static MCAsmInfo * createSparcMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT)
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
static MCCodeGenInfo * createSparcMCCodeGenInfo(const Triple &TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
static void RegisterMCCodeGenInfo(Target &T, Target::MCCodeGenInfoCtorFnTy Fn)
RegisterMCCodeGenInfo - Register a MCCodeGenInfo implementation for the given target.
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:44
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static MCInstrInfo * createSparcMCInstrInfo()
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Target - Wrapper for Target specific information.
Target TheSparcV9Target
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:38
void initMCCodeGenInfo(Reloc::Model RM=Reloc::Default, CodeModel::Model CM=CodeModel::Default, CodeGenOpt::Level OL=CodeGenOpt::Default)
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.
static MCAsmInfo * createSparcV9MCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT)
static MCSubtargetInfo * createSparcMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
Target TheSparcelTarget
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:110