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