| 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 |
| 11 /// \brief Declares the TargetLowering, LoweringContext, and TargetDataLowering | 11 /// \brief Declares the TargetLowering, LoweringContext, and TargetDataLowering |
| 12 /// classes. | 12 /// classes. |
| 13 /// | 13 /// |
| 14 /// TargetLowering is an abstract class used to drive the translation/lowering | 14 /// TargetLowering is an abstract class used to drive the translation/lowering |
| 15 /// process. LoweringContext maintains a context for lowering each instruction, | 15 /// process. LoweringContext maintains a context for lowering each instruction, |
| 16 /// offering conveniences such as iterating over non-deleted instructions. | 16 /// offering conveniences such as iterating over non-deleted instructions. |
| 17 /// TargetDataLowering is an abstract class used to drive the lowering/emission | 17 /// TargetDataLowering is an abstract class used to drive the lowering/emission |
| 18 /// of global initializers, external global declarations, and internal constant | 18 /// of global initializers, external global declarations, and internal constant |
| 19 /// pools. | 19 /// pools. |
| 20 /// | 20 /// |
| 21 //===----------------------------------------------------------------------===// | 21 //===----------------------------------------------------------------------===// |
| 22 | 22 |
| 23 #ifndef SUBZERO_SRC_ICETARGETLOWERING_H | 23 #ifndef SUBZERO_SRC_ICETARGETLOWERING_H |
| 24 #define SUBZERO_SRC_ICETARGETLOWERING_H | 24 #define SUBZERO_SRC_ICETARGETLOWERING_H |
| 25 | 25 |
| 26 #include "IceCfgNode.h" |
| 26 #include "IceDefs.h" | 27 #include "IceDefs.h" |
| 27 #include "IceInst.h" // for the names of the Inst subtypes | 28 #include "IceInst.h" // for the names of the Inst subtypes |
| 28 #include "IceOperand.h" | 29 #include "IceOperand.h" |
| 29 #include "IceTypes.h" | 30 #include "IceTypes.h" |
| 30 | 31 |
| 32 #include <utility> |
| 33 |
| 31 namespace Ice { | 34 namespace Ice { |
| 32 | 35 |
| 33 // UnimplementedError is defined as a macro so that we can get actual line | 36 // UnimplementedError is defined as a macro so that we can get actual line |
| 34 // numbers. | 37 // numbers. |
| 35 #define UnimplementedError(Flags) \ | 38 #define UnimplementedError(Flags) \ |
| 36 do { \ | 39 do { \ |
| 37 if (!static_cast<const ClFlags &>(Flags).getSkipUnimplemented()) { \ | 40 if (!static_cast<const ClFlags &>(Flags).getSkipUnimplemented()) { \ |
| 38 /* Use llvm_unreachable instead of report_fatal_error, which gives \ | 41 /* Use llvm_unreachable instead of report_fatal_error, which gives \ |
| 39 better stack traces. */ \ | 42 better stack traces. */ \ |
| 40 llvm_unreachable("Not yet implemented"); \ | 43 llvm_unreachable("Not yet implemented"); \ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 65 if (Iter == End) | 68 if (Iter == End) |
| 66 return nullptr; | 69 return nullptr; |
| 67 return Iter; | 70 return Iter; |
| 68 } | 71 } |
| 69 CfgNode *getNode() const { return Node; } | 72 CfgNode *getNode() const { return Node; } |
| 70 bool atEnd() const { return Cur == End; } | 73 bool atEnd() const { return Cur == End; } |
| 71 InstList::iterator getCur() const { return Cur; } | 74 InstList::iterator getCur() const { return Cur; } |
| 72 InstList::iterator getNext() const { return Next; } | 75 InstList::iterator getNext() const { return Next; } |
| 73 InstList::iterator getEnd() const { return End; } | 76 InstList::iterator getEnd() const { return End; } |
| 74 void insert(Inst *Inst); | 77 void insert(Inst *Inst); |
| 78 template <typename Inst, typename... Args> Inst *insert(Args &&... A) { |
| 79 auto *New = Inst::create(Node->getCfg(), std::forward<Args>(A)...); |
| 80 insert(New); |
| 81 return New; |
| 82 } |
| 75 Inst *getLastInserted() const; | 83 Inst *getLastInserted() const; |
| 76 void advanceCur() { Cur = Next; } | 84 void advanceCur() { Cur = Next; } |
| 77 void advanceNext() { advanceForward(Next); } | 85 void advanceNext() { advanceForward(Next); } |
| 78 void setCur(InstList::iterator C) { Cur = C; } | 86 void setCur(InstList::iterator C) { Cur = C; } |
| 79 void setNext(InstList::iterator N) { Next = N; } | 87 void setNext(InstList::iterator N) { Next = N; } |
| 80 void rewind(); | 88 void rewind(); |
| 81 void setInsertPoint(const InstList::iterator &Position) { Next = Position; } | 89 void setInsertPoint(const InstList::iterator &Position) { Next = Position; } |
| 82 void availabilityReset(); | 90 void availabilityReset(); |
| 83 void availabilityUpdate(); | 91 void availabilityUpdate(); |
| 84 Variable *availabilityGet(Operand *Src) const; | 92 Variable *availabilityGet(Operand *Src) const; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 /// Sort the variables in Source based on required alignment. The variables | 371 /// Sort the variables in Source based on required alignment. The variables |
| 364 /// with the largest alignment need are placed in the front of the Dest list. | 372 /// with the largest alignment need are placed in the front of the Dest list. |
| 365 void sortVarsByAlignment(VarList &Dest, const VarList &Source) const; | 373 void sortVarsByAlignment(VarList &Dest, const VarList &Source) const; |
| 366 | 374 |
| 367 /// Make a call to an external helper function. | 375 /// Make a call to an external helper function. |
| 368 InstCall *makeHelperCall(const IceString &Name, Variable *Dest, | 376 InstCall *makeHelperCall(const IceString &Name, Variable *Dest, |
| 369 SizeT MaxSrcs); | 377 SizeT MaxSrcs); |
| 370 | 378 |
| 371 void | 379 void |
| 372 _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) { | 380 _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) { |
| 373 Context.insert(InstBundleLock::create(Func, BundleOption)); | 381 Context.insert<InstBundleLock>(BundleOption); |
| 374 } | 382 } |
| 375 void _bundle_unlock() { Context.insert(InstBundleUnlock::create(Func)); } | 383 void _bundle_unlock() { Context.insert<InstBundleUnlock>(); } |
| 376 void _set_dest_redefined() { Context.getLastInserted()->setDestRedefined(); } | 384 void _set_dest_redefined() { Context.getLastInserted()->setDestRedefined(); } |
| 377 | 385 |
| 378 bool shouldOptimizeMemIntrins(); | 386 bool shouldOptimizeMemIntrins(); |
| 379 | 387 |
| 380 Cfg *Func; | 388 Cfg *Func; |
| 381 GlobalContext *Ctx; | 389 GlobalContext *Ctx; |
| 382 bool HasComputedFrame = false; | 390 bool HasComputedFrame = false; |
| 383 bool CallsReturnsTwice = false; | 391 bool CallsReturnsTwice = false; |
| 384 SizeT NextLabelNumber = 0; | 392 SizeT NextLabelNumber = 0; |
| 385 SizeT NextJumpTableNumber = 0; | 393 SizeT NextJumpTableNumber = 0; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 virtual void lower() {} | 478 virtual void lower() {} |
| 471 | 479 |
| 472 protected: | 480 protected: |
| 473 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} | 481 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
| 474 GlobalContext *Ctx; | 482 GlobalContext *Ctx; |
| 475 }; | 483 }; |
| 476 | 484 |
| 477 } // end of namespace Ice | 485 } // end of namespace Ice |
| 478 | 486 |
| 479 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 487 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
| OLD | NEW |