| 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 and LoweringContext | 10 // This file declares the TargetLowering and LoweringContext |
| 11 // classes. TargetLowering is an abstract class used to drive the | 11 // classes. TargetLowering is an abstract class used to drive the |
| 12 // translation/lowering process. LoweringContext maintains a | 12 // translation/lowering process. LoweringContext maintains a |
| 13 // context for lowering each instruction, offering conveniences such | 13 // context for lowering each instruction, offering conveniences such |
| 14 // as iterating over non-deleted instructions. | 14 // as iterating over non-deleted instructions. |
| 15 // | 15 // |
| 16 //===----------------------------------------------------------------------===// | 16 //===----------------------------------------------------------------------===// |
| 17 | 17 |
| 18 #ifndef SUBZERO_SRC_ICETARGETLOWERING_H | 18 #ifndef SUBZERO_SRC_ICETARGETLOWERING_H |
| 19 #define SUBZERO_SRC_ICETARGETLOWERING_H | 19 #define SUBZERO_SRC_ICETARGETLOWERING_H |
| 20 | 20 |
| 21 #include "IceDefs.h" | 21 #include "IceDefs.h" |
| 22 #include "IceInst.h" // for the names of the Inst subtypes | 22 #include "IceInst.h" // for the names of the Inst subtypes |
| 23 #include "IceTypes.h" | 23 #include "IceTypes.h" |
| 24 | 24 |
| 25 namespace Ice { | 25 namespace Ice { |
| 26 | 26 |
| 27 typedef uint8_t AsmCodeByte; |
| 28 |
| 27 class Assembler; | 29 class Assembler; |
| 28 | 30 |
| 29 // LoweringContext makes it easy to iterate through non-deleted | 31 // LoweringContext makes it easy to iterate through non-deleted |
| 30 // instructions in a node, and insert new (lowered) instructions at | 32 // instructions in a node, and insert new (lowered) instructions at |
| 31 // the current point. Along with the instruction list container and | 33 // the current point. Along with the instruction list container and |
| 32 // associated iterators, it holds the current node, which is needed | 34 // associated iterators, it holds the current node, which is needed |
| 33 // when inserting new instructions in order to track whether variables | 35 // when inserting new instructions in order to track whether variables |
| 34 // are used as single-block or multi-block. | 36 // are used as single-block or multi-block. |
| 35 class LoweringContext { | 37 class LoweringContext { |
| 36 public: | 38 public: |
| 37 LoweringContext() : Node(NULL) {} | 39 LoweringContext() : Node(NULL) {} |
| 38 ~LoweringContext() {} | 40 ~LoweringContext() {} |
| 39 void init(CfgNode *Node); | 41 void init(CfgNode *Node); |
| 40 Inst *getNextInst() const { | 42 Inst *getNextInst() const { |
| 41 if (Next == End) | 43 if (Next == End) |
| 42 return NULL; | 44 return NULL; |
| 43 return *Next; | 45 return *Next; |
| 44 } | 46 } |
| 45 Inst *getNextInst(InstList::iterator &Iter) const { | 47 Inst *getNextInst(InstList::iterator &Iter) const { |
| 46 advanceForward(Iter); | 48 advanceForward(Iter); |
| 47 if (Iter == End) | 49 if (Iter == End) |
| 48 return NULL; | 50 return NULL; |
| 49 return *Iter; | 51 return *Iter; |
| 50 } | 52 } |
| 51 CfgNode *getNode() const { return Node; } | 53 CfgNode *getNode() const { return Node; } |
| 52 bool atEnd() const { return Cur == End; } | 54 bool atEnd() const { return Cur == End; } |
| 53 InstList::iterator getCur() const { return Cur; } | 55 InstList::iterator getCur() const { return Cur; } |
| 54 InstList::iterator getEnd() const { return End; } | 56 InstList::iterator getEnd() const { return End; } |
| 57 // Adaptor to enable range-based for loops. |
| 58 InstList::iterator begin() const { return getCur(); } |
| 59 InstList::iterator end() const { return getEnd(); } |
| 55 void insert(Inst *Inst); | 60 void insert(Inst *Inst); |
| 56 Inst *getLastInserted() const; | 61 Inst *getLastInserted() const; |
| 57 void advanceCur() { Cur = Next; } | 62 void advanceCur() { Cur = Next; } |
| 58 void advanceNext() { advanceForward(Next); } | 63 void advanceNext() { advanceForward(Next); } |
| 59 void setInsertPoint(const InstList::iterator &Position) { Next = Position; } | 64 void setInsertPoint(const InstList::iterator &Position) { Next = Position; } |
| 60 | 65 |
| 61 private: | 66 private: |
| 62 // Node is the argument to Inst::updateVars(). | 67 // Node is the argument to Inst::updateVars(). |
| 63 CfgNode *Node; | 68 CfgNode *Node; |
| 64 // Cur points to the current instruction being considered. It is | 69 // Cur points to the current instruction being considered. It is |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // the register such as in the prolog or epilog or for marking | 143 // the register such as in the prolog or epilog or for marking |
| 139 // scratch registers as killed by a call. | 144 // scratch registers as killed by a call. |
| 140 virtual Variable *getPhysicalRegister(SizeT RegNum) = 0; | 145 virtual Variable *getPhysicalRegister(SizeT RegNum) = 0; |
| 141 // Returns a printable name for the register. | 146 // Returns a printable name for the register. |
| 142 virtual IceString getRegName(SizeT RegNum, Type Ty) const = 0; | 147 virtual IceString getRegName(SizeT RegNum, Type Ty) const = 0; |
| 143 | 148 |
| 144 virtual bool hasFramePointer() const { return false; } | 149 virtual bool hasFramePointer() const { return false; } |
| 145 virtual SizeT getFrameOrStackReg() const = 0; | 150 virtual SizeT getFrameOrStackReg() const = 0; |
| 146 virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0; | 151 virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0; |
| 147 virtual SizeT getBundleAlignLog2Bytes() const = 0; | 152 virtual SizeT getBundleAlignLog2Bytes() const = 0; |
| 148 virtual llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const = 0; | 153 virtual llvm::ArrayRef<AsmCodeByte> getNonExecBundlePadding() const = 0; |
| 149 bool hasComputedFrame() const { return HasComputedFrame; } | 154 bool hasComputedFrame() const { return HasComputedFrame; } |
| 150 bool shouldDoNopInsertion() const; | 155 bool shouldDoNopInsertion() const; |
| 151 // Returns true if this function calls a function that has the | 156 // Returns true if this function calls a function that has the |
| 152 // "returns twice" attribute. | 157 // "returns twice" attribute. |
| 153 bool callsReturnsTwice() const { return CallsReturnsTwice; } | 158 bool callsReturnsTwice() const { return CallsReturnsTwice; } |
| 154 void setCallsReturnsTwice(bool RetTwice) { | 159 void setCallsReturnsTwice(bool RetTwice) { |
| 155 CallsReturnsTwice = RetTwice; | 160 CallsReturnsTwice = RetTwice; |
| 156 } | 161 } |
| 157 int32_t getStackAdjustment() const { return StackAdjustment; } | 162 int32_t getStackAdjustment() const { return StackAdjustment; } |
| 158 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; } | 163 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 private: | 260 private: |
| 256 TargetGlobalInitLowering(const TargetGlobalInitLowering &) | 261 TargetGlobalInitLowering(const TargetGlobalInitLowering &) |
| 257 LLVM_DELETED_FUNCTION; | 262 LLVM_DELETED_FUNCTION; |
| 258 TargetGlobalInitLowering & | 263 TargetGlobalInitLowering & |
| 259 operator=(const TargetGlobalInitLowering &) LLVM_DELETED_FUNCTION; | 264 operator=(const TargetGlobalInitLowering &) LLVM_DELETED_FUNCTION; |
| 260 }; | 265 }; |
| 261 | 266 |
| 262 } // end of namespace Ice | 267 } // end of namespace Ice |
| 263 | 268 |
| 264 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 269 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
| OLD | NEW |