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 /// \file | 10 /// \file |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 }; | 139 }; |
140 | 140 |
141 class TargetLowering { | 141 class TargetLowering { |
142 TargetLowering() = delete; | 142 TargetLowering() = delete; |
143 TargetLowering(const TargetLowering &) = delete; | 143 TargetLowering(const TargetLowering &) = delete; |
144 TargetLowering &operator=(const TargetLowering &) = delete; | 144 TargetLowering &operator=(const TargetLowering &) = delete; |
145 | 145 |
146 public: | 146 public: |
147 // TODO(jvoung): return a unique_ptr like the other factory functions. | 147 // TODO(jvoung): return a unique_ptr like the other factory functions. |
148 static TargetLowering *createLowering(TargetArch Target, Cfg *Func); | 148 static TargetLowering *createLowering(TargetArch Target, Cfg *Func); |
149 static void staticInit(TargetArch Target); | 149 static void staticInit(const ClFlags &Flags); |
150 // Each target must define a public static method: | 150 // Each target must define a public static method: |
151 // static void staticInit(); | 151 // static void staticInit(const ClFlags &Flags); |
152 static std::unique_ptr<Assembler> createAssembler(TargetArch Target, | 152 static std::unique_ptr<Assembler> createAssembler(TargetArch Target, |
153 Cfg *Func); | 153 Cfg *Func); |
154 void translate() { | 154 void translate() { |
155 switch (Ctx->getFlags().getOptLevel()) { | 155 switch (Ctx->getFlags().getOptLevel()) { |
156 case Opt_m1: | 156 case Opt_m1: |
157 translateOm1(); | 157 translateOm1(); |
158 break; | 158 break; |
159 case Opt_0: | 159 case Opt_0: |
160 translateO0(); | 160 translateO0(); |
161 break; | 161 break; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 virtual bool shouldSplitToVariable64On32(Type Ty) const = 0; | 227 virtual bool shouldSplitToVariable64On32(Type Ty) const = 0; |
228 | 228 |
229 bool hasComputedFrame() const { return HasComputedFrame; } | 229 bool hasComputedFrame() const { return HasComputedFrame; } |
230 /// Returns true if this function calls a function that has the "returns | 230 /// Returns true if this function calls a function that has the "returns |
231 /// twice" attribute. | 231 /// twice" attribute. |
232 bool callsReturnsTwice() const { return CallsReturnsTwice; } | 232 bool callsReturnsTwice() const { return CallsReturnsTwice; } |
233 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } | 233 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } |
234 SizeT makeNextLabelNumber() { return NextLabelNumber++; } | 234 SizeT makeNextLabelNumber() { return NextLabelNumber++; } |
235 SizeT makeNextJumpTableNumber() { return NextJumpTableNumber++; } | 235 SizeT makeNextJumpTableNumber() { return NextJumpTableNumber++; } |
236 LoweringContext &getContext() { return Context; } | 236 LoweringContext &getContext() { return Context; } |
| 237 Cfg *getFunc() const { return Func; } |
| 238 GlobalContext *getGlobalContext() const { return Ctx; } |
237 | 239 |
238 enum RegSet { | 240 enum RegSet { |
239 RegSet_None = 0, | 241 RegSet_None = 0, |
240 RegSet_CallerSave = 1 << 0, | 242 RegSet_CallerSave = 1 << 0, |
241 RegSet_CalleeSave = 1 << 1, | 243 RegSet_CalleeSave = 1 << 1, |
242 RegSet_StackPointer = 1 << 2, | 244 RegSet_StackPointer = 1 << 2, |
243 RegSet_FramePointer = 1 << 3, | 245 RegSet_FramePointer = 1 << 3, |
244 RegSet_All = ~RegSet_None | 246 RegSet_All = ~RegSet_None |
245 }; | 247 }; |
246 using RegSetMask = uint32_t; | 248 using RegSetMask = uint32_t; |
(...skipping 12 matching lines...) Expand all Loading... |
259 uint64_t Salt) const = 0; | 261 uint64_t Salt) const = 0; |
260 | 262 |
261 /// Get the minimum number of clusters required for a jump table to be | 263 /// Get the minimum number of clusters required for a jump table to be |
262 /// considered. | 264 /// considered. |
263 virtual SizeT getMinJumpTableSize() const = 0; | 265 virtual SizeT getMinJumpTableSize() const = 0; |
264 virtual void emitJumpTable(const Cfg *Func, | 266 virtual void emitJumpTable(const Cfg *Func, |
265 const InstJumpTable *JumpTable) const = 0; | 267 const InstJumpTable *JumpTable) const = 0; |
266 | 268 |
267 virtual void emitVariable(const Variable *Var) const = 0; | 269 virtual void emitVariable(const Variable *Var) const = 0; |
268 | 270 |
269 void emitWithoutPrefix(const ConstantRelocatable *CR) const; | 271 void emitWithoutPrefix(const ConstantRelocatable *CR, |
270 void emit(const ConstantRelocatable *CR) const; | 272 const char *Suffix = "") const; |
271 virtual const char *getConstantPrefix() const = 0; | |
272 | 273 |
273 virtual void emit(const ConstantUndef *C) const = 0; | |
274 virtual void emit(const ConstantInteger32 *C) const = 0; | 274 virtual void emit(const ConstantInteger32 *C) const = 0; |
275 virtual void emit(const ConstantInteger64 *C) const = 0; | 275 virtual void emit(const ConstantInteger64 *C) const = 0; |
276 virtual void emit(const ConstantFloat *C) const = 0; | 276 virtual void emit(const ConstantFloat *C) const = 0; |
277 virtual void emit(const ConstantDouble *C) const = 0; | 277 virtual void emit(const ConstantDouble *C) const = 0; |
| 278 virtual void emit(const ConstantUndef *C) const = 0; |
| 279 virtual void emit(const ConstantRelocatable *CR) const = 0; |
278 | 280 |
279 /// Performs target-specific argument lowering. | 281 /// Performs target-specific argument lowering. |
280 virtual void lowerArguments() = 0; | 282 virtual void lowerArguments() = 0; |
281 | 283 |
282 virtual void initNodeForLowering(CfgNode *) {} | 284 virtual void initNodeForLowering(CfgNode *) {} |
283 virtual void addProlog(CfgNode *Node) = 0; | 285 virtual void addProlog(CfgNode *Node) = 0; |
284 virtual void addEpilog(CfgNode *Node) = 0; | 286 virtual void addEpilog(CfgNode *Node) = 0; |
285 | 287 |
286 virtual ~TargetLowering() = default; | 288 virtual ~TargetLowering() = default; |
287 | 289 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 const static constexpr char *H_call_setjmp = "setjmp"; | 410 const static constexpr char *H_call_setjmp = "setjmp"; |
409 const static constexpr char *H_fptosi_f32_i64 = "__Sz_fptosi_f32_i64"; | 411 const static constexpr char *H_fptosi_f32_i64 = "__Sz_fptosi_f32_i64"; |
410 const static constexpr char *H_fptosi_f64_i64 = "__Sz_fptosi_f64_i64"; | 412 const static constexpr char *H_fptosi_f64_i64 = "__Sz_fptosi_f64_i64"; |
411 const static constexpr char *H_fptoui_4xi32_f32 = "__Sz_fptoui_4xi32_f32"; | 413 const static constexpr char *H_fptoui_4xi32_f32 = "__Sz_fptoui_4xi32_f32"; |
412 const static constexpr char *H_fptoui_f32_i32 = "__Sz_fptoui_f32_i32"; | 414 const static constexpr char *H_fptoui_f32_i32 = "__Sz_fptoui_f32_i32"; |
413 const static constexpr char *H_fptoui_f32_i64 = "__Sz_fptoui_f32_i64"; | 415 const static constexpr char *H_fptoui_f32_i64 = "__Sz_fptoui_f32_i64"; |
414 const static constexpr char *H_fptoui_f64_i32 = "__Sz_fptoui_f64_i32"; | 416 const static constexpr char *H_fptoui_f64_i32 = "__Sz_fptoui_f64_i32"; |
415 const static constexpr char *H_fptoui_f64_i64 = "__Sz_fptoui_f64_i64"; | 417 const static constexpr char *H_fptoui_f64_i64 = "__Sz_fptoui_f64_i64"; |
416 const static constexpr char *H_frem_f32 = "fmodf"; | 418 const static constexpr char *H_frem_f32 = "fmodf"; |
417 const static constexpr char *H_frem_f64 = "fmod"; | 419 const static constexpr char *H_frem_f64 = "fmod"; |
| 420 const static constexpr char *H_getIP_prefix = "__Sz_getIP_"; |
418 const static constexpr char *H_sdiv_i32 = "__divsi3"; | 421 const static constexpr char *H_sdiv_i32 = "__divsi3"; |
419 const static constexpr char *H_sdiv_i64 = "__divdi3"; | 422 const static constexpr char *H_sdiv_i64 = "__divdi3"; |
420 const static constexpr char *H_sitofp_i64_f32 = "__Sz_sitofp_i64_f32"; | 423 const static constexpr char *H_sitofp_i64_f32 = "__Sz_sitofp_i64_f32"; |
421 const static constexpr char *H_sitofp_i64_f64 = "__Sz_sitofp_i64_f64"; | 424 const static constexpr char *H_sitofp_i64_f64 = "__Sz_sitofp_i64_f64"; |
422 const static constexpr char *H_srem_i32 = "__modsi3"; | 425 const static constexpr char *H_srem_i32 = "__modsi3"; |
423 const static constexpr char *H_srem_i64 = "__moddi3"; | 426 const static constexpr char *H_srem_i64 = "__moddi3"; |
424 const static constexpr char *H_udiv_i32 = "__udivsi3"; | 427 const static constexpr char *H_udiv_i32 = "__udivsi3"; |
425 const static constexpr char *H_udiv_i64 = "__udivdi3"; | 428 const static constexpr char *H_udiv_i64 = "__udivdi3"; |
426 const static constexpr char *H_uitofp_4xi32_4xf32 = "__Sz_uitofp_4xi32_4xf32"; | 429 const static constexpr char *H_uitofp_4xi32_4xf32 = "__Sz_uitofp_4xi32_4xf32"; |
427 const static constexpr char *H_uitofp_i32_f32 = "__Sz_uitofp_i32_f32"; | 430 const static constexpr char *H_uitofp_i32_f32 = "__Sz_uitofp_i32_f32"; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 virtual void lower() {} | 481 virtual void lower() {} |
479 | 482 |
480 protected: | 483 protected: |
481 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} | 484 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
482 GlobalContext *Ctx; | 485 GlobalContext *Ctx; |
483 }; | 486 }; |
484 | 487 |
485 } // end of namespace Ice | 488 } // end of namespace Ice |
486 | 489 |
487 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 490 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
OLD | NEW |