OLD | NEW |
1 //===- subzero/src/IceTargetLoweringMIPS32.h - MIPS32 lowering ---*- C++-*-===// | 1 //===- subzero/src/IceTargetLoweringMIPS32.h - MIPS32 lowering ---*- 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 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 llvm::report_fatal_error("Not yet implemented"); | 87 llvm::report_fatal_error("Not yet implemented"); |
88 } | 88 } |
89 void emit(const ConstantDouble *C) const final { | 89 void emit(const ConstantDouble *C) const final { |
90 (void)C; | 90 (void)C; |
91 llvm::report_fatal_error("Not yet implemented"); | 91 llvm::report_fatal_error("Not yet implemented"); |
92 } | 92 } |
93 void _ret(Variable *RA, Variable *Src0 = nullptr) { | 93 void _ret(Variable *RA, Variable *Src0 = nullptr) { |
94 Context.insert(InstMIPS32Ret::create(Func, RA, Src0)); | 94 Context.insert(InstMIPS32Ret::create(Func, RA, Src0)); |
95 } | 95 } |
96 | 96 |
| 97 void _addiu(Variable *Dest, Variable *Src, uint32_t Imm) { |
| 98 Context.insert(InstMIPS32Addiu::create(Func, Dest, Src, Imm)); |
| 99 } |
| 100 |
| 101 void _lui(Variable *Dest, uint32_t Imm) { |
| 102 Context.insert(InstMIPS32Lui::create(Func, Dest, Imm)); |
| 103 } |
| 104 |
| 105 void _mov(Variable *Dest, Operand *Src0) { |
| 106 assert(Dest != nullptr); |
| 107 // Variable* Src0_ = llvm::dyn_cast<Variable>(Src0); |
| 108 if (llvm::isa<ConstantRelocatable>(Src0)) { |
| 109 Context.insert(InstMIPS32La::create(Func, Dest, Src0)); |
| 110 } else { |
| 111 auto *Instr = InstMIPS32Mov::create(Func, Dest, Src0); |
| 112 Context.insert(Instr); |
| 113 if (Instr->isMultiDest()) { |
| 114 // If Instr is multi-dest, then Dest must be a Variable64On32. We add a |
| 115 // fake-def for Instr.DestHi here. |
| 116 assert(llvm::isa<Variable64On32>(Dest)); |
| 117 Context.insert(InstFakeDef::create(Func, Instr->getDestHi())); |
| 118 } |
| 119 } |
| 120 } |
| 121 |
| 122 void _ori(Variable *Dest, Variable *Src, uint32_t Imm) { |
| 123 Context.insert(InstMIPS32Ori::create(Func, Dest, Src, Imm)); |
| 124 } |
| 125 |
97 void lowerArguments() override; | 126 void lowerArguments() override; |
| 127 |
| 128 /// Operand legalization helpers. To deal with address mode constraints, |
| 129 /// the helpers will create a new Operand and emit instructions that |
| 130 /// guarantee that the Operand kind is one of those indicated by the |
| 131 /// LegalMask (a bitmask of allowed kinds). If the input Operand is known |
| 132 /// to already meet the constraints, it may be simply returned as the result, |
| 133 /// without creating any new instructions or operands. |
| 134 enum OperandLegalization { |
| 135 Legal_None = 0, |
| 136 Legal_Reg = 1 << 0, // physical register, not stack location |
| 137 Legal_Imm = 1 << 1, |
| 138 Legal_Mem = 1 << 2, |
| 139 Legal_All = ~Legal_None |
| 140 }; |
| 141 typedef uint32_t LegalMask; |
| 142 Operand *legalize(Operand *From, LegalMask Allowed = Legal_All, |
| 143 int32_t RegNum = Variable::NoRegister); |
| 144 |
| 145 Variable *legalizeToVar(Operand *From, int32_t RegNum = Variable::NoRegister); |
| 146 |
| 147 Variable *legalizeToReg(Operand *From, int32_t RegNum = Variable::NoRegister); |
| 148 |
| 149 Variable *makeReg(Type Ty, int32_t RegNum = Variable::NoRegister); |
| 150 static Type stackSlotType(); |
| 151 Variable *copyToReg(Operand *Src, int32_t RegNum = Variable::NoRegister); |
| 152 |
98 void addProlog(CfgNode *Node) override; | 153 void addProlog(CfgNode *Node) override; |
99 void addEpilog(CfgNode *Node) override; | 154 void addEpilog(CfgNode *Node) override; |
100 | 155 |
| 156 // Ensure that a 64-bit Variable has been split into 2 32-bit |
| 157 // Variables, creating them if necessary. This is needed for all |
| 158 // I64 operations. |
| 159 void split64(Variable *Var); |
| 160 Operand *loOperand(Operand *Operand); |
| 161 Operand *hiOperand(Operand *Operand); |
| 162 |
| 163 Operand *legalizeUndef(Operand *From, int32_t RegNum = Variable::NoRegister); |
| 164 |
101 protected: | 165 protected: |
102 explicit TargetMIPS32(Cfg *Func); | 166 explicit TargetMIPS32(Cfg *Func); |
103 | 167 |
104 void postLower() override; | 168 void postLower() override; |
105 | 169 |
106 void lowerAlloca(const InstAlloca *Inst) override; | 170 void lowerAlloca(const InstAlloca *Inst) override; |
107 void lowerArithmetic(const InstArithmetic *Inst) override; | 171 void lowerArithmetic(const InstArithmetic *Inst) override; |
108 void lowerAssign(const InstAssign *Inst) override; | 172 void lowerAssign(const InstAssign *Inst) override; |
109 void lowerBr(const InstBr *Inst) override; | 173 void lowerBr(const InstBr *Inst) override; |
110 void lowerCall(const InstCall *Inst) override; | 174 void lowerCall(const InstCall *Inst) override; |
(...skipping 13 matching lines...) Expand all Loading... |
124 void prelowerPhis() override; | 188 void prelowerPhis() override; |
125 void doAddressOptLoad() override; | 189 void doAddressOptLoad() override; |
126 void doAddressOptStore() override; | 190 void doAddressOptStore() override; |
127 void randomlyInsertNop(float Probability, | 191 void randomlyInsertNop(float Probability, |
128 RandomNumberGenerator &RNG) override; | 192 RandomNumberGenerator &RNG) override; |
129 void | 193 void |
130 makeRandomRegisterPermutation(llvm::SmallVectorImpl<int32_t> &Permutation, | 194 makeRandomRegisterPermutation(llvm::SmallVectorImpl<int32_t> &Permutation, |
131 const llvm::SmallBitVector &ExcludeRegisters, | 195 const llvm::SmallBitVector &ExcludeRegisters, |
132 uint64_t Salt) const override; | 196 uint64_t Salt) const override; |
133 | 197 |
134 static Type stackSlotType(); | |
135 | |
136 bool UsesFramePointer = false; | 198 bool UsesFramePointer = false; |
137 bool NeedsStackAlignment = false; | 199 bool NeedsStackAlignment = false; |
138 llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; | 200 llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; |
139 llvm::SmallBitVector RegisterAliases[RegMIPS32::Reg_NUM]; | 201 llvm::SmallBitVector RegisterAliases[RegMIPS32::Reg_NUM]; |
140 llvm::SmallBitVector ScratchRegs; | 202 llvm::SmallBitVector ScratchRegs; |
141 llvm::SmallBitVector RegsUsed; | 203 llvm::SmallBitVector RegsUsed; |
142 VarList PhysicalRegisters[IceType_NUM]; | 204 VarList PhysicalRegisters[IceType_NUM]; |
143 | 205 |
144 private: | 206 private: |
145 ~TargetMIPS32() override = default; | 207 ~TargetMIPS32() override = default; |
(...skipping 25 matching lines...) Expand all Loading... |
171 class TargetHeaderMIPS32 final : public TargetHeaderLowering { | 233 class TargetHeaderMIPS32 final : public TargetHeaderLowering { |
172 TargetHeaderMIPS32() = delete; | 234 TargetHeaderMIPS32() = delete; |
173 TargetHeaderMIPS32(const TargetHeaderMIPS32 &) = delete; | 235 TargetHeaderMIPS32(const TargetHeaderMIPS32 &) = delete; |
174 TargetHeaderMIPS32 &operator=(const TargetHeaderMIPS32 &) = delete; | 236 TargetHeaderMIPS32 &operator=(const TargetHeaderMIPS32 &) = delete; |
175 | 237 |
176 public: | 238 public: |
177 static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) { | 239 static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) { |
178 return std::unique_ptr<TargetHeaderLowering>(new TargetHeaderMIPS32(Ctx)); | 240 return std::unique_ptr<TargetHeaderLowering>(new TargetHeaderMIPS32(Ctx)); |
179 } | 241 } |
180 | 242 |
| 243 void lower() override; |
| 244 |
181 protected: | 245 protected: |
182 explicit TargetHeaderMIPS32(GlobalContext *Ctx); | 246 explicit TargetHeaderMIPS32(GlobalContext *Ctx); |
183 | 247 |
184 private: | 248 private: |
185 ~TargetHeaderMIPS32() = default; | 249 ~TargetHeaderMIPS32() = default; |
186 }; | 250 }; |
187 | 251 |
188 } // end of namespace Ice | 252 } // end of namespace Ice |
189 | 253 |
190 #endif // SUBZERO_SRC_ICETARGETLOWERINGMIPS32_H | 254 #endif // SUBZERO_SRC_ICETARGETLOWERINGMIPS32_H |
OLD | NEW |