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