Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 //===- subzero/src/IceTargetLoweringARM32.h - ARM32 lowering ----*- C++ -*-===// | |
| 2 // | |
| 3 // The Subzero Code Generator | |
| 4 // | |
| 5 // This file is distributed under the University of Illinois Open Source | |
| 6 // License. See LICENSE.TXT for details. | |
| 7 // | |
| 8 //===----------------------------------------------------------------------===// | |
| 9 // | |
| 10 // This file declares the TargetLoweringARM32 class, which implements the | |
| 11 // TargetLowering interface for the ARM 32-bit architecture. | |
| 12 // | |
| 13 //===----------------------------------------------------------------------===// | |
| 14 | |
| 15 #ifndef SUBZERO_SRC_ICETARGETLOWERINGARM32_H | |
| 16 #define SUBZERO_SRC_ICETARGETLOWERINGARM32_H | |
| 17 | |
| 18 #include "IceDefs.h" | |
| 19 #include "IceRegistersARM32.h" | |
| 20 #include "IceTargetLowering.h" | |
| 21 | |
| 22 namespace Ice { | |
| 23 | |
| 24 class TargetARM32 : public TargetLowering { | |
| 25 TargetARM32() = delete; | |
| 26 TargetARM32(const TargetARM32 &) = delete; | |
| 27 TargetARM32 &operator=(const TargetARM32 &) = delete; | |
| 28 | |
| 29 public: | |
| 30 static TargetARM32 *create(Cfg *Func) { return new TargetARM32(Func); } | |
|
Jim Stichnoth
2015/04/17 19:16:02
Just noticed that TargetFoo::create() and TargetLo
jvoung (off chromium)
2015/04/21 17:05:30
Done.
| |
| 31 | |
| 32 void translateOm1() override; | |
| 33 void translateO2() override; | |
| 34 bool doBranchOpt(Inst *I, const CfgNode *NextNode) override; | |
| 35 | |
| 36 SizeT getNumRegisters() const override { return RegARM32::Reg_NUM; } | |
| 37 Variable *getPhysicalRegister(SizeT RegNum, Type Ty = IceType_void) override; | |
| 38 IceString getRegName(SizeT RegNum, Type Ty) const override; | |
| 39 llvm::SmallBitVector getRegisterSet(RegSetMask Include, | |
| 40 RegSetMask Exclude) const override; | |
| 41 const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const override { | |
| 42 return TypeToRegisterSet[Ty]; | |
| 43 } | |
| 44 bool hasFramePointer() const override { return UsesFramePointer; } | |
| 45 SizeT getFrameOrStackReg() const override { | |
| 46 return UsesFramePointer ? RegARM32::Reg_fp : RegARM32::Reg_sp; | |
| 47 } | |
| 48 size_t typeWidthInBytesOnStack(Type Ty) const override { | |
| 49 // Round up to the next multiple of 4 bytes. In particular, i1, | |
| 50 // i8, and i16 are rounded up to 4 bytes. | |
| 51 return (typeWidthInBytes(Ty) + 3) & ~3; | |
| 52 } | |
| 53 void emitVariable(const Variable *Var) const override; | |
| 54 void lowerArguments() override; | |
| 55 void addProlog(CfgNode *Node) override; | |
| 56 void addEpilog(CfgNode *Node) override; | |
| 57 SizeT makeNextLabelNumber() { return NextLabelNumber++; } | |
|
Jim Stichnoth
2015/04/17 19:16:01
Maybe this should be lifted into the base class?
jvoung (off chromium)
2015/04/21 17:05:30
Done.
| |
| 58 | |
| 59 protected: | |
| 60 explicit TargetARM32(Cfg *Func); | |
| 61 | |
| 62 void postLower() override; | |
| 63 | |
| 64 void lowerAlloca(const InstAlloca *Inst) override; | |
| 65 void lowerArithmetic(const InstArithmetic *Inst) override; | |
| 66 void lowerAssign(const InstAssign *Inst) override; | |
| 67 void lowerBr(const InstBr *Inst) override; | |
| 68 void lowerCall(const InstCall *Inst) override; | |
| 69 void lowerCast(const InstCast *Inst) override; | |
| 70 void lowerExtractElement(const InstExtractElement *Inst) override; | |
| 71 void lowerFcmp(const InstFcmp *Inst) override; | |
| 72 void lowerIcmp(const InstIcmp *Inst) override; | |
| 73 void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override; | |
| 74 void lowerInsertElement(const InstInsertElement *Inst) override; | |
| 75 void lowerLoad(const InstLoad *Inst) override; | |
| 76 void lowerPhi(const InstPhi *Inst) override; | |
| 77 void lowerRet(const InstRet *Inst) override; | |
| 78 void lowerSelect(const InstSelect *Inst) override; | |
| 79 void lowerStore(const InstStore *Inst) override; | |
| 80 void lowerSwitch(const InstSwitch *Inst) override; | |
| 81 void lowerUnreachable(const InstUnreachable *Inst) override; | |
| 82 void prelowerPhis() override; | |
| 83 void lowerPhiAssignments(CfgNode *Node, | |
| 84 const AssignList &Assignments) override; | |
| 85 void doAddressOptLoad() override; | |
| 86 void doAddressOptStore() override; | |
| 87 void randomlyInsertNop(float Probability) override; | |
| 88 void makeRandomRegisterPermutation( | |
| 89 llvm::SmallVectorImpl<int32_t> &Permutation, | |
| 90 const llvm::SmallBitVector &ExcludeRegisters) const override; | |
| 91 | |
| 92 // Make a call to an external helper function. | |
| 93 // TODO(jvoung): Refactor to base TargetLowering? | |
|
Jim Stichnoth
2015/04/17 19:16:02
sgtm
jvoung (off chromium)
2015/04/21 17:05:30
Went ahead and Done it.
| |
| 94 InstCall *makeHelperCall(const IceString &Name, Variable *Dest, | |
| 95 SizeT MaxSrcs) { | |
| 96 const bool HasTailCall = false; | |
| 97 Constant *CallTarget = Ctx->getConstantExternSym(Name); | |
| 98 InstCall *Call = | |
| 99 InstCall::create(Func, MaxSrcs, Dest, CallTarget, HasTailCall); | |
| 100 return Call; | |
| 101 } | |
| 102 static Type stackSlotType(); | |
| 103 | |
| 104 bool UsesFramePointer; | |
| 105 bool NeedsStackAlignment; | |
| 106 llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; | |
| 107 llvm::SmallBitVector ScratchRegs; | |
| 108 llvm::SmallBitVector RegsUsed; | |
| 109 SizeT NextLabelNumber; | |
| 110 VarList PhysicalRegisters[IceType_NUM]; | |
| 111 static IceString RegNames[]; | |
| 112 | |
| 113 private: | |
| 114 ~TargetARM32() override {} | |
| 115 }; | |
| 116 | |
| 117 class TargetDataARM32 : public TargetDataLowering { | |
| 118 TargetDataARM32() = delete; | |
| 119 TargetDataARM32(const TargetDataARM32 &) = delete; | |
| 120 TargetDataARM32 &operator=(const TargetDataARM32 &) = delete; | |
| 121 | |
| 122 public: | |
| 123 static TargetDataLowering *create(GlobalContext *Ctx) { | |
| 124 return new TargetDataARM32(Ctx); | |
| 125 } | |
| 126 | |
| 127 void lowerGlobals(std::unique_ptr<VariableDeclarationList> Vars) const final; | |
| 128 void lowerConstants() const final; | |
| 129 | |
| 130 protected: | |
| 131 explicit TargetDataARM32(GlobalContext *Ctx); | |
| 132 | |
| 133 private: | |
| 134 void lowerGlobal(const VariableDeclaration &Var) const; | |
| 135 ~TargetDataARM32() override {} | |
| 136 template <typename T> static void emitConstantPool(GlobalContext *Ctx); | |
| 137 }; | |
| 138 | |
| 139 } // end of namespace Ice | |
| 140 | |
| 141 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H | |
| OLD | NEW |