| 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 // This file declares the TargetLoweringARM32 class, which implements the | 10 // This file declares the TargetLoweringARM32 class, which implements the |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 void emit(const ConstantUndef *C) const final; | 58 void emit(const ConstantUndef *C) const final; |
| 59 void emit(const ConstantInteger32 *C) const final; | 59 void emit(const ConstantInteger32 *C) const final; |
| 60 void emit(const ConstantInteger64 *C) const final; | 60 void emit(const ConstantInteger64 *C) const final; |
| 61 void emit(const ConstantFloat *C) const final; | 61 void emit(const ConstantFloat *C) const final; |
| 62 void emit(const ConstantDouble *C) const final; | 62 void emit(const ConstantDouble *C) const final; |
| 63 | 63 |
| 64 void lowerArguments() override; | 64 void lowerArguments() override; |
| 65 void addProlog(CfgNode *Node) override; | 65 void addProlog(CfgNode *Node) override; |
| 66 void addEpilog(CfgNode *Node) override; | 66 void addEpilog(CfgNode *Node) override; |
| 67 | 67 |
| 68 // Ensure that a 64-bit Variable has been split into 2 32-bit |
| 69 // Variables, creating them if necessary. This is needed for all |
| 70 // I64 operations. |
| 71 void split64(Variable *Var); |
| 72 Operand *loOperand(Operand *Operand); |
| 73 Operand *hiOperand(Operand *Operand); |
| 74 |
| 68 protected: | 75 protected: |
| 69 explicit TargetARM32(Cfg *Func); | 76 explicit TargetARM32(Cfg *Func); |
| 70 | 77 |
| 71 void postLower() override; | 78 void postLower() override; |
| 72 | 79 |
| 73 void lowerAlloca(const InstAlloca *Inst) override; | 80 void lowerAlloca(const InstAlloca *Inst) override; |
| 74 void lowerArithmetic(const InstArithmetic *Inst) override; | 81 void lowerArithmetic(const InstArithmetic *Inst) override; |
| 75 void lowerAssign(const InstAssign *Inst) override; | 82 void lowerAssign(const InstAssign *Inst) override; |
| 76 void lowerBr(const InstBr *Inst) override; | 83 void lowerBr(const InstBr *Inst) override; |
| 77 void lowerCall(const InstCall *Inst) override; | 84 void lowerCall(const InstCall *Inst) override; |
| 78 void lowerCast(const InstCast *Inst) override; | 85 void lowerCast(const InstCast *Inst) override; |
| 79 void lowerExtractElement(const InstExtractElement *Inst) override; | 86 void lowerExtractElement(const InstExtractElement *Inst) override; |
| 80 void lowerFcmp(const InstFcmp *Inst) override; | 87 void lowerFcmp(const InstFcmp *Inst) override; |
| 81 void lowerIcmp(const InstIcmp *Inst) override; | 88 void lowerIcmp(const InstIcmp *Inst) override; |
| 82 void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override; | 89 void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override; |
| 83 void lowerInsertElement(const InstInsertElement *Inst) override; | 90 void lowerInsertElement(const InstInsertElement *Inst) override; |
| 84 void lowerLoad(const InstLoad *Inst) override; | 91 void lowerLoad(const InstLoad *Inst) override; |
| 85 void lowerPhi(const InstPhi *Inst) override; | 92 void lowerPhi(const InstPhi *Inst) override; |
| 86 void lowerRet(const InstRet *Inst) override; | 93 void lowerRet(const InstRet *Inst) override; |
| 87 void lowerSelect(const InstSelect *Inst) override; | 94 void lowerSelect(const InstSelect *Inst) override; |
| 88 void lowerStore(const InstStore *Inst) override; | 95 void lowerStore(const InstStore *Inst) override; |
| 89 void lowerSwitch(const InstSwitch *Inst) override; | 96 void lowerSwitch(const InstSwitch *Inst) override; |
| 90 void lowerUnreachable(const InstUnreachable *Inst) override; | 97 void lowerUnreachable(const InstUnreachable *Inst) override; |
| 91 void prelowerPhis() override; | 98 void prelowerPhis() override; |
| 92 void lowerPhiAssignments(CfgNode *Node, | 99 void lowerPhiAssignments(CfgNode *Node, |
| 93 const AssignList &Assignments) override; | 100 const AssignList &Assignments) override; |
| 94 void doAddressOptLoad() override; | 101 void doAddressOptLoad() override; |
| 95 void doAddressOptStore() override; | 102 void doAddressOptStore() override; |
| 96 void randomlyInsertNop(float Probability) override; | 103 void randomlyInsertNop(float Probability) override; |
| 104 |
| 105 enum OperandLegalization { |
| 106 Legal_None = 0, |
| 107 Legal_Reg = 1 << 0, // physical register, not stack location |
| 108 Legal_Flex = 1 << 1, // A flexible operand2, which can hold rotated |
| 109 // small immediates, or shifted registers. |
| 110 Legal_Mem = 1 << 2, // includes [r0, r1 lsl #2] as well as [sp, #12] |
| 111 Legal_All = ~Legal_None |
| 112 }; |
| 113 typedef uint32_t LegalMask; |
| 114 Operand *legalize(Operand *From, LegalMask Allowed = Legal_All, |
| 115 int32_t RegNum = Variable::NoRegister); |
| 116 Variable *legalizeToVar(Operand *From, int32_t RegNum = Variable::NoRegister); |
| 117 OperandARM32Flex *legalizeToFlex(Operand *From, |
| 118 int32_t RegNum = Variable::NoRegister); |
| 119 |
| 120 Variable *makeReg(Type Ty, int32_t RegNum = Variable::NoRegister); |
| 121 static Type stackSlotType(); |
| 122 Variable *copyToReg(Operand *Src, int32_t RegNum = Variable::NoRegister); |
| 123 |
| 124 // Returns a vector in a register with the given constant entries. |
| 125 Variable *makeVectorOfZeros(Type Ty, int32_t RegNum = Variable::NoRegister); |
| 126 |
| 97 void makeRandomRegisterPermutation( | 127 void makeRandomRegisterPermutation( |
| 98 llvm::SmallVectorImpl<int32_t> &Permutation, | 128 llvm::SmallVectorImpl<int32_t> &Permutation, |
| 99 const llvm::SmallBitVector &ExcludeRegisters) const override; | 129 const llvm::SmallBitVector &ExcludeRegisters) const override; |
| 100 | 130 |
| 101 static Type stackSlotType(); | |
| 102 | |
| 103 // The following are helpers that insert lowered ARM32 instructions | 131 // The following are helpers that insert lowered ARM32 instructions |
| 104 // with minimal syntactic overhead, so that the lowering code can | 132 // with minimal syntactic overhead, so that the lowering code can |
| 105 // look as close to assembly as practical. | 133 // look as close to assembly as practical. |
| 106 | 134 |
| 135 void _ldr(Variable *Dest, OperandARM32Mem *Addr) { |
| 136 Context.insert(InstARM32Ldr::create(Func, Dest, Addr)); |
| 137 } |
| 138 // If Dest=nullptr is passed in, then a new variable is created, |
| 139 // marked as infinite register allocation weight, and returned |
| 140 // through the in/out Dest argument. |
| 141 void _mov(Variable *&Dest, Operand *Src0, |
| 142 int32_t RegNum = Variable::NoRegister) { |
| 143 if (Dest == nullptr) |
| 144 Dest = makeReg(Src0->getType(), RegNum); |
| 145 Context.insert(InstARM32Mov::create(Func, Dest, Src0)); |
| 146 } |
| 147 // The Operand can only be a 16-bit immediate or a ConstantRelocatable |
| 148 // (with an upper16 relocation). |
| 149 void _movt(Variable *&Dest, Operand *Src0) { |
| 150 Context.insert(InstARM32Movt::create(Func, Dest, Src0)); |
| 151 } |
| 152 void _movw(Variable *&Dest, Operand *Src0) { |
| 153 Context.insert(InstARM32Movw::create(Func, Dest, Src0)); |
| 154 } |
| 155 void _mvn(Variable *&Dest, Operand *Src0) { |
| 156 Context.insert(InstARM32Mvn::create(Func, Dest, Src0)); |
| 157 } |
| 107 void _ret(Variable *LR, Variable *Src0 = nullptr) { | 158 void _ret(Variable *LR, Variable *Src0 = nullptr) { |
| 108 Context.insert(InstARM32Ret::create(Func, LR, Src0)); | 159 Context.insert(InstARM32Ret::create(Func, LR, Src0)); |
| 109 } | 160 } |
| 110 | 161 |
| 111 bool UsesFramePointer; | 162 bool UsesFramePointer; |
| 112 bool NeedsStackAlignment; | 163 bool NeedsStackAlignment; |
| 113 llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; | 164 llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; |
| 114 llvm::SmallBitVector ScratchRegs; | 165 llvm::SmallBitVector ScratchRegs; |
| 115 llvm::SmallBitVector RegsUsed; | 166 llvm::SmallBitVector RegsUsed; |
| 116 VarList PhysicalRegisters[IceType_NUM]; | 167 VarList PhysicalRegisters[IceType_NUM]; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 138 | 189 |
| 139 private: | 190 private: |
| 140 void lowerGlobal(const VariableDeclaration &Var) const; | 191 void lowerGlobal(const VariableDeclaration &Var) const; |
| 141 ~TargetDataARM32() override {} | 192 ~TargetDataARM32() override {} |
| 142 template <typename T> static void emitConstantPool(GlobalContext *Ctx); | 193 template <typename T> static void emitConstantPool(GlobalContext *Ctx); |
| 143 }; | 194 }; |
| 144 | 195 |
| 145 } // end of namespace Ice | 196 } // end of namespace Ice |
| 146 | 197 |
| 147 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H | 198 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H |
| OLD | NEW |