| OLD | NEW |
| 1 //===- subzero/src/IceCfgNode.h - Control flow graph node -------*- C++ -*-===// | 1 //===- subzero/src/IceCfgNode.h - Control flow graph node -------*- 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 CfgNode class, which represents a single basic block as | 11 /// \brief Declares the CfgNode class, which represents a single basic block as |
| 12 /// its instruction list, in-edge list, and out-edge list. | 12 /// its instruction list, in-edge list, and out-edge list. |
| 13 /// | 13 /// |
| 14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 15 | 15 |
| 16 #ifndef SUBZERO_SRC_ICECFGNODE_H | 16 #ifndef SUBZERO_SRC_ICECFGNODE_H |
| 17 #define SUBZERO_SRC_ICECFGNODE_H | 17 #define SUBZERO_SRC_ICECFGNODE_H |
| 18 | 18 |
| 19 #include "IceDefs.h" | 19 #include "IceDefs.h" |
| 20 #include "IceInst.h" // InstList traits | 20 #include "IceInst.h" // InstList traits |
| 21 #include "IceStringPool.h" |
| 21 | 22 |
| 22 namespace Ice { | 23 namespace Ice { |
| 23 | 24 |
| 24 class CfgNode { | 25 class CfgNode { |
| 25 CfgNode() = delete; | 26 CfgNode() = delete; |
| 26 CfgNode(const CfgNode &) = delete; | 27 CfgNode(const CfgNode &) = delete; |
| 27 CfgNode &operator=(const CfgNode &) = delete; | 28 CfgNode &operator=(const CfgNode &) = delete; |
| 28 | 29 |
| 29 public: | 30 public: |
| 30 static CfgNode *create(Cfg *Func, SizeT LabelIndex) { | 31 static CfgNode *create(Cfg *Func, SizeT Number) { |
| 31 return new (Func->allocate<CfgNode>()) CfgNode(Func, LabelIndex); | 32 return new (Func->allocate<CfgNode>()) CfgNode(Func, Number); |
| 32 } | 33 } |
| 33 | 34 |
| 34 Cfg *getCfg() const { return Func; } | 35 Cfg *getCfg() const { return Func; } |
| 35 | 36 |
| 36 /// Access the label number and name for this node. | 37 /// Access the label number and name for this node. |
| 37 SizeT getIndex() const { return Number; } | 38 SizeT getIndex() const { return Number; } |
| 38 void resetIndex(SizeT NewNumber) { Number = NewNumber; } | 39 void resetIndex(SizeT NewNumber) { Number = NewNumber; } |
| 39 IceString getName() const; | 40 NodeString getName() const { return Name; } |
| 40 void setName(const IceString &NewName) { | 41 void setName(const std::string &NewName) { |
| 41 // Make sure that the name can only be set once. | 42 if (NewName.empty()) |
| 42 assert(NameIndex == Cfg::IdentifierIndexInvalid); | 43 return; |
| 43 if (!NewName.empty()) | 44 Name = NodeString::createWithString(Func, NewName); |
| 44 NameIndex = Func->addIdentifierName(NewName); | |
| 45 } | 45 } |
| 46 IceString getAsmName() const { | 46 std::string getAsmName() const { |
| 47 return ".L" + Func->getFunctionName() + "$" + getName(); | 47 return ".L" + Func->getFunctionName() + "$" + getName(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void incrementLoopNestDepth() { ++LoopNestDepth; } | 50 void incrementLoopNestDepth() { ++LoopNestDepth; } |
| 51 void setLoopNestDepth(SizeT NewDepth) { LoopNestDepth = NewDepth; } | 51 void setLoopNestDepth(SizeT NewDepth) { LoopNestDepth = NewDepth; } |
| 52 SizeT getLoopNestDepth() const { return LoopNestDepth; } | 52 SizeT getLoopNestDepth() const { return LoopNestDepth; } |
| 53 | 53 |
| 54 /// The HasReturn flag indicates that this node contains a return instruction | 54 /// The HasReturn flag indicates that this node contains a return instruction |
| 55 /// and therefore needs an epilog. | 55 /// and therefore needs an epilog. |
| 56 void setHasReturn() { HasReturn = true; } | 56 void setHasReturn() { HasReturn = true; } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 InstNumberT LastInstNum); | 104 InstNumberT LastInstNum); |
| 105 void contractIfEmpty(); | 105 void contractIfEmpty(); |
| 106 void doBranchOpt(const CfgNode *NextNode); | 106 void doBranchOpt(const CfgNode *NextNode); |
| 107 void emit(Cfg *Func) const; | 107 void emit(Cfg *Func) const; |
| 108 void emitIAS(Cfg *Func) const; | 108 void emitIAS(Cfg *Func) const; |
| 109 void dump(Cfg *Func) const; | 109 void dump(Cfg *Func) const; |
| 110 | 110 |
| 111 void profileExecutionCount(VariableDeclaration *Var); | 111 void profileExecutionCount(VariableDeclaration *Var); |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 CfgNode(Cfg *Func, SizeT LabelIndex); | 114 CfgNode(Cfg *Func, SizeT Number); |
| 115 bool livenessValidateIntervals(Liveness *Liveness) const; | 115 bool livenessValidateIntervals(Liveness *Liveness) const; |
| 116 Cfg *const Func; | 116 Cfg *const Func; |
| 117 SizeT Number; /// invariant: Func->Nodes[Number]==this | 117 SizeT Number; /// invariant: Func->Nodes[Number]==this |
| 118 const SizeT LabelNumber; /// persistent number for label generation | 118 NodeString Name; |
| 119 Cfg::IdentifierIndexType NameIndex = | 119 SizeT LoopNestDepth = 0; /// the loop nest depth of this node |
| 120 Cfg::IdentifierIndexInvalid; /// index into Cfg::NodeNames table | 120 bool HasReturn = false; /// does this block need an epilog? |
| 121 SizeT LoopNestDepth = 0; /// the loop nest depth of this node | |
| 122 bool HasReturn = false; /// does this block need an epilog? | |
| 123 bool NeedsPlacement = false; | 121 bool NeedsPlacement = false; |
| 124 bool NeedsAlignment = false; /// is sandboxing required? | 122 bool NeedsAlignment = false; /// is sandboxing required? |
| 125 InstNumberT InstCountEstimate = 0; /// rough instruction count estimate | 123 InstNumberT InstCountEstimate = 0; /// rough instruction count estimate |
| 126 NodeList InEdges; /// in no particular order | 124 NodeList InEdges; /// in no particular order |
| 127 NodeList OutEdges; /// in no particular order | 125 NodeList OutEdges; /// in no particular order |
| 128 PhiList Phis; /// unordered set of phi instructions | 126 PhiList Phis; /// unordered set of phi instructions |
| 129 InstList Insts; /// ordered list of non-phi instructions | 127 InstList Insts; /// ordered list of non-phi instructions |
| 130 }; | 128 }; |
| 131 | 129 |
| 132 } // end of namespace Ice | 130 } // end of namespace Ice |
| 133 | 131 |
| 134 #endif // SUBZERO_SRC_ICECFGNODE_H | 132 #endif // SUBZERO_SRC_ICECFGNODE_H |
| OLD | NEW |