| OLD | NEW |
| 1 //===- subzero/src/IceAssemblerMIPS32.h - Assembler for MIPS ----*- C++ -*-===// | 1 //===- subzero/src/IceAssemblerMIPS32.h - Assembler for MIPS ----*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 /// | 9 /// |
| 10 /// \file | 10 /// \file |
| 11 /// \brief Declares the Assembler class for MIPS32. | 11 /// \brief Declares the Assembler class for MIPS32. |
| 12 /// | 12 /// |
| 13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
| 14 | 14 |
| 15 #ifndef SUBZERO_SRC_ICEASSEMBLERMIPS32_H | 15 #ifndef SUBZERO_SRC_ICEASSEMBLERMIPS32_H |
| 16 #define SUBZERO_SRC_ICEASSEMBLERMIPS32_H | 16 #define SUBZERO_SRC_ICEASSEMBLERMIPS32_H |
| 17 | 17 |
| 18 #include "IceAssembler.h" | 18 #include "IceAssembler.h" |
| 19 #include "IceDefs.h" | 19 #include "IceDefs.h" |
| 20 #include "IceFixups.h" | 20 #include "IceFixups.h" |
| 21 #include "IceInstMIPS32.h" | 21 #include "IceInstMIPS32.h" |
| 22 #include "IceTargetLowering.h" | 22 #include "IceTargetLowering.h" |
| 23 | 23 |
| 24 namespace Ice { | 24 namespace Ice { |
| 25 namespace MIPS32 { | 25 namespace MIPS32 { |
| 26 | 26 |
| 27 using IValueT = uint32_t; | 27 using IValueT = uint32_t; |
| 28 using IOffsetT = int32_t; | 28 using IOffsetT = int32_t; |
| 29 | 29 |
| 30 enum FPInstDataFormat { |
| 31 SinglePrecision = 16, |
| 32 DoublePrecision = 17, |
| 33 Word = 20, |
| 34 Long = 21 |
| 35 }; |
| 36 |
| 30 class AssemblerMIPS32 : public Assembler { | 37 class AssemblerMIPS32 : public Assembler { |
| 31 AssemblerMIPS32(const AssemblerMIPS32 &) = delete; | 38 AssemblerMIPS32(const AssemblerMIPS32 &) = delete; |
| 32 AssemblerMIPS32 &operator=(const AssemblerMIPS32 &) = delete; | 39 AssemblerMIPS32 &operator=(const AssemblerMIPS32 &) = delete; |
| 33 | 40 |
| 34 public: | 41 public: |
| 35 explicit AssemblerMIPS32(bool use_far_branches = false) | 42 explicit AssemblerMIPS32(bool use_far_branches = false) |
| 36 : Assembler(Asm_MIPS32) { | 43 : Assembler(Asm_MIPS32) { |
| 37 // This mode is only needed and implemented for MIPS32 and ARM. | 44 // This mode is only needed and implemented for MIPS32 and ARM. |
| 38 assert(!use_far_branches); | 45 assert(!use_far_branches); |
| 39 (void)use_far_branches; | 46 (void)use_far_branches; |
| 40 } | 47 } |
| 41 ~AssemblerMIPS32() override { | 48 ~AssemblerMIPS32() override { |
| 42 if (BuildDefs::asserts()) { | 49 if (BuildDefs::asserts()) { |
| 43 for (const Label *Label : CfgNodeLabels) { | 50 for (const Label *Label : CfgNodeLabels) { |
| 44 Label->finalCheck(); | 51 Label->finalCheck(); |
| 45 } | 52 } |
| 46 for (const Label *Label : LocalLabels) { | 53 for (const Label *Label : LocalLabels) { |
| 47 Label->finalCheck(); | 54 Label->finalCheck(); |
| 48 } | 55 } |
| 49 } | 56 } |
| 50 } | 57 } |
| 51 | 58 |
| 52 void trap(); | 59 void trap(); |
| 53 | 60 |
| 54 void nop(); | 61 void nop(); |
| 55 | 62 |
| 56 void emitRtRsImm16(IValueT Opcode, const Operand *OpRt, const Operand *OpRs, | 63 void emitRtRsImm16(IValueT Opcode, const Operand *OpRt, const Operand *OpRs, |
| 57 const uint32_t Imm, const char *InsnName); | 64 uint32_t Imm, const char *InsnName); |
| 65 |
| 66 void emitFtRsImm16(IValueT Opcode, const Operand *OpFt, const Operand *OpRs, |
| 67 uint32_t Imm, const char *InsnName); |
| 58 | 68 |
| 59 void emitRdRtSa(IValueT Opcode, const Operand *OpRd, const Operand *OpRt, | 69 void emitRdRtSa(IValueT Opcode, const Operand *OpRd, const Operand *OpRt, |
| 60 const uint32_t Sa, const char *InsnName); | 70 uint32_t Sa, const char *InsnName); |
| 61 | 71 |
| 62 void emitRdRsRt(IValueT Opcode, const Operand *OpRd, const Operand *OpRs, | 72 void emitRdRsRt(IValueT Opcode, const Operand *OpRd, const Operand *OpRs, |
| 63 const Operand *OpRt, const char *InsnName); | 73 const Operand *OpRt, const char *InsnName); |
| 64 | 74 |
| 75 void emitCOP1FmtFsFd(IValueT Opcode, FPInstDataFormat Format, |
| 76 const Operand *OpFd, const Operand *OpFs, |
| 77 const char *InsnName); |
| 78 |
| 79 void emitCOP1FmtFtFsFd(IValueT Opcode, FPInstDataFormat Format, |
| 80 const Operand *OpFd, const Operand *OpFs, |
| 81 const Operand *OpFt, const char *InsnName); |
| 82 |
| 83 void emitCOP1FmtRtFsFd(IValueT Opcode, FPInstDataFormat Format, |
| 84 const Operand *OpFd, const Operand *OpFs, |
| 85 const Operand *OpRt, const char *InsnName); |
| 86 |
| 87 void emitCOP1MovRtFs(IValueT Opcode, const Operand *OpRt, const Operand *OpFs, |
| 88 const char *InsnName); |
| 89 |
| 65 void emitBr(const CondMIPS32::Cond Cond, const Operand *OpRs, | 90 void emitBr(const CondMIPS32::Cond Cond, const Operand *OpRs, |
| 66 const Operand *OpRt, IOffsetT Offset); | 91 const Operand *OpRt, IOffsetT Offset); |
| 67 | 92 |
| 93 void abs_d(const Operand *OpFd, const Operand *OpFs); |
| 94 |
| 95 void abs_s(const Operand *OpFd, const Operand *OpFs); |
| 96 |
| 97 void add_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 98 |
| 99 void add_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 100 |
| 101 void addu(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); |
| 102 |
| 68 void addiu(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); | 103 void addiu(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); |
| 69 | 104 |
| 105 void and_(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); |
| 106 |
| 107 void andi(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); |
| 108 |
| 109 void b(Label *TargetLabel); |
| 110 |
| 111 void cvt_d_l(const Operand *OpFd, const Operand *OpFs); |
| 112 |
| 113 void cvt_d_s(const Operand *OpFd, const Operand *OpFs); |
| 114 |
| 115 void cvt_d_w(const Operand *OpFd, const Operand *OpFs); |
| 116 |
| 117 void cvt_s_d(const Operand *OpFd, const Operand *OpFs); |
| 118 |
| 119 void cvt_s_l(const Operand *OpFd, const Operand *OpFs); |
| 120 |
| 121 void cvt_s_w(const Operand *OpFd, const Operand *OpFs); |
| 122 |
| 123 void div_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 124 |
| 125 void div_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 126 |
| 127 void lw(const Operand *OpRt, const Operand *OpBase, const uint32_t Offset); |
| 128 |
| 129 void mfc1(const Operand *OpRt, const Operand *OpFs); |
| 130 |
| 131 void mov_d(const Operand *OpFd, const Operand *OpFs); |
| 132 |
| 133 void mov_s(const Operand *OpFd, const Operand *OpFs); |
| 134 |
| 135 void move(const Operand *OpRd, const Operand *OpRs); |
| 136 |
| 137 void movn_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 138 |
| 139 void movn_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 140 |
| 141 void movz_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 142 |
| 143 void movz_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 144 |
| 145 void mtc1(const Operand *OpRt, const Operand *OpFs); |
| 146 |
| 147 void mul_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 148 |
| 149 void mul_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 150 |
| 151 void or_(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); |
| 152 |
| 153 void ori(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); |
| 154 |
| 155 void ret(void); |
| 156 |
| 157 void sll(const Operand *OpRd, const Operand *OpRt, const uint32_t Sa); |
| 158 |
| 159 void slt(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); |
| 160 |
| 70 void slti(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); | 161 void slti(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); |
| 71 | 162 |
| 72 void sltiu(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); | 163 void sltiu(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); |
| 73 | 164 |
| 74 void and_(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); | 165 void sltu(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); |
| 75 | 166 |
| 76 void andi(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); | 167 void sqrt_d(const Operand *OpFd, const Operand *OpFs); |
| 77 | 168 |
| 78 void or_(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); | 169 void sqrt_s(const Operand *OpFd, const Operand *OpFs); |
| 79 | 170 |
| 80 void ori(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); | 171 void sra(const Operand *OpRd, const Operand *OpRt, const uint32_t Sa); |
| 172 |
| 173 void srl(const Operand *OpRd, const Operand *OpRt, const uint32_t Sa); |
| 174 |
| 175 void sub_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 176 |
| 177 void sub_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); |
| 178 |
| 179 void sw(const Operand *OpRt, const Operand *OpBase, const uint32_t Offset); |
| 180 |
| 181 void trunc_l_d(const Operand *OpFd, const Operand *OpFs); |
| 182 |
| 183 void trunc_l_s(const Operand *OpFd, const Operand *OpFs); |
| 184 |
| 185 void trunc_w_d(const Operand *OpFd, const Operand *OpFs); |
| 186 |
| 187 void trunc_w_s(const Operand *OpFd, const Operand *OpFs); |
| 81 | 188 |
| 82 void xor_(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); | 189 void xor_(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); |
| 83 | 190 |
| 84 void xori(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); | 191 void xori(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); |
| 85 | 192 |
| 86 void sll(const Operand *OpRd, const Operand *OpRt, const uint32_t Sa); | |
| 87 | |
| 88 void srl(const Operand *OpRd, const Operand *OpRt, const uint32_t Sa); | |
| 89 | |
| 90 void sra(const Operand *OpRd, const Operand *OpRt, const uint32_t Sa); | |
| 91 | |
| 92 void move(const Operand *OpRd, const Operand *OpRs); | |
| 93 | |
| 94 void addu(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); | |
| 95 | |
| 96 void slt(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); | |
| 97 | |
| 98 void sltu(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); | |
| 99 | |
| 100 void sw(const Operand *OpRt, const Operand *OpBase, const uint32_t Offset); | |
| 101 | |
| 102 void lw(const Operand *OpRt, const Operand *OpBase, const uint32_t Offset); | |
| 103 | |
| 104 void ret(void); | |
| 105 | |
| 106 void b(Label *TargetLabel); | |
| 107 | |
| 108 void bcc(const CondMIPS32::Cond Cond, const Operand *OpRs, | 193 void bcc(const CondMIPS32::Cond Cond, const Operand *OpRs, |
| 109 const Operand *OpRt, Label *TargetLabel); | 194 const Operand *OpRt, Label *TargetLabel); |
| 110 | 195 |
| 111 void bzc(const CondMIPS32::Cond Cond, const Operand *OpRs, | 196 void bzc(const CondMIPS32::Cond Cond, const Operand *OpRs, |
| 112 Label *TargetLabel); | 197 Label *TargetLabel); |
| 113 | 198 |
| 114 void alignFunction() override { | 199 void alignFunction() override { |
| 115 const SizeT Align = 1 << getBundleAlignLog2Bytes(); | 200 const SizeT Align = 1 << getBundleAlignLog2Bytes(); |
| 116 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align); | 201 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align); |
| 117 constexpr SizeT InstSize = sizeof(IValueT); | 202 constexpr SizeT InstSize = sizeof(IValueT); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 void emitInst(IValueT Value) { | 258 void emitInst(IValueT Value) { |
| 174 AssemblerBuffer::EnsureCapacity _(&Buffer); | 259 AssemblerBuffer::EnsureCapacity _(&Buffer); |
| 175 Buffer.emit<IValueT>(Value); | 260 Buffer.emit<IValueT>(Value); |
| 176 } | 261 } |
| 177 }; | 262 }; |
| 178 | 263 |
| 179 } // end of namespace MIPS32 | 264 } // end of namespace MIPS32 |
| 180 } // end of namespace Ice | 265 } // end of namespace Ice |
| 181 | 266 |
| 182 #endif // SUBZERO_SRC_ICEASSEMBLERMIPS32_H | 267 #endif // SUBZERO_SRC_ICEASSEMBLERMIPS32_H |
| OLD | NEW |