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