OLD | NEW |
1 //===- subzero/src/IceTargetLowering.h - Lowering interface -----*- C++ -*-===// | 1 //===- subzero/src/IceTargetLowering.h - Lowering interface -----*- 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 TargetLowering, LoweringContext, and | 10 // This file declares the TargetLowering, LoweringContext, and |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void skipDeleted(InstList::iterator &I) const; | 88 void skipDeleted(InstList::iterator &I) const; |
89 void advanceForward(InstList::iterator &I) const; | 89 void advanceForward(InstList::iterator &I) const; |
90 }; | 90 }; |
91 | 91 |
92 class TargetLowering { | 92 class TargetLowering { |
93 TargetLowering() = delete; | 93 TargetLowering() = delete; |
94 TargetLowering(const TargetLowering &) = delete; | 94 TargetLowering(const TargetLowering &) = delete; |
95 TargetLowering &operator=(const TargetLowering &) = delete; | 95 TargetLowering &operator=(const TargetLowering &) = delete; |
96 | 96 |
97 public: | 97 public: |
| 98 // TODO(jvoung): return a unique_ptr like the other factory functions. |
98 static TargetLowering *createLowering(TargetArch Target, Cfg *Func); | 99 static TargetLowering *createLowering(TargetArch Target, Cfg *Func); |
99 static std::unique_ptr<Assembler> createAssembler(TargetArch Target, | 100 static std::unique_ptr<Assembler> createAssembler(TargetArch Target, |
100 Cfg *Func); | 101 Cfg *Func); |
101 void translate() { | 102 void translate() { |
102 switch (Ctx->getFlags().getOptLevel()) { | 103 switch (Ctx->getFlags().getOptLevel()) { |
103 case Opt_m1: | 104 case Opt_m1: |
104 translateOm1(); | 105 translateOm1(); |
105 break; | 106 break; |
106 case Opt_0: | 107 case Opt_0: |
107 translateO0(); | 108 translateO0(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 virtual SizeT getFrameOrStackReg() const = 0; | 165 virtual SizeT getFrameOrStackReg() const = 0; |
165 virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0; | 166 virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0; |
166 bool hasComputedFrame() const { return HasComputedFrame; } | 167 bool hasComputedFrame() const { return HasComputedFrame; } |
167 // Returns true if this function calls a function that has the | 168 // Returns true if this function calls a function that has the |
168 // "returns twice" attribute. | 169 // "returns twice" attribute. |
169 bool callsReturnsTwice() const { return CallsReturnsTwice; } | 170 bool callsReturnsTwice() const { return CallsReturnsTwice; } |
170 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } | 171 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } |
171 int32_t getStackAdjustment() const { return StackAdjustment; } | 172 int32_t getStackAdjustment() const { return StackAdjustment; } |
172 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; } | 173 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; } |
173 void resetStackAdjustment() { StackAdjustment = 0; } | 174 void resetStackAdjustment() { StackAdjustment = 0; } |
| 175 SizeT makeNextLabelNumber() { return NextLabelNumber++; } |
174 LoweringContext &getContext() { return Context; } | 176 LoweringContext &getContext() { return Context; } |
175 | 177 |
176 enum RegSet { | 178 enum RegSet { |
177 RegSet_None = 0, | 179 RegSet_None = 0, |
178 RegSet_CallerSave = 1 << 0, | 180 RegSet_CallerSave = 1 << 0, |
179 RegSet_CalleeSave = 1 << 1, | 181 RegSet_CalleeSave = 1 << 1, |
180 RegSet_StackPointer = 1 << 2, | 182 RegSet_StackPointer = 1 << 2, |
181 RegSet_FramePointer = 1 << 3, | 183 RegSet_FramePointer = 1 << 3, |
182 RegSet_All = ~RegSet_None | 184 RegSet_All = ~RegSet_None |
183 }; | 185 }; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 virtual void lowerSwitch(const InstSwitch *Inst) = 0; | 236 virtual void lowerSwitch(const InstSwitch *Inst) = 0; |
235 virtual void lowerUnreachable(const InstUnreachable *Inst) = 0; | 237 virtual void lowerUnreachable(const InstUnreachable *Inst) = 0; |
236 | 238 |
237 virtual void doAddressOptLoad() {} | 239 virtual void doAddressOptLoad() {} |
238 virtual void doAddressOptStore() {} | 240 virtual void doAddressOptStore() {} |
239 virtual void randomlyInsertNop(float Probability) = 0; | 241 virtual void randomlyInsertNop(float Probability) = 0; |
240 // This gives the target an opportunity to post-process the lowered | 242 // This gives the target an opportunity to post-process the lowered |
241 // expansion before returning. | 243 // expansion before returning. |
242 virtual void postLower() {} | 244 virtual void postLower() {} |
243 | 245 |
| 246 // Make a call to an external helper function. |
| 247 InstCall *makeHelperCall(const IceString &Name, Variable *Dest, |
| 248 SizeT MaxSrcs); |
| 249 |
244 Cfg *Func; | 250 Cfg *Func; |
245 GlobalContext *Ctx; | 251 GlobalContext *Ctx; |
246 bool HasComputedFrame; | 252 bool HasComputedFrame; |
247 bool CallsReturnsTwice; | 253 bool CallsReturnsTwice; |
248 // StackAdjustment keeps track of the current stack offset from its | 254 // StackAdjustment keeps track of the current stack offset from its |
249 // natural location, as arguments are pushed for a function call. | 255 // natural location, as arguments are pushed for a function call. |
250 int32_t StackAdjustment; | 256 int32_t StackAdjustment; |
| 257 SizeT NextLabelNumber; |
251 LoweringContext Context; | 258 LoweringContext Context; |
252 | 259 |
253 // Runtime helper function names | 260 // Runtime helper function names |
254 const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16"; | 261 const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16"; |
255 const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8"; | 262 const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8"; |
256 const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1"; | 263 const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1"; |
257 const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1"; | 264 const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1"; |
258 const static constexpr char *H_call_ctpop_i32 = "__popcountsi2"; | 265 const static constexpr char *H_call_ctpop_i32 = "__popcountsi2"; |
259 const static constexpr char *H_call_ctpop_i64 = "__popcountdi2"; | 266 const static constexpr char *H_call_ctpop_i64 = "__popcountdi2"; |
260 const static constexpr char *H_call_longjmp = "longjmp"; | 267 const static constexpr char *H_call_longjmp = "longjmp"; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 virtual void lowerConstants() const = 0; | 312 virtual void lowerConstants() const = 0; |
306 | 313 |
307 protected: | 314 protected: |
308 explicit TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {} | 315 explicit TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
309 GlobalContext *Ctx; | 316 GlobalContext *Ctx; |
310 }; | 317 }; |
311 | 318 |
312 } // end of namespace Ice | 319 } // end of namespace Ice |
313 | 320 |
314 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 321 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
OLD | NEW |