Rafael Espindola | a17151a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 1 | //===-- MipsTargetStreamer.h - Mips Target Streamer ------------*- C++ -*--===// |
| 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 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETSTREAMER_H |
| 11 | #define LLVM_LIB_TARGET_MIPS_MIPSTARGETSTREAMER_H |
Rafael Espindola | a17151a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 12 | |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 13 | #include "MCTargetDesc/MipsABIFlagsSection.h" |
Eric Christopher | a576281 | 2015-01-26 17:33:46 +0000 | [diff] [blame] | 14 | #include "MCTargetDesc/MipsABIInfo.h" |
Simon Atanasyan | 4d45c76 | 2015-09-14 11:18:03 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/Optional.h" |
Benjamin Kramer | d3f4c05 | 2016-06-12 16:13:55 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/STLExtras.h" |
Jack Carter | 86ac5c1 | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCELFStreamer.h" |
Daniel Sanders | d97a634 | 2014-08-13 10:07:34 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCRegisterInfo.h" |
Rafael Espindola | a17151a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCStreamer.h" |
| 20 | |
| 21 | namespace llvm { |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 22 | |
Daniel Sanders | 324ad95 | 2014-07-08 13:13:42 +0000 | [diff] [blame] | 23 | struct MipsABIFlagsSection; |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 24 | |
Rafael Espindola | a17151a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 25 | class MipsTargetStreamer : public MCTargetStreamer { |
Rafael Espindola | a17151a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 26 | public: |
Rafael Espindola | 24ea09e | 2014-01-26 06:06:37 +0000 | [diff] [blame] | 27 | MipsTargetStreamer(MCStreamer &S); |
Daniel Sanders | 8de3d3c | 2016-05-06 14:37:24 +0000 | [diff] [blame] | 28 | |
| 29 | virtual void setPic(bool Value) {} |
| 30 | |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 31 | virtual void emitDirectiveSetMicroMips(); |
| 32 | virtual void emitDirectiveSetNoMicroMips(); |
Daniel Sanders | cda908a | 2016-05-16 09:10:13 +0000 | [diff] [blame] | 33 | virtual void setUsesMicroMips(); |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 34 | virtual void emitDirectiveSetMips16(); |
| 35 | virtual void emitDirectiveSetNoMips16(); |
Rafael Espindola | eb0a8af | 2014-01-26 05:06:48 +0000 | [diff] [blame] | 36 | |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 37 | virtual void emitDirectiveSetReorder(); |
| 38 | virtual void emitDirectiveSetNoReorder(); |
| 39 | virtual void emitDirectiveSetMacro(); |
| 40 | virtual void emitDirectiveSetNoMacro(); |
Daniel Sanders | 4493443 | 2014-08-07 12:03:36 +0000 | [diff] [blame] | 41 | virtual void emitDirectiveSetMsa(); |
| 42 | virtual void emitDirectiveSetNoMsa(); |
Simon Dardis | 805f1e0 | 2017-07-11 21:28:36 +0000 | [diff] [blame^] | 43 | virtual void emitDirectiveSetMt(); |
| 44 | virtual void emitDirectiveSetNoMt(); |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 45 | virtual void emitDirectiveSetAt(); |
Toma Tabacu | 16a7449 | 2015-02-13 10:30:57 +0000 | [diff] [blame] | 46 | virtual void emitDirectiveSetAtWithArg(unsigned RegNo); |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 47 | virtual void emitDirectiveSetNoAt(); |
| 48 | virtual void emitDirectiveEnd(StringRef Name); |
Rafael Espindola | eb0a8af | 2014-01-26 05:06:48 +0000 | [diff] [blame] | 49 | |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 50 | virtual void emitDirectiveEnt(const MCSymbol &Symbol); |
| 51 | virtual void emitDirectiveAbiCalls(); |
| 52 | virtual void emitDirectiveNaN2008(); |
| 53 | virtual void emitDirectiveNaNLegacy(); |
| 54 | virtual void emitDirectiveOptionPic0(); |
| 55 | virtual void emitDirectiveOptionPic2(); |
Toma Tabacu | 9ca5096 | 2015-04-16 09:53:47 +0000 | [diff] [blame] | 56 | virtual void emitDirectiveInsn(); |
Rafael Espindola | 054234f | 2014-01-27 03:53:56 +0000 | [diff] [blame] | 57 | virtual void emitFrame(unsigned StackReg, unsigned StackSize, |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 58 | unsigned ReturnReg); |
| 59 | virtual void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff); |
| 60 | virtual void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff); |
Vladimir Medic | 615b26e | 2014-03-04 09:54:09 +0000 | [diff] [blame] | 61 | |
Toma Tabacu | 85618b3 | 2014-08-19 14:22:52 +0000 | [diff] [blame] | 62 | virtual void emitDirectiveSetArch(StringRef Arch); |
Toma Tabacu | 2664779 | 2014-09-09 12:52:14 +0000 | [diff] [blame] | 63 | virtual void emitDirectiveSetMips0(); |
Daniel Sanders | f0df221 | 2014-08-04 12:20:00 +0000 | [diff] [blame] | 64 | virtual void emitDirectiveSetMips1(); |
| 65 | virtual void emitDirectiveSetMips2(); |
| 66 | virtual void emitDirectiveSetMips3(); |
| 67 | virtual void emitDirectiveSetMips4(); |
| 68 | virtual void emitDirectiveSetMips5(); |
| 69 | virtual void emitDirectiveSetMips32(); |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 70 | virtual void emitDirectiveSetMips32R2(); |
Daniel Sanders | 1779314 | 2015-02-18 16:24:50 +0000 | [diff] [blame] | 71 | virtual void emitDirectiveSetMips32R3(); |
| 72 | virtual void emitDirectiveSetMips32R5(); |
Daniel Sanders | f0df221 | 2014-08-04 12:20:00 +0000 | [diff] [blame] | 73 | virtual void emitDirectiveSetMips32R6(); |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 74 | virtual void emitDirectiveSetMips64(); |
| 75 | virtual void emitDirectiveSetMips64R2(); |
Daniel Sanders | 1779314 | 2015-02-18 16:24:50 +0000 | [diff] [blame] | 76 | virtual void emitDirectiveSetMips64R3(); |
| 77 | virtual void emitDirectiveSetMips64R5(); |
Daniel Sanders | f0df221 | 2014-08-04 12:20:00 +0000 | [diff] [blame] | 78 | virtual void emitDirectiveSetMips64R6(); |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 79 | virtual void emitDirectiveSetDsp(); |
Toma Tabacu | 351b2fe | 2014-09-17 09:01:54 +0000 | [diff] [blame] | 80 | virtual void emitDirectiveSetNoDsp(); |
Toma Tabacu | 9db22db | 2014-09-09 10:15:38 +0000 | [diff] [blame] | 81 | virtual void emitDirectiveSetPop(); |
| 82 | virtual void emitDirectiveSetPush(); |
Toma Tabacu | 2969650 | 2015-06-02 09:48:04 +0000 | [diff] [blame] | 83 | virtual void emitDirectiveSetSoftFloat(); |
| 84 | virtual void emitDirectiveSetHardFloat(); |
Matheus Almeida | 525bc4f | 2014-04-30 11:28:42 +0000 | [diff] [blame] | 85 | |
| 86 | // PIC support |
Toma Tabacu | c4c202a | 2014-10-01 14:53:19 +0000 | [diff] [blame] | 87 | virtual void emitDirectiveCpLoad(unsigned RegNo); |
Daniel Sanders | df8510d | 2016-05-11 12:48:19 +0000 | [diff] [blame] | 88 | virtual bool emitDirectiveCpRestore(int Offset, |
Benjamin Kramer | d3f4c05 | 2016-06-12 16:13:55 +0000 | [diff] [blame] | 89 | function_ref<unsigned()> GetATReg, |
Daniel Sanders | df8510d | 2016-05-11 12:48:19 +0000 | [diff] [blame] | 90 | SMLoc IDLoc, const MCSubtargetInfo *STI); |
Matheus Almeida | d92a3fa | 2014-05-01 10:24:46 +0000 | [diff] [blame] | 91 | virtual void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, |
Rafael Espindola | 60890b8 | 2014-06-23 19:43:40 +0000 | [diff] [blame] | 92 | const MCSymbol &Sym, bool IsReg); |
Daniel Sanders | f173dda | 2015-09-22 10:50:09 +0000 | [diff] [blame] | 93 | virtual void emitDirectiveCpreturn(unsigned SaveLocation, |
| 94 | bool SaveLocationIsRegister); |
Daniel Sanders | 7e52742 | 2014-07-10 13:38:23 +0000 | [diff] [blame] | 95 | |
Toma Tabacu | a64e540 | 2015-06-25 12:44:38 +0000 | [diff] [blame] | 96 | // FP abiflags directives |
| 97 | virtual void emitDirectiveModuleFP(); |
Toma Tabacu | 3c49958 | 2015-06-25 10:56:57 +0000 | [diff] [blame] | 98 | virtual void emitDirectiveModuleOddSPReg(); |
Toma Tabacu | 0f09313 | 2015-06-30 13:46:03 +0000 | [diff] [blame] | 99 | virtual void emitDirectiveModuleSoftFloat(); |
| 100 | virtual void emitDirectiveModuleHardFloat(); |
Simon Dardis | 805f1e0 | 2017-07-11 21:28:36 +0000 | [diff] [blame^] | 101 | virtual void emitDirectiveModuleMT(); |
Toma Tabacu | 4e0cf8e | 2015-03-06 12:15:12 +0000 | [diff] [blame] | 102 | virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value); |
Toma Tabacu | 32c72aa | 2015-06-30 09:36:50 +0000 | [diff] [blame] | 103 | virtual void emitDirectiveSetOddSPReg(); |
| 104 | virtual void emitDirectiveSetNoOddSPReg(); |
Toma Tabacu | a64e540 | 2015-06-25 12:44:38 +0000 | [diff] [blame] | 105 | |
Daniel Sanders | a736b37 | 2016-04-29 13:33:12 +0000 | [diff] [blame] | 106 | void emitR(unsigned Opcode, unsigned Reg0, SMLoc IDLoc, |
| 107 | const MCSubtargetInfo *STI); |
| 108 | void emitII(unsigned Opcode, int16_t Imm1, int16_t Imm2, SMLoc IDLoc, |
| 109 | const MCSubtargetInfo *STI); |
| 110 | void emitRX(unsigned Opcode, unsigned Reg0, MCOperand Op1, SMLoc IDLoc, |
| 111 | const MCSubtargetInfo *STI); |
| 112 | void emitRI(unsigned Opcode, unsigned Reg0, int32_t Imm, SMLoc IDLoc, |
| 113 | const MCSubtargetInfo *STI); |
| 114 | void emitRR(unsigned Opcode, unsigned Reg0, unsigned Reg1, SMLoc IDLoc, |
| 115 | const MCSubtargetInfo *STI); |
| 116 | void emitRRX(unsigned Opcode, unsigned Reg0, unsigned Reg1, MCOperand Op2, |
| 117 | SMLoc IDLoc, const MCSubtargetInfo *STI); |
| 118 | void emitRRR(unsigned Opcode, unsigned Reg0, unsigned Reg1, unsigned Reg2, |
| 119 | SMLoc IDLoc, const MCSubtargetInfo *STI); |
| 120 | void emitRRI(unsigned Opcode, unsigned Reg0, unsigned Reg1, int16_t Imm, |
| 121 | SMLoc IDLoc, const MCSubtargetInfo *STI); |
| 122 | void emitAddu(unsigned DstReg, unsigned SrcReg, unsigned TrgReg, bool Is64Bit, |
| 123 | const MCSubtargetInfo *STI); |
| 124 | void emitDSLL(unsigned DstReg, unsigned SrcReg, int16_t ShiftAmount, |
| 125 | SMLoc IDLoc, const MCSubtargetInfo *STI); |
| 126 | void emitEmptyDelaySlot(bool hasShortDelaySlot, SMLoc IDLoc, |
| 127 | const MCSubtargetInfo *STI); |
| 128 | void emitNop(SMLoc IDLoc, const MCSubtargetInfo *STI); |
Daniel Sanders | 241c679 | 2016-05-12 14:01:50 +0000 | [diff] [blame] | 129 | |
| 130 | /// Emit a store instruction with an offset. If the offset is out of range |
| 131 | /// then it will be synthesized using the assembler temporary. |
| 132 | /// |
| 133 | /// GetATReg() is a callback that can be used to obtain the current assembler |
| 134 | /// temporary and is only called when the assembler temporary is required. It |
| 135 | /// must handle the case where no assembler temporary is available (typically |
| 136 | /// by reporting an error). |
Daniel Sanders | fba875f | 2016-04-29 13:43:45 +0000 | [diff] [blame] | 137 | void emitStoreWithImmOffset(unsigned Opcode, unsigned SrcReg, |
Daniel Sanders | 241c679 | 2016-05-12 14:01:50 +0000 | [diff] [blame] | 138 | unsigned BaseReg, int64_t Offset, |
Benjamin Kramer | d3f4c05 | 2016-06-12 16:13:55 +0000 | [diff] [blame] | 139 | function_ref<unsigned()> GetATReg, SMLoc IDLoc, |
Daniel Sanders | 241c679 | 2016-05-12 14:01:50 +0000 | [diff] [blame] | 140 | const MCSubtargetInfo *STI); |
Daniel Sanders | fba875f | 2016-04-29 13:43:45 +0000 | [diff] [blame] | 141 | void emitStoreWithSymOffset(unsigned Opcode, unsigned SrcReg, |
| 142 | unsigned BaseReg, MCOperand &HiOperand, |
| 143 | MCOperand &LoOperand, unsigned ATReg, SMLoc IDLoc, |
| 144 | const MCSubtargetInfo *STI); |
| 145 | void emitLoadWithImmOffset(unsigned Opcode, unsigned DstReg, unsigned BaseReg, |
| 146 | int64_t Offset, unsigned TmpReg, SMLoc IDLoc, |
| 147 | const MCSubtargetInfo *STI); |
| 148 | void emitLoadWithSymOffset(unsigned Opcode, unsigned DstReg, unsigned BaseReg, |
| 149 | MCOperand &HiOperand, MCOperand &LoOperand, |
| 150 | unsigned ATReg, SMLoc IDLoc, |
| 151 | const MCSubtargetInfo *STI); |
Daniel Sanders | 7225cd5 | 2016-04-29 16:16:49 +0000 | [diff] [blame] | 152 | void emitGPRestore(int Offset, SMLoc IDLoc, const MCSubtargetInfo *STI); |
Daniel Sanders | a736b37 | 2016-04-29 13:33:12 +0000 | [diff] [blame] | 153 | |
Daniel Sanders | cdb45fa | 2014-08-14 09:18:14 +0000 | [diff] [blame] | 154 | void forbidModuleDirective() { ModuleDirectiveAllowed = false; } |
Toma Tabacu | 4e0cf8e | 2015-03-06 12:15:12 +0000 | [diff] [blame] | 155 | void reallowModuleDirective() { ModuleDirectiveAllowed = true; } |
Daniel Sanders | cdb45fa | 2014-08-14 09:18:14 +0000 | [diff] [blame] | 156 | bool isModuleDirectiveAllowed() { return ModuleDirectiveAllowed; } |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 157 | |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 158 | // This method enables template classes to set internal abi flags |
| 159 | // structure values. |
| 160 | template <class PredicateLibrary> |
| 161 | void updateABIInfo(const PredicateLibrary &P) { |
Simon Atanasyan | 4d45c76 | 2015-09-14 11:18:03 +0000 | [diff] [blame] | 162 | ABI = P.getABI(); |
Daniel Sanders | c7dbc63 | 2014-07-08 10:11:38 +0000 | [diff] [blame] | 163 | ABIFlagsSection.setAllFromPredicates(P); |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Daniel Sanders | c7dbc63 | 2014-07-08 10:11:38 +0000 | [diff] [blame] | 166 | MipsABIFlagsSection &getABIFlagsSection() { return ABIFlagsSection; } |
Eric Christopher | a576281 | 2015-01-26 17:33:46 +0000 | [diff] [blame] | 167 | const MipsABIInfo &getABI() const { |
Simon Atanasyan | 4d45c76 | 2015-09-14 11:18:03 +0000 | [diff] [blame] | 168 | assert(ABI.hasValue() && "ABI hasn't been set!"); |
Eric Christopher | a576281 | 2015-01-26 17:33:46 +0000 | [diff] [blame] | 169 | return *ABI; |
| 170 | } |
Daniel Sanders | c7dbc63 | 2014-07-08 10:11:38 +0000 | [diff] [blame] | 171 | |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 172 | protected: |
Simon Atanasyan | 4d45c76 | 2015-09-14 11:18:03 +0000 | [diff] [blame] | 173 | llvm::Optional<MipsABIInfo> ABI; |
Daniel Sanders | c7dbc63 | 2014-07-08 10:11:38 +0000 | [diff] [blame] | 174 | MipsABIFlagsSection ABIFlagsSection; |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 175 | |
Daniel Sanders | d97a634 | 2014-08-13 10:07:34 +0000 | [diff] [blame] | 176 | bool GPRInfoSet; |
| 177 | unsigned GPRBitMask; |
| 178 | int GPROffset; |
| 179 | |
| 180 | bool FPRInfoSet; |
| 181 | unsigned FPRBitMask; |
| 182 | int FPROffset; |
| 183 | |
| 184 | bool FrameInfoSet; |
| 185 | int FrameOffset; |
| 186 | unsigned FrameReg; |
| 187 | unsigned ReturnReg; |
| 188 | |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 189 | private: |
Daniel Sanders | cdb45fa | 2014-08-14 09:18:14 +0000 | [diff] [blame] | 190 | bool ModuleDirectiveAllowed; |
Rafael Espindola | a17151a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 191 | }; |
Jack Carter | 86ac5c1 | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 192 | |
| 193 | // This part is for ascii assembly output |
| 194 | class MipsTargetAsmStreamer : public MipsTargetStreamer { |
Jack Carter | 6ef6cc5 | 2013-11-19 20:53:28 +0000 | [diff] [blame] | 195 | formatted_raw_ostream &OS; |
| 196 | |
Jack Carter | 86ac5c1 | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 197 | public: |
Rafael Espindola | 24ea09e | 2014-01-26 06:06:37 +0000 | [diff] [blame] | 198 | MipsTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS); |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 199 | void emitDirectiveSetMicroMips() override; |
| 200 | void emitDirectiveSetNoMicroMips() override; |
| 201 | void emitDirectiveSetMips16() override; |
| 202 | void emitDirectiveSetNoMips16() override; |
Rafael Espindola | eb0a8af | 2014-01-26 05:06:48 +0000 | [diff] [blame] | 203 | |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 204 | void emitDirectiveSetReorder() override; |
| 205 | void emitDirectiveSetNoReorder() override; |
| 206 | void emitDirectiveSetMacro() override; |
| 207 | void emitDirectiveSetNoMacro() override; |
Daniel Sanders | 4493443 | 2014-08-07 12:03:36 +0000 | [diff] [blame] | 208 | void emitDirectiveSetMsa() override; |
| 209 | void emitDirectiveSetNoMsa() override; |
Simon Dardis | 805f1e0 | 2017-07-11 21:28:36 +0000 | [diff] [blame^] | 210 | void emitDirectiveSetMt() override; |
| 211 | void emitDirectiveSetNoMt() override; |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 212 | void emitDirectiveSetAt() override; |
Toma Tabacu | 16a7449 | 2015-02-13 10:30:57 +0000 | [diff] [blame] | 213 | void emitDirectiveSetAtWithArg(unsigned RegNo) override; |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 214 | void emitDirectiveSetNoAt() override; |
| 215 | void emitDirectiveEnd(StringRef Name) override; |
Rafael Espindola | eb0a8af | 2014-01-26 05:06:48 +0000 | [diff] [blame] | 216 | |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 217 | void emitDirectiveEnt(const MCSymbol &Symbol) override; |
| 218 | void emitDirectiveAbiCalls() override; |
| 219 | void emitDirectiveNaN2008() override; |
| 220 | void emitDirectiveNaNLegacy() override; |
| 221 | void emitDirectiveOptionPic0() override; |
| 222 | void emitDirectiveOptionPic2() override; |
Toma Tabacu | 9ca5096 | 2015-04-16 09:53:47 +0000 | [diff] [blame] | 223 | void emitDirectiveInsn() override; |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 224 | void emitFrame(unsigned StackReg, unsigned StackSize, |
| 225 | unsigned ReturnReg) override; |
| 226 | void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override; |
| 227 | void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override; |
Vladimir Medic | 615b26e | 2014-03-04 09:54:09 +0000 | [diff] [blame] | 228 | |
Toma Tabacu | 85618b3 | 2014-08-19 14:22:52 +0000 | [diff] [blame] | 229 | void emitDirectiveSetArch(StringRef Arch) override; |
Toma Tabacu | 2664779 | 2014-09-09 12:52:14 +0000 | [diff] [blame] | 230 | void emitDirectiveSetMips0() override; |
Daniel Sanders | f0df221 | 2014-08-04 12:20:00 +0000 | [diff] [blame] | 231 | void emitDirectiveSetMips1() override; |
| 232 | void emitDirectiveSetMips2() override; |
| 233 | void emitDirectiveSetMips3() override; |
| 234 | void emitDirectiveSetMips4() override; |
| 235 | void emitDirectiveSetMips5() override; |
| 236 | void emitDirectiveSetMips32() override; |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 237 | void emitDirectiveSetMips32R2() override; |
Daniel Sanders | 1779314 | 2015-02-18 16:24:50 +0000 | [diff] [blame] | 238 | void emitDirectiveSetMips32R3() override; |
| 239 | void emitDirectiveSetMips32R5() override; |
Daniel Sanders | f0df221 | 2014-08-04 12:20:00 +0000 | [diff] [blame] | 240 | void emitDirectiveSetMips32R6() override; |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 241 | void emitDirectiveSetMips64() override; |
| 242 | void emitDirectiveSetMips64R2() override; |
Daniel Sanders | 1779314 | 2015-02-18 16:24:50 +0000 | [diff] [blame] | 243 | void emitDirectiveSetMips64R3() override; |
| 244 | void emitDirectiveSetMips64R5() override; |
Daniel Sanders | f0df221 | 2014-08-04 12:20:00 +0000 | [diff] [blame] | 245 | void emitDirectiveSetMips64R6() override; |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 246 | void emitDirectiveSetDsp() override; |
Toma Tabacu | 351b2fe | 2014-09-17 09:01:54 +0000 | [diff] [blame] | 247 | void emitDirectiveSetNoDsp() override; |
Toma Tabacu | 9db22db | 2014-09-09 10:15:38 +0000 | [diff] [blame] | 248 | void emitDirectiveSetPop() override; |
| 249 | void emitDirectiveSetPush() override; |
Toma Tabacu | 2969650 | 2015-06-02 09:48:04 +0000 | [diff] [blame] | 250 | void emitDirectiveSetSoftFloat() override; |
| 251 | void emitDirectiveSetHardFloat() override; |
Matheus Almeida | 525bc4f | 2014-04-30 11:28:42 +0000 | [diff] [blame] | 252 | |
| 253 | // PIC support |
Toma Tabacu | c4c202a | 2014-10-01 14:53:19 +0000 | [diff] [blame] | 254 | void emitDirectiveCpLoad(unsigned RegNo) override; |
Daniel Sanders | 241c679 | 2016-05-12 14:01:50 +0000 | [diff] [blame] | 255 | |
| 256 | /// Emit a .cprestore directive. If the offset is out of range then it will |
| 257 | /// be synthesized using the assembler temporary. |
| 258 | /// |
| 259 | /// GetATReg() is a callback that can be used to obtain the current assembler |
| 260 | /// temporary and is only called when the assembler temporary is required. It |
| 261 | /// must handle the case where no assembler temporary is available (typically |
| 262 | /// by reporting an error). |
Benjamin Kramer | d3f4c05 | 2016-06-12 16:13:55 +0000 | [diff] [blame] | 263 | bool emitDirectiveCpRestore(int Offset, function_ref<unsigned()> GetATReg, |
Daniel Sanders | df8510d | 2016-05-11 12:48:19 +0000 | [diff] [blame] | 264 | SMLoc IDLoc, const MCSubtargetInfo *STI) override; |
Matheus Almeida | d92a3fa | 2014-05-01 10:24:46 +0000 | [diff] [blame] | 265 | void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, |
| 266 | const MCSymbol &Sym, bool IsReg) override; |
Daniel Sanders | f173dda | 2015-09-22 10:50:09 +0000 | [diff] [blame] | 267 | void emitDirectiveCpreturn(unsigned SaveLocation, |
| 268 | bool SaveLocationIsRegister) override; |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 269 | |
Toma Tabacu | a64e540 | 2015-06-25 12:44:38 +0000 | [diff] [blame] | 270 | // FP abiflags directives |
| 271 | void emitDirectiveModuleFP() override; |
Toma Tabacu | 3c49958 | 2015-06-25 10:56:57 +0000 | [diff] [blame] | 272 | void emitDirectiveModuleOddSPReg() override; |
Toma Tabacu | 0f09313 | 2015-06-30 13:46:03 +0000 | [diff] [blame] | 273 | void emitDirectiveModuleSoftFloat() override; |
| 274 | void emitDirectiveModuleHardFloat() override; |
Simon Dardis | 805f1e0 | 2017-07-11 21:28:36 +0000 | [diff] [blame^] | 275 | void emitDirectiveModuleMT() override; |
Daniel Sanders | 7e52742 | 2014-07-10 13:38:23 +0000 | [diff] [blame] | 276 | void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override; |
Toma Tabacu | 32c72aa | 2015-06-30 09:36:50 +0000 | [diff] [blame] | 277 | void emitDirectiveSetOddSPReg() override; |
| 278 | void emitDirectiveSetNoOddSPReg() override; |
Jack Carter | 86ac5c1 | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 279 | }; |
| 280 | |
| 281 | // This part is for ELF object output |
| 282 | class MipsTargetELFStreamer : public MipsTargetStreamer { |
Rafael Espindola | 6d5f7ce | 2014-01-14 04:25:13 +0000 | [diff] [blame] | 283 | bool MicroMipsEnabled; |
Rafael Espindola | 972e71a | 2014-01-31 23:10:26 +0000 | [diff] [blame] | 284 | const MCSubtargetInfo &STI; |
Matheus Almeida | f79b281 | 2014-03-26 13:40:29 +0000 | [diff] [blame] | 285 | bool Pic; |
Jack Carter | 3953672 | 2014-01-22 23:08:42 +0000 | [diff] [blame] | 286 | |
Jack Carter | 86ac5c1 | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 287 | public: |
Rafael Espindola | 6d5f7ce | 2014-01-14 04:25:13 +0000 | [diff] [blame] | 288 | bool isMicroMipsEnabled() const { return MicroMipsEnabled; } |
Jack Carter | 86ac5c1 | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 289 | MCELFStreamer &getStreamer(); |
Rafael Espindola | cb1953f | 2014-01-26 06:57:13 +0000 | [diff] [blame] | 290 | MipsTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI); |
Rafael Espindola | 6d5f7ce | 2014-01-14 04:25:13 +0000 | [diff] [blame] | 291 | |
Daniel Sanders | 8de3d3c | 2016-05-06 14:37:24 +0000 | [diff] [blame] | 292 | void setPic(bool Value) override { Pic = Value; } |
| 293 | |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 294 | void emitLabel(MCSymbol *Symbol) override; |
| 295 | void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override; |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 296 | void finish() override; |
Rafael Espindola | 6d5f7ce | 2014-01-14 04:25:13 +0000 | [diff] [blame] | 297 | |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 298 | void emitDirectiveSetMicroMips() override; |
| 299 | void emitDirectiveSetNoMicroMips() override; |
Daniel Sanders | cda908a | 2016-05-16 09:10:13 +0000 | [diff] [blame] | 300 | void setUsesMicroMips() override; |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 301 | void emitDirectiveSetMips16() override; |
Rafael Espindola | eb0a8af | 2014-01-26 05:06:48 +0000 | [diff] [blame] | 302 | |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 303 | void emitDirectiveSetNoReorder() override; |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 304 | void emitDirectiveEnd(StringRef Name) override; |
Rafael Espindola | eb0a8af | 2014-01-26 05:06:48 +0000 | [diff] [blame] | 305 | |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 306 | void emitDirectiveEnt(const MCSymbol &Symbol) override; |
| 307 | void emitDirectiveAbiCalls() override; |
| 308 | void emitDirectiveNaN2008() override; |
| 309 | void emitDirectiveNaNLegacy() override; |
| 310 | void emitDirectiveOptionPic0() override; |
| 311 | void emitDirectiveOptionPic2() override; |
Toma Tabacu | 9ca5096 | 2015-04-16 09:53:47 +0000 | [diff] [blame] | 312 | void emitDirectiveInsn() override; |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 313 | void emitFrame(unsigned StackReg, unsigned StackSize, |
| 314 | unsigned ReturnReg) override; |
| 315 | void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override; |
| 316 | void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override; |
Vladimir Medic | 615b26e | 2014-03-04 09:54:09 +0000 | [diff] [blame] | 317 | |
Matheus Almeida | 525bc4f | 2014-04-30 11:28:42 +0000 | [diff] [blame] | 318 | // PIC support |
Toma Tabacu | c4c202a | 2014-10-01 14:53:19 +0000 | [diff] [blame] | 319 | void emitDirectiveCpLoad(unsigned RegNo) override; |
Benjamin Kramer | d3f4c05 | 2016-06-12 16:13:55 +0000 | [diff] [blame] | 320 | bool emitDirectiveCpRestore(int Offset, function_ref<unsigned()> GetATReg, |
Daniel Sanders | df8510d | 2016-05-11 12:48:19 +0000 | [diff] [blame] | 321 | SMLoc IDLoc, const MCSubtargetInfo *STI) override; |
Matheus Almeida | d92a3fa | 2014-05-01 10:24:46 +0000 | [diff] [blame] | 322 | void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, |
| 323 | const MCSymbol &Sym, bool IsReg) override; |
Daniel Sanders | f173dda | 2015-09-22 10:50:09 +0000 | [diff] [blame] | 324 | void emitDirectiveCpreturn(unsigned SaveLocation, |
| 325 | bool SaveLocationIsRegister) override; |
Matheus Almeida | 525bc4f | 2014-04-30 11:28:42 +0000 | [diff] [blame] | 326 | |
Toma Tabacu | e95a491 | 2015-03-13 11:40:01 +0000 | [diff] [blame] | 327 | void emitMipsAbiFlags(); |
Jack Carter | 86ac5c1 | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 328 | }; |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 329 | } |
Rafael Espindola | a17151a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 330 | #endif |