LLVM  8.0.1
XCoreMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- XCoreMCTargetDesc.cpp - XCore 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 XCore specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13 
17 #include "XCoreTargetStreamer.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/MCDwarf.h"
20 #include "llvm/MC/MCInstrInfo.h"
21 #include "llvm/MC/MCRegisterInfo.h"
23 #include "llvm/Support/CodeGen.h"
28 
29 using namespace llvm;
30 
31 #define GET_INSTRINFO_MC_DESC
32 #include "XCoreGenInstrInfo.inc"
33 
34 #define GET_SUBTARGETINFO_MC_DESC
35 #include "XCoreGenSubtargetInfo.inc"
36 
37 #define GET_REGINFO_MC_DESC
38 #include "XCoreGenRegisterInfo.inc"
39 
41  MCInstrInfo *X = new MCInstrInfo();
42  InitXCoreMCInstrInfo(X);
43  return X;
44 }
45 
48  InitXCoreMCRegisterInfo(X, XCore::LR);
49  return X;
50 }
51 
52 static MCSubtargetInfo *
54  return createXCoreMCSubtargetInfoImpl(TT, CPU, FS);
55 }
56 
58  const Triple &TT) {
59  MCAsmInfo *MAI = new XCoreMCAsmInfo(TT);
60 
61  // Initial state of the frame pointer is SP.
62  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, XCore::SP, 0);
63  MAI->addInitialFrameState(Inst);
64 
65  return MAI;
66 }
67 
69  unsigned SyntaxVariant,
70  const MCAsmInfo &MAI,
71  const MCInstrInfo &MII,
72  const MCRegisterInfo &MRI) {
73  return new XCoreInstPrinter(MAI, MII, MRI);
74 }
75 
77 
79 
80 namespace {
81 
82 class XCoreTargetAsmStreamer : public XCoreTargetStreamer {
84 
85 public:
86  XCoreTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
87 
88  void emitCCTopData(StringRef Name) override;
89  void emitCCTopFunction(StringRef Name) override;
90  void emitCCBottomData(StringRef Name) override;
91  void emitCCBottomFunction(StringRef Name) override;
92 };
93 
94 } // end anonymous namespace
95 
96 XCoreTargetAsmStreamer::XCoreTargetAsmStreamer(MCStreamer &S,
98  : XCoreTargetStreamer(S), OS(OS) {}
99 
100 void XCoreTargetAsmStreamer::emitCCTopData(StringRef Name) {
101  OS << "\t.cc_top " << Name << ".data," << Name << '\n';
102 }
103 
104 void XCoreTargetAsmStreamer::emitCCTopFunction(StringRef Name) {
105  OS << "\t.cc_top " << Name << ".function," << Name << '\n';
106 }
107 
108 void XCoreTargetAsmStreamer::emitCCBottomData(StringRef Name) {
109  OS << "\t.cc_bottom " << Name << ".data\n";
110 }
111 
112 void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) {
113  OS << "\t.cc_bottom " << Name << ".function\n";
114 }
115 
118  MCInstPrinter *InstPrint,
119  bool isVerboseAsm) {
120  return new XCoreTargetAsmStreamer(S, OS);
121 }
122 
123 // Force static initialization.
124 extern "C" void LLVMInitializeXCoreTargetMC() {
125  // Register the MC asm info.
127 
128  // Register the MC instruction info.
131 
132  // Register the MC register info.
135 
136  // Register the MC subtarget info.
139 
140  // Register the MCInstPrinter
143 
146 }
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static MCSubtargetInfo * createXCoreMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
This class represents lattice values for constants.
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:84
void LLVMInitializeXCoreTargetMC()
virtual void emitCCTopFunction(StringRef Name)=0
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)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
static MCInstPrinter * createXCoreMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
static MCInstrInfo * createXCoreMCInstrInfo()
virtual void emitCCBottomFunction(StringRef Name)=0
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.h:601
virtual void emitCCBottomData(StringRef Name)=0
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
Streaming machine code generation interface.
Definition: MCStreamer.h:189
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:461
virtual void emitCCTopData(StringRef Name)=0
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
static MCRegisterInfo * createXCoreMCRegisterInfo(const Triple &TT)
static MCAsmInfo * createXCoreMCAsmInfo(const MCRegisterInfo &MRI, 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
Target & getTheXCoreTarget()
static MCTargetStreamer * createTargetAsmStreamer(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.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:40
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target. ...
Generic base class for all target subtargets.
This file contains the declaration of the XCoreInstPrinter class, which is used to print XCore MCInst...
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49