/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp
Line | Count | Source |
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 | | |
14 | | #include "MCTargetDesc/XCoreMCTargetDesc.h" |
15 | | #include "InstPrinter/XCoreInstPrinter.h" |
16 | | #include "MCTargetDesc/XCoreMCAsmInfo.h" |
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" |
22 | | #include "llvm/MC/MCSubtargetInfo.h" |
23 | | #include "llvm/Support/CodeGen.h" |
24 | | #include "llvm/Support/ErrorHandling.h" |
25 | | #include "llvm/Support/FormattedStream.h" |
26 | | #include "llvm/Support/TargetRegistry.h" |
27 | | #include "llvm/Support/raw_ostream.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 | | |
40 | 81 | static MCInstrInfo *createXCoreMCInstrInfo() { |
41 | 81 | MCInstrInfo *X = new MCInstrInfo(); |
42 | 81 | InitXCoreMCInstrInfo(X); |
43 | 81 | return X; |
44 | 81 | } |
45 | | |
46 | 82 | static MCRegisterInfo *createXCoreMCRegisterInfo(const Triple &TT) { |
47 | 82 | MCRegisterInfo *X = new MCRegisterInfo(); |
48 | 82 | InitXCoreMCRegisterInfo(X, XCore::LR); |
49 | 82 | return X; |
50 | 82 | } |
51 | | |
52 | | static MCSubtargetInfo * |
53 | 81 | createXCoreMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) { |
54 | 81 | return createXCoreMCSubtargetInfoImpl(TT, CPU, FS); |
55 | 81 | } |
56 | | |
57 | | static MCAsmInfo *createXCoreMCAsmInfo(const MCRegisterInfo &MRI, |
58 | 82 | const Triple &TT) { |
59 | 82 | MCAsmInfo *MAI = new XCoreMCAsmInfo(TT); |
60 | 82 | |
61 | 82 | // Initial state of the frame pointer is SP. |
62 | 82 | MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, XCore::SP, 0); |
63 | 82 | MAI->addInitialFrameState(Inst); |
64 | 82 | |
65 | 82 | return MAI; |
66 | 82 | } |
67 | | |
68 | | static MCInstPrinter *createXCoreMCInstPrinter(const Triple &T, |
69 | | unsigned SyntaxVariant, |
70 | | const MCAsmInfo &MAI, |
71 | | const MCInstrInfo &MII, |
72 | 70 | const MCRegisterInfo &MRI) { |
73 | 70 | return new XCoreInstPrinter(MAI, MII, MRI); |
74 | 70 | } |
75 | | |
76 | 70 | XCoreTargetStreamer::XCoreTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {} |
77 | | |
78 | 68 | XCoreTargetStreamer::~XCoreTargetStreamer() = default; |
79 | | |
80 | | namespace { |
81 | | |
82 | | class XCoreTargetAsmStreamer : public XCoreTargetStreamer { |
83 | | formatted_raw_ostream &OS; |
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, |
97 | | formatted_raw_ostream &OS) |
98 | 70 | : XCoreTargetStreamer(S), OS(OS) {} |
99 | | |
100 | 51 | void XCoreTargetAsmStreamer::emitCCTopData(StringRef Name) { |
101 | 51 | OS << "\t.cc_top " << Name << ".data," << Name << '\n'; |
102 | 51 | } |
103 | | |
104 | 276 | void XCoreTargetAsmStreamer::emitCCTopFunction(StringRef Name) { |
105 | 276 | OS << "\t.cc_top " << Name << ".function," << Name << '\n'; |
106 | 276 | } |
107 | | |
108 | 51 | void XCoreTargetAsmStreamer::emitCCBottomData(StringRef Name) { |
109 | 51 | OS << "\t.cc_bottom " << Name << ".data\n"; |
110 | 51 | } |
111 | | |
112 | 275 | void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) { |
113 | 275 | OS << "\t.cc_bottom " << Name << ".function\n"; |
114 | 275 | } |
115 | | |
116 | | static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S, |
117 | | formatted_raw_ostream &OS, |
118 | | MCInstPrinter *InstPrint, |
119 | 70 | bool isVerboseAsm) { |
120 | 70 | return new XCoreTargetAsmStreamer(S, OS); |
121 | 70 | } |
122 | | |
123 | | // Force static initialization. |
124 | 70.1k | extern "C" void LLVMInitializeXCoreTargetMC() { |
125 | 70.1k | // Register the MC asm info. |
126 | 70.1k | RegisterMCAsmInfoFn X(getTheXCoreTarget(), createXCoreMCAsmInfo); |
127 | 70.1k | |
128 | 70.1k | // Register the MC instruction info. |
129 | 70.1k | TargetRegistry::RegisterMCInstrInfo(getTheXCoreTarget(), |
130 | 70.1k | createXCoreMCInstrInfo); |
131 | 70.1k | |
132 | 70.1k | // Register the MC register info. |
133 | 70.1k | TargetRegistry::RegisterMCRegInfo(getTheXCoreTarget(), |
134 | 70.1k | createXCoreMCRegisterInfo); |
135 | 70.1k | |
136 | 70.1k | // Register the MC subtarget info. |
137 | 70.1k | TargetRegistry::RegisterMCSubtargetInfo(getTheXCoreTarget(), |
138 | 70.1k | createXCoreMCSubtargetInfo); |
139 | 70.1k | |
140 | 70.1k | // Register the MCInstPrinter |
141 | 70.1k | TargetRegistry::RegisterMCInstPrinter(getTheXCoreTarget(), |
142 | 70.1k | createXCoreMCInstPrinter); |
143 | 70.1k | |
144 | 70.1k | TargetRegistry::RegisterAsmTargetStreamer(getTheXCoreTarget(), |
145 | 70.1k | createTargetAsmStreamer); |
146 | 70.1k | } |