Mercurial > hg > CbC > CbC_llvm
comparison lib/Target/Mips/MipsTargetStreamer.h @ 95:afa8332a0e37 LLVM3.8
LLVM 3.8
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 13 Oct 2015 17:48:58 +0900 |
parents | 60c9769439b8 |
children | 1172e4bd9c6f |
comparison
equal
deleted
inserted
replaced
84:f3e34b893a5f | 95:afa8332a0e37 |
---|---|
10 #ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETSTREAMER_H | 10 #ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETSTREAMER_H |
11 #define LLVM_LIB_TARGET_MIPS_MIPSTARGETSTREAMER_H | 11 #define LLVM_LIB_TARGET_MIPS_MIPSTARGETSTREAMER_H |
12 | 12 |
13 #include "MCTargetDesc/MipsABIFlagsSection.h" | 13 #include "MCTargetDesc/MipsABIFlagsSection.h" |
14 #include "MCTargetDesc/MipsABIInfo.h" | 14 #include "MCTargetDesc/MipsABIInfo.h" |
15 #include "llvm/ADT/Optional.h" | |
15 #include "llvm/MC/MCELFStreamer.h" | 16 #include "llvm/MC/MCELFStreamer.h" |
16 #include "llvm/MC/MCRegisterInfo.h" | 17 #include "llvm/MC/MCRegisterInfo.h" |
17 #include "llvm/MC/MCStreamer.h" | 18 #include "llvm/MC/MCStreamer.h" |
18 | 19 |
19 namespace llvm { | 20 namespace llvm { |
43 virtual void emitDirectiveAbiCalls(); | 44 virtual void emitDirectiveAbiCalls(); |
44 virtual void emitDirectiveNaN2008(); | 45 virtual void emitDirectiveNaN2008(); |
45 virtual void emitDirectiveNaNLegacy(); | 46 virtual void emitDirectiveNaNLegacy(); |
46 virtual void emitDirectiveOptionPic0(); | 47 virtual void emitDirectiveOptionPic0(); |
47 virtual void emitDirectiveOptionPic2(); | 48 virtual void emitDirectiveOptionPic2(); |
49 virtual void emitDirectiveInsn(); | |
48 virtual void emitFrame(unsigned StackReg, unsigned StackSize, | 50 virtual void emitFrame(unsigned StackReg, unsigned StackSize, |
49 unsigned ReturnReg); | 51 unsigned ReturnReg); |
50 virtual void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff); | 52 virtual void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff); |
51 virtual void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff); | 53 virtual void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff); |
52 | 54 |
57 virtual void emitDirectiveSetMips3(); | 59 virtual void emitDirectiveSetMips3(); |
58 virtual void emitDirectiveSetMips4(); | 60 virtual void emitDirectiveSetMips4(); |
59 virtual void emitDirectiveSetMips5(); | 61 virtual void emitDirectiveSetMips5(); |
60 virtual void emitDirectiveSetMips32(); | 62 virtual void emitDirectiveSetMips32(); |
61 virtual void emitDirectiveSetMips32R2(); | 63 virtual void emitDirectiveSetMips32R2(); |
64 virtual void emitDirectiveSetMips32R3(); | |
65 virtual void emitDirectiveSetMips32R5(); | |
62 virtual void emitDirectiveSetMips32R6(); | 66 virtual void emitDirectiveSetMips32R6(); |
63 virtual void emitDirectiveSetMips64(); | 67 virtual void emitDirectiveSetMips64(); |
64 virtual void emitDirectiveSetMips64R2(); | 68 virtual void emitDirectiveSetMips64R2(); |
69 virtual void emitDirectiveSetMips64R3(); | |
70 virtual void emitDirectiveSetMips64R5(); | |
65 virtual void emitDirectiveSetMips64R6(); | 71 virtual void emitDirectiveSetMips64R6(); |
66 virtual void emitDirectiveSetDsp(); | 72 virtual void emitDirectiveSetDsp(); |
67 virtual void emitDirectiveSetNoDsp(); | 73 virtual void emitDirectiveSetNoDsp(); |
68 virtual void emitDirectiveSetPop(); | 74 virtual void emitDirectiveSetPop(); |
69 virtual void emitDirectiveSetPush(); | 75 virtual void emitDirectiveSetPush(); |
76 virtual void emitDirectiveSetSoftFloat(); | |
77 virtual void emitDirectiveSetHardFloat(); | |
70 | 78 |
71 // PIC support | 79 // PIC support |
72 virtual void emitDirectiveCpLoad(unsigned RegNo); | 80 virtual void emitDirectiveCpLoad(unsigned RegNo); |
81 virtual void emitDirectiveCpRestore(SmallVector<MCInst, 3> &StoreInsts, | |
82 int Offset); | |
73 virtual void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, | 83 virtual void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, |
74 const MCSymbol &Sym, bool IsReg); | 84 const MCSymbol &Sym, bool IsReg); |
75 | 85 virtual void emitDirectiveCpreturn(unsigned SaveLocation, |
76 /// Emit a '.module fp=value' directive using the given values. | 86 bool SaveLocationIsRegister); |
77 /// Updates the .MIPS.abiflags section | 87 |
78 virtual void emitDirectiveModuleFP(MipsABIFlagsSection::FpABIKind Value, | 88 // FP abiflags directives |
79 bool Is32BitABI) { | 89 virtual void emitDirectiveModuleFP(); |
80 ABIFlagsSection.setFpABI(Value, Is32BitABI); | 90 virtual void emitDirectiveModuleOddSPReg(); |
81 } | 91 virtual void emitDirectiveModuleSoftFloat(); |
82 | 92 virtual void emitDirectiveModuleHardFloat(); |
83 /// Emit a '.module fp=value' directive using the current values of the | 93 virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value); |
84 /// .MIPS.abiflags section. | 94 virtual void emitDirectiveSetOddSPReg(); |
85 void emitDirectiveModuleFP() { | 95 virtual void emitDirectiveSetNoOddSPReg(); |
86 emitDirectiveModuleFP(ABIFlagsSection.getFpABI(), | 96 |
87 ABIFlagsSection.Is32BitABI); | |
88 } | |
89 | |
90 virtual void emitDirectiveModuleOddSPReg(bool Enabled, bool IsO32ABI); | |
91 virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value){}; | |
92 virtual void emitMipsAbiFlags(){}; | |
93 void forbidModuleDirective() { ModuleDirectiveAllowed = false; } | 97 void forbidModuleDirective() { ModuleDirectiveAllowed = false; } |
98 void reallowModuleDirective() { ModuleDirectiveAllowed = true; } | |
94 bool isModuleDirectiveAllowed() { return ModuleDirectiveAllowed; } | 99 bool isModuleDirectiveAllowed() { return ModuleDirectiveAllowed; } |
95 | 100 |
96 // This method enables template classes to set internal abi flags | 101 // This method enables template classes to set internal abi flags |
97 // structure values. | 102 // structure values. |
98 template <class PredicateLibrary> | 103 template <class PredicateLibrary> |
99 void updateABIInfo(const PredicateLibrary &P) { | 104 void updateABIInfo(const PredicateLibrary &P) { |
100 ABI = &P.getABI(); | 105 ABI = P.getABI(); |
101 ABIFlagsSection.setAllFromPredicates(P); | 106 ABIFlagsSection.setAllFromPredicates(P); |
102 } | 107 } |
103 | 108 |
104 MipsABIFlagsSection &getABIFlagsSection() { return ABIFlagsSection; } | 109 MipsABIFlagsSection &getABIFlagsSection() { return ABIFlagsSection; } |
105 const MipsABIInfo &getABI() const { | 110 const MipsABIInfo &getABI() const { |
106 assert(ABI && "ABI hasn't been set!"); | 111 assert(ABI.hasValue() && "ABI hasn't been set!"); |
107 return *ABI; | 112 return *ABI; |
108 } | 113 } |
109 | 114 |
110 protected: | 115 protected: |
111 const MipsABIInfo *ABI; | 116 llvm::Optional<MipsABIInfo> ABI; |
112 MipsABIFlagsSection ABIFlagsSection; | 117 MipsABIFlagsSection ABIFlagsSection; |
113 | 118 |
114 bool GPRInfoSet; | 119 bool GPRInfoSet; |
115 unsigned GPRBitMask; | 120 unsigned GPRBitMask; |
116 int GPROffset; | 121 int GPROffset; |
154 void emitDirectiveAbiCalls() override; | 159 void emitDirectiveAbiCalls() override; |
155 void emitDirectiveNaN2008() override; | 160 void emitDirectiveNaN2008() override; |
156 void emitDirectiveNaNLegacy() override; | 161 void emitDirectiveNaNLegacy() override; |
157 void emitDirectiveOptionPic0() override; | 162 void emitDirectiveOptionPic0() override; |
158 void emitDirectiveOptionPic2() override; | 163 void emitDirectiveOptionPic2() override; |
164 void emitDirectiveInsn() override; | |
159 void emitFrame(unsigned StackReg, unsigned StackSize, | 165 void emitFrame(unsigned StackReg, unsigned StackSize, |
160 unsigned ReturnReg) override; | 166 unsigned ReturnReg) override; |
161 void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override; | 167 void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override; |
162 void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override; | 168 void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override; |
163 | 169 |
168 void emitDirectiveSetMips3() override; | 174 void emitDirectiveSetMips3() override; |
169 void emitDirectiveSetMips4() override; | 175 void emitDirectiveSetMips4() override; |
170 void emitDirectiveSetMips5() override; | 176 void emitDirectiveSetMips5() override; |
171 void emitDirectiveSetMips32() override; | 177 void emitDirectiveSetMips32() override; |
172 void emitDirectiveSetMips32R2() override; | 178 void emitDirectiveSetMips32R2() override; |
179 void emitDirectiveSetMips32R3() override; | |
180 void emitDirectiveSetMips32R5() override; | |
173 void emitDirectiveSetMips32R6() override; | 181 void emitDirectiveSetMips32R6() override; |
174 void emitDirectiveSetMips64() override; | 182 void emitDirectiveSetMips64() override; |
175 void emitDirectiveSetMips64R2() override; | 183 void emitDirectiveSetMips64R2() override; |
184 void emitDirectiveSetMips64R3() override; | |
185 void emitDirectiveSetMips64R5() override; | |
176 void emitDirectiveSetMips64R6() override; | 186 void emitDirectiveSetMips64R6() override; |
177 void emitDirectiveSetDsp() override; | 187 void emitDirectiveSetDsp() override; |
178 void emitDirectiveSetNoDsp() override; | 188 void emitDirectiveSetNoDsp() override; |
179 void emitDirectiveSetPop() override; | 189 void emitDirectiveSetPop() override; |
180 void emitDirectiveSetPush() override; | 190 void emitDirectiveSetPush() override; |
191 void emitDirectiveSetSoftFloat() override; | |
192 void emitDirectiveSetHardFloat() override; | |
181 | 193 |
182 // PIC support | 194 // PIC support |
183 void emitDirectiveCpLoad(unsigned RegNo) override; | 195 void emitDirectiveCpLoad(unsigned RegNo) override; |
196 void emitDirectiveCpRestore(SmallVector<MCInst, 3> &StoreInsts, | |
197 int Offset) override; | |
184 void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, | 198 void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, |
185 const MCSymbol &Sym, bool IsReg) override; | 199 const MCSymbol &Sym, bool IsReg) override; |
186 | 200 void emitDirectiveCpreturn(unsigned SaveLocation, |
187 // ABI Flags | 201 bool SaveLocationIsRegister) override; |
188 void emitDirectiveModuleFP(MipsABIFlagsSection::FpABIKind Value, | 202 |
189 bool Is32BitABI) override; | 203 // FP abiflags directives |
190 void emitDirectiveModuleOddSPReg(bool Enabled, bool IsO32ABI) override; | 204 void emitDirectiveModuleFP() override; |
205 void emitDirectiveModuleOddSPReg() override; | |
206 void emitDirectiveModuleSoftFloat() override; | |
207 void emitDirectiveModuleHardFloat() override; | |
191 void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override; | 208 void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override; |
192 void emitMipsAbiFlags() override; | 209 void emitDirectiveSetOddSPReg() override; |
210 void emitDirectiveSetNoOddSPReg() override; | |
193 }; | 211 }; |
194 | 212 |
195 // This part is for ELF object output | 213 // This part is for ELF object output |
196 class MipsTargetELFStreamer : public MipsTargetStreamer { | 214 class MipsTargetELFStreamer : public MipsTargetStreamer { |
197 bool MicroMipsEnabled; | 215 bool MicroMipsEnabled; |
218 void emitDirectiveAbiCalls() override; | 236 void emitDirectiveAbiCalls() override; |
219 void emitDirectiveNaN2008() override; | 237 void emitDirectiveNaN2008() override; |
220 void emitDirectiveNaNLegacy() override; | 238 void emitDirectiveNaNLegacy() override; |
221 void emitDirectiveOptionPic0() override; | 239 void emitDirectiveOptionPic0() override; |
222 void emitDirectiveOptionPic2() override; | 240 void emitDirectiveOptionPic2() override; |
241 void emitDirectiveInsn() override; | |
223 void emitFrame(unsigned StackReg, unsigned StackSize, | 242 void emitFrame(unsigned StackReg, unsigned StackSize, |
224 unsigned ReturnReg) override; | 243 unsigned ReturnReg) override; |
225 void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override; | 244 void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override; |
226 void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override; | 245 void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override; |
227 | 246 |
228 // PIC support | 247 // PIC support |
229 void emitDirectiveCpLoad(unsigned RegNo) override; | 248 void emitDirectiveCpLoad(unsigned RegNo) override; |
249 void emitDirectiveCpRestore(SmallVector<MCInst, 3> &StoreInsts, | |
250 int Offset) override; | |
230 void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, | 251 void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, |
231 const MCSymbol &Sym, bool IsReg) override; | 252 const MCSymbol &Sym, bool IsReg) override; |
232 | 253 void emitDirectiveCpreturn(unsigned SaveLocation, |
233 // ABI Flags | 254 bool SaveLocationIsRegister) override; |
234 void emitDirectiveModuleOddSPReg(bool Enabled, bool IsO32ABI) override; | 255 |
235 void emitMipsAbiFlags() override; | 256 void emitMipsAbiFlags(); |
236 }; | 257 }; |
237 } | 258 } |
238 #endif | 259 #endif |