OLD | NEW |
---|---|
(Empty) | |
1 //===- subzero/src/IceTargetLoweringMIPS32.h - MIPS32 lowering ----*- C++ -*-=== // | |
Jim Stichnoth
2015/05/30 00:47:15
80-col
| |
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 TargetLoweringMIPS32 class, which implements the | |
11 // TargetLowering interface for the MIPS 32-bit architecture. | |
12 // | |
13 //===----------------------------------------------------------------------===// | |
14 | |
15 #ifndef SUBZERO_SRC_ICETARGETLOWERINGMIPS32_H | |
16 #define SUBZERO_SRC_ICETARGETLOWERINGMIPS32_H | |
17 | |
18 #include "IceDefs.h" | |
19 #include "IceInstMIPS32.h" | |
20 #include "IceRegistersMIPS32.h" | |
21 #include "IceTargetLowering.h" | |
22 | |
23 namespace Ice { | |
24 | |
25 class TargetMIPS32 : public TargetLowering { | |
26 TargetMIPS32() = delete; | |
27 TargetMIPS32(const TargetMIPS32 &) = delete; | |
28 TargetMIPS32 &operator=(const TargetMIPS32 &) = delete; | |
29 | |
30 public: | |
31 // TODO(jvoung): return a unique_ptr. | |
32 static TargetMIPS32 *create(Cfg *Func) { return new TargetMIPS32(Func); } | |
33 | |
34 void translateOm1() override; | |
35 void translateO2() override; | |
36 bool doBranchOpt(Inst *I, const CfgNode *NextNode) override; | |
37 | |
38 SizeT getNumRegisters() const override { return RegMIPS32::Reg_NUM; } | |
39 Variable *getPhysicalRegister(SizeT RegNum, Type Ty = IceType_void) override; | |
40 IceString getRegName(SizeT RegNum, Type Ty) const override; | |
41 llvm::SmallBitVector getRegisterSet(RegSetMask Include, | |
42 RegSetMask Exclude) const override; | |
43 const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const override { | |
44 return TypeToRegisterSet[Ty]; | |
45 } | |
46 bool hasFramePointer() const override { return UsesFramePointer; } | |
47 SizeT getFrameOrStackReg() const override { | |
48 return UsesFramePointer ? RegMIPS32::Reg_FP : RegMIPS32::Reg_SP; | |
49 } | |
50 size_t typeWidthInBytesOnStack(Type Ty) const override { | |
51 // Round up to the next multiple of 4 bytes. In particular, i1, | |
52 // i8, and i16 are rounded up to 4 bytes. | |
53 return (typeWidthInBytes(Ty) + 3) & ~3; | |
54 } | |
55 void emitVariable(const Variable *Var) const override; | |
56 | |
57 const char *getConstantPrefix() const final { return ""; } | |
58 void emit(const ConstantUndef *C) const final { | |
59 llvm::report_fatal_error("Not yet implemented"); | |
60 } | |
61 void emit(const ConstantInteger32 *C) const final { | |
62 llvm::report_fatal_error("Not yet implemented"); | |
63 | |
64 } | |
65 void emit(const ConstantInteger64 *C) const final { | |
66 llvm::report_fatal_error("Not yet implemented"); | |
67 | |
68 } | |
69 void emit(const ConstantFloat *C) const final { | |
70 llvm::report_fatal_error("Not yet implemented"); | |
71 } | |
72 void emit(const ConstantDouble *C) const final { | |
73 llvm::report_fatal_error("Not yet implemented"); | |
74 } | |
75 | |
76 void lowerArguments() override; | |
77 void addProlog(CfgNode *Node) override; | |
78 void addEpilog(CfgNode *Node) override; | |
79 | |
80 protected: | |
81 explicit TargetMIPS32(Cfg *Func); | |
82 | |
83 void postLower() override; | |
84 | |
85 void lowerAlloca(const InstAlloca *Inst) override; | |
86 void lowerArithmetic(const InstArithmetic *Inst) override; | |
87 void lowerAssign(const InstAssign *Inst) override; | |
88 void lowerBr(const InstBr *Inst) override; | |
89 void lowerCall(const InstCall *Inst) override; | |
90 void lowerCast(const InstCast *Inst) override; | |
91 void lowerExtractElement(const InstExtractElement *Inst) override; | |
92 void lowerFcmp(const InstFcmp *Inst) override; | |
93 void lowerIcmp(const InstIcmp *Inst) override; | |
94 void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override; | |
95 void lowerInsertElement(const InstInsertElement *Inst) override; | |
96 void lowerLoad(const InstLoad *Inst) override; | |
97 void lowerPhi(const InstPhi *Inst) override; | |
98 void lowerRet(const InstRet *Inst) override; | |
99 void lowerSelect(const InstSelect *Inst) override; | |
100 void lowerStore(const InstStore *Inst) override; | |
101 void lowerSwitch(const InstSwitch *Inst) override; | |
102 void lowerUnreachable(const InstUnreachable *Inst) override; | |
103 void prelowerPhis() override; | |
104 void lowerPhiAssignments(CfgNode *Node, | |
105 const AssignList &Assignments) override; | |
106 void doAddressOptLoad() override; | |
107 void doAddressOptStore() override; | |
108 void randomlyInsertNop(float Probability) override; | |
109 void makeRandomRegisterPermutation( | |
110 llvm::SmallVectorImpl<int32_t> &Permutation, | |
111 const llvm::SmallBitVector &ExcludeRegisters) const override; | |
112 | |
113 static Type stackSlotType(); | |
114 | |
115 bool UsesFramePointer; | |
116 bool NeedsStackAlignment; | |
117 llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; | |
118 llvm::SmallBitVector ScratchRegs; | |
119 llvm::SmallBitVector RegsUsed; | |
120 VarList PhysicalRegisters[IceType_NUM]; | |
121 static IceString RegNames[]; | |
122 | |
123 private: | |
124 ~TargetMIPS32() override {} | |
125 }; | |
126 | |
127 class TargetDataMIPS32 : public TargetDataLowering { | |
128 TargetDataMIPS32() = delete; | |
129 TargetDataMIPS32(const TargetDataMIPS32 &) = delete; | |
130 TargetDataMIPS32 &operator=(const TargetDataMIPS32 &) = delete; | |
131 | |
132 public: | |
133 static TargetDataLowering *create(GlobalContext *Ctx) { | |
134 return new TargetDataMIPS32(Ctx); | |
135 } | |
136 | |
137 void lowerGlobals(std::unique_ptr<VariableDeclarationList> Vars) const final; | |
138 void lowerConstants() const final; | |
139 | |
140 protected: | |
141 explicit TargetDataMIPS32(GlobalContext *Ctx); | |
142 | |
143 private: | |
144 void lowerGlobal(const VariableDeclaration &Var) const; | |
145 ~TargetDataMIPS32() override {} | |
146 template <typename T> static void emitConstantPool(GlobalContext *Ctx); | |
147 }; | |
148 | |
149 } // end of namespace Ice | |
150 | |
151 #endif // SUBZERO_SRC_ICETARGETLOWERINGMIPS32_H | |
OLD | NEW |