OLD | NEW |
1 //===- subzero/src/IceTargetLoweringARM32.h - ARM32 lowering ----*- C++ -*-===// | 1 //===- subzero/src/IceTargetLoweringARM32.h - ARM32 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 void lowerAlloca(const InstAlloca *Inst) override; | 125 void lowerAlloca(const InstAlloca *Inst) override; |
126 void lowerArithmetic(const InstArithmetic *Inst) override; | 126 void lowerArithmetic(const InstArithmetic *Inst) override; |
127 void lowerAssign(const InstAssign *Inst) override; | 127 void lowerAssign(const InstAssign *Inst) override; |
128 void lowerBr(const InstBr *Inst) override; | 128 void lowerBr(const InstBr *Inst) override; |
129 void lowerCall(const InstCall *Inst) override; | 129 void lowerCall(const InstCall *Inst) override; |
130 void lowerCast(const InstCast *Inst) override; | 130 void lowerCast(const InstCast *Inst) override; |
131 void lowerExtractElement(const InstExtractElement *Inst) override; | 131 void lowerExtractElement(const InstExtractElement *Inst) override; |
132 void lowerFcmp(const InstFcmp *Inst) override; | 132 void lowerFcmp(const InstFcmp *Inst) override; |
133 void lowerIcmp(const InstIcmp *Inst) override; | 133 void lowerIcmp(const InstIcmp *Inst) override; |
| 134 void lowerAtomicRMW(Variable *Dest, uint32_t Operation, Operand *Ptr, |
| 135 Operand *Val); |
134 void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override; | 136 void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override; |
135 void lowerInsertElement(const InstInsertElement *Inst) override; | 137 void lowerInsertElement(const InstInsertElement *Inst) override; |
136 void lowerLoad(const InstLoad *Inst) override; | 138 void lowerLoad(const InstLoad *Inst) override; |
137 void lowerPhi(const InstPhi *Inst) override; | 139 void lowerPhi(const InstPhi *Inst) override; |
138 void lowerRet(const InstRet *Inst) override; | 140 void lowerRet(const InstRet *Inst) override; |
139 void lowerSelect(const InstSelect *Inst) override; | 141 void lowerSelect(const InstSelect *Inst) override; |
140 void lowerStore(const InstStore *Inst) override; | 142 void lowerStore(const InstStore *Inst) override; |
141 void lowerSwitch(const InstSwitch *Inst) override; | 143 void lowerSwitch(const InstSwitch *Inst) override; |
142 void lowerUnreachable(const InstUnreachable *Inst) override; | 144 void lowerUnreachable(const InstUnreachable *Inst) override; |
143 void prelowerPhis() override; | 145 void prelowerPhis() override; |
144 void doAddressOptLoad() override; | 146 void doAddressOptLoad() override; |
145 void doAddressOptStore() override; | 147 void doAddressOptStore() override; |
146 void randomlyInsertNop(float Probability, | 148 void randomlyInsertNop(float Probability, |
147 RandomNumberGenerator &RNG) override; | 149 RandomNumberGenerator &RNG) override; |
148 | 150 |
149 enum OperandLegalization { | 151 enum OperandLegalization { |
150 Legal_None = 0, | 152 Legal_None = 0, |
151 Legal_Reg = 1 << 0, /// physical register, not stack location | 153 Legal_Reg = 1 << 0, /// physical register, not stack location |
152 Legal_Flex = 1 << 1, /// A flexible operand2, which can hold rotated small | 154 Legal_Flex = 1 << 1, /// A flexible operand2, which can hold rotated small |
153 /// immediates, or shifted registers. | 155 /// immediates, or shifted registers. |
154 Legal_Mem = 1 << 2, /// includes [r0, r1 lsl #2] as well as [sp, #12] | 156 Legal_Mem = 1 << 2, /// includes [r0, r1 lsl #2] as well as [sp, #12] |
155 Legal_All = ~Legal_None | 157 Legal_All = ~Legal_None |
156 }; | 158 }; |
157 using LegalMask = uint32_t; | 159 using LegalMask = uint32_t; |
158 Operand *legalize(Operand *From, LegalMask Allowed = Legal_All, | 160 Operand *legalize(Operand *From, LegalMask Allowed = Legal_All, |
159 int32_t RegNum = Variable::NoRegister); | 161 int32_t RegNum = Variable::NoRegister); |
160 Variable *legalizeToReg(Operand *From, int32_t RegNum = Variable::NoRegister); | 162 Variable *legalizeToReg(Operand *From, int32_t RegNum = Variable::NoRegister); |
161 OperandARM32Mem *formMemoryOperand(Operand *Ptr, Type Ty); | 163 OperandARM32Mem *formMemoryOperand(Operand *Ptr, Type Ty); |
162 | 164 |
| 165 Variable64On32 *makeI64RegPair(); |
163 Variable *makeReg(Type Ty, int32_t RegNum = Variable::NoRegister); | 166 Variable *makeReg(Type Ty, int32_t RegNum = Variable::NoRegister); |
164 static Type stackSlotType(); | 167 static Type stackSlotType(); |
165 Variable *copyToReg(Operand *Src, int32_t RegNum = Variable::NoRegister); | 168 Variable *copyToReg(Operand *Src, int32_t RegNum = Variable::NoRegister); |
166 void alignRegisterPow2(Variable *Reg, uint32_t Align); | 169 void alignRegisterPow2(Variable *Reg, uint32_t Align); |
167 | 170 |
168 /// Returns a vector in a register with the given constant entries. | 171 /// Returns a vector in a register with the given constant entries. |
169 Variable *makeVectorOfZeros(Type Ty, int32_t RegNum = Variable::NoRegister); | 172 Variable *makeVectorOfZeros(Type Ty, int32_t RegNum = Variable::NoRegister); |
170 | 173 |
171 void | 174 void |
172 makeRandomRegisterPermutation(llvm::SmallVectorImpl<int32_t> &Permutation, | 175 makeRandomRegisterPermutation(llvm::SmallVectorImpl<int32_t> &Permutation, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 auto *Instr = InstARM32Mov::create(Func, Dest, Src0, Pred); | 295 auto *Instr = InstARM32Mov::create(Func, Dest, Src0, Pred); |
293 | 296 |
294 Context.insert(Instr); | 297 Context.insert(Instr); |
295 if (Instr->isMultiDest()) { | 298 if (Instr->isMultiDest()) { |
296 // If Instr is multi-dest, then Dest must be a Variable64On32. We add a | 299 // If Instr is multi-dest, then Dest must be a Variable64On32. We add a |
297 // fake-def for Instr.DestHi here. | 300 // fake-def for Instr.DestHi here. |
298 assert(llvm::isa<Variable64On32>(Dest)); | 301 assert(llvm::isa<Variable64On32>(Dest)); |
299 Context.insert(InstFakeDef::create(Func, Instr->getDestHi())); | 302 Context.insert(InstFakeDef::create(Func, Instr->getDestHi())); |
300 } | 303 } |
301 } | 304 } |
| 305 |
302 void _mov_redefined(Variable *Dest, Operand *Src0, | 306 void _mov_redefined(Variable *Dest, Operand *Src0, |
303 CondARM32::Cond Pred = CondARM32::AL) { | 307 CondARM32::Cond Pred = CondARM32::AL) { |
304 auto *Instr = InstARM32Mov::create(Func, Dest, Src0, Pred); | 308 auto *Instr = InstARM32Mov::create(Func, Dest, Src0, Pred); |
305 Instr->setDestRedefined(); | 309 Instr->setDestRedefined(); |
306 Context.insert(Instr); | 310 Context.insert(Instr); |
307 if (Instr->isMultiDest()) { | 311 if (Instr->isMultiDest()) { |
308 // If Instr is multi-dest, then Dest must be a Variable64On32. We add a | 312 // If Instr is multi-dest, then Dest must be a Variable64On32. We add a |
309 // fake-def for Instr.DestHi here. | 313 // fake-def for Instr.DestHi here. |
310 assert(llvm::isa<Variable64On32>(Dest)); | 314 assert(llvm::isa<Variable64On32>(Dest)); |
311 Context.insert(InstFakeDef::create(Func, Instr->getDestHi())); | 315 Context.insert(InstFakeDef::create(Func, Instr->getDestHi())); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 Context.insert(InstARM32Sdiv::create(Func, Dest, Src0, Src1, Pred)); | 382 Context.insert(InstARM32Sdiv::create(Func, Dest, Src0, Src1, Pred)); |
379 } | 383 } |
380 /// _str, for all your Variable to memory transfers. Addr has the same | 384 /// _str, for all your Variable to memory transfers. Addr has the same |
381 /// restrictions that it does in _ldr. | 385 /// restrictions that it does in _ldr. |
382 void _str(Variable *Value, OperandARM32Mem *Addr, | 386 void _str(Variable *Value, OperandARM32Mem *Addr, |
383 CondARM32::Cond Pred = CondARM32::AL) { | 387 CondARM32::Cond Pred = CondARM32::AL) { |
384 Context.insert(InstARM32Str::create(Func, Value, Addr, Pred)); | 388 Context.insert(InstARM32Str::create(Func, Value, Addr, Pred)); |
385 } | 389 } |
386 void _strex(Variable *Dest, Variable *Value, OperandARM32Mem *Addr, | 390 void _strex(Variable *Dest, Variable *Value, OperandARM32Mem *Addr, |
387 CondARM32::Cond Pred = CondARM32::AL) { | 391 CondARM32::Cond Pred = CondARM32::AL) { |
| 392 // strex requires Dest to be a register other than Value or Addr. This |
| 393 // restriction is cleanly represented by adding an "early" definition of |
| 394 // Dest (or a latter use of all the sources.) |
| 395 Context.insert(InstFakeDef::create(Func, Dest)); |
388 if (auto *Value64 = llvm::dyn_cast<Variable64On32>(Value)) { | 396 if (auto *Value64 = llvm::dyn_cast<Variable64On32>(Value)) { |
389 Context.insert(InstFakeUse::create(Func, Value64->getLo())); | 397 Context.insert(InstFakeUse::create(Func, Value64->getLo())); |
390 Context.insert(InstFakeUse::create(Func, Value64->getHi())); | 398 Context.insert(InstFakeUse::create(Func, Value64->getHi())); |
391 } | 399 } |
392 Context.insert(InstARM32Strex::create(Func, Dest, Value, Addr, Pred)); | 400 auto *Instr = InstARM32Strex::create(Func, Dest, Value, Addr, Pred); |
| 401 Context.insert(Instr); |
| 402 Instr->setDestRedefined(); |
393 } | 403 } |
394 void _sub(Variable *Dest, Variable *Src0, Operand *Src1, | 404 void _sub(Variable *Dest, Variable *Src0, Operand *Src1, |
395 CondARM32::Cond Pred = CondARM32::AL) { | 405 CondARM32::Cond Pred = CondARM32::AL) { |
396 Context.insert(InstARM32Sub::create(Func, Dest, Src0, Src1, Pred)); | 406 Context.insert(InstARM32Sub::create(Func, Dest, Src0, Src1, Pred)); |
397 } | 407 } |
398 void _subs(Variable *Dest, Variable *Src0, Operand *Src1, | 408 void _subs(Variable *Dest, Variable *Src0, Operand *Src1, |
399 CondARM32::Cond Pred = CondARM32::AL) { | 409 CondARM32::Cond Pred = CondARM32::AL) { |
400 constexpr bool SetFlags = true; | 410 constexpr bool SetFlags = true; |
401 Context.insert( | 411 Context.insert( |
402 InstARM32Sub::create(Func, Dest, Src0, Src1, Pred, SetFlags)); | 412 InstARM32Sub::create(Func, Dest, Src0, Src1, Pred, SetFlags)); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 582 |
573 private: | 583 private: |
574 ~TargetHeaderARM32() = default; | 584 ~TargetHeaderARM32() = default; |
575 | 585 |
576 TargetARM32Features CPUFeatures; | 586 TargetARM32Features CPUFeatures; |
577 }; | 587 }; |
578 | 588 |
579 } // end of namespace Ice | 589 } // end of namespace Ice |
580 | 590 |
581 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H | 591 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H |
OLD | NEW |