| 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 // This file declares the CfgNode class, which represents a single | 10 /// \file |
| 11 // basic block as its instruction list, in-edge list, and out-edge | 11 /// This file declares the CfgNode class, which represents a single |
| 12 // list. | 12 /// basic block as its instruction list, in-edge list, and out-edge |
| 13 // | 13 /// list. |
| 14 /// |
| 14 //===----------------------------------------------------------------------===// | 15 //===----------------------------------------------------------------------===// |
| 15 | 16 |
| 16 #ifndef SUBZERO_SRC_ICECFGNODE_H | 17 #ifndef SUBZERO_SRC_ICECFGNODE_H |
| 17 #define SUBZERO_SRC_ICECFGNODE_H | 18 #define SUBZERO_SRC_ICECFGNODE_H |
| 18 | 19 |
| 19 #include "IceDefs.h" | 20 #include "IceDefs.h" |
| 20 #include "IceInst.h" // InstList traits | 21 #include "IceInst.h" // InstList traits |
| 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 LabelIndex) { |
| 31 return new (Func->allocate<CfgNode>()) CfgNode(Func, LabelIndex); | 32 return new (Func->allocate<CfgNode>()) CfgNode(Func, LabelIndex); |
| 32 } | 33 } |
| 33 | 34 |
| 34 // Access the label number and name for this node. | 35 /// Access the label number and name for this node. |
| 35 SizeT getIndex() const { return Number; } | 36 SizeT getIndex() const { return Number; } |
| 36 void resetIndex(SizeT NewNumber) { Number = NewNumber; } | 37 void resetIndex(SizeT NewNumber) { Number = NewNumber; } |
| 37 IceString getName() const; | 38 IceString getName() const; |
| 38 void setName(const IceString &NewName) { | 39 void setName(const IceString &NewName) { |
| 39 // Make sure that the name can only be set once. | 40 // Make sure that the name can only be set once. |
| 40 assert(NameIndex == Cfg::IdentifierIndexInvalid); | 41 assert(NameIndex == Cfg::IdentifierIndexInvalid); |
| 41 if (!NewName.empty()) | 42 if (!NewName.empty()) |
| 42 NameIndex = Func->addIdentifierName(NewName); | 43 NameIndex = Func->addIdentifierName(NewName); |
| 43 } | 44 } |
| 44 IceString getAsmName() const { | 45 IceString getAsmName() const { |
| 45 return ".L" + Func->getFunctionName() + "$" + getName(); | 46 return ".L" + Func->getFunctionName() + "$" + getName(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 // The HasReturn flag indicates that this node contains a return | 49 /// The HasReturn flag indicates that this node contains a return |
| 49 // instruction and therefore needs an epilog. | 50 /// instruction and therefore needs an epilog. |
| 50 void setHasReturn() { HasReturn = true; } | 51 void setHasReturn() { HasReturn = true; } |
| 51 bool getHasReturn() const { return HasReturn; } | 52 bool getHasReturn() const { return HasReturn; } |
| 52 | 53 |
| 53 void setNeedsPlacement(bool Value) { NeedsPlacement = Value; } | 54 void setNeedsPlacement(bool Value) { NeedsPlacement = Value; } |
| 54 bool needsPlacement() const { return NeedsPlacement; } | 55 bool needsPlacement() const { return NeedsPlacement; } |
| 55 | 56 |
| 56 // Access predecessor and successor edge lists. | 57 /// \name Access predecessor and successor edge lists. |
| 58 /// @{ |
| 57 const NodeList &getInEdges() const { return InEdges; } | 59 const NodeList &getInEdges() const { return InEdges; } |
| 58 const NodeList &getOutEdges() const { return OutEdges; } | 60 const NodeList &getOutEdges() const { return OutEdges; } |
| 61 /// @} |
| 59 | 62 |
| 60 // Manage the instruction list. | 63 /// \name Manage the instruction list. |
| 64 /// @{ |
| 61 InstList &getInsts() { return Insts; } | 65 InstList &getInsts() { return Insts; } |
| 62 PhiList &getPhis() { return Phis; } | 66 PhiList &getPhis() { return Phis; } |
| 63 void appendInst(Inst *Inst); | 67 void appendInst(Inst *Inst); |
| 64 void renumberInstructions(); | 68 void renumberInstructions(); |
| 65 // Rough and generally conservative estimate of the number of | 69 /// Rough and generally conservative estimate of the number of |
| 66 // instructions in the block. It is updated when an instruction is | 70 /// instructions in the block. It is updated when an instruction is |
| 67 // added, but not when deleted. It is recomputed during | 71 /// added, but not when deleted. It is recomputed during |
| 68 // renumberInstructions(). | 72 /// renumberInstructions(). |
| 69 InstNumberT getInstCountEstimate() const { return InstCountEstimate; } | 73 InstNumberT getInstCountEstimate() const { return InstCountEstimate; } |
| 74 /// @} |
| 70 | 75 |
| 71 // Add a predecessor edge to the InEdges list for each of this | 76 /// \name Manage predecessors and successors. |
| 72 // node's successors. | 77 /// @{ |
| 78 |
| 79 /// Add a predecessor edge to the InEdges list for each of this |
| 80 /// node's successors. |
| 73 void computePredecessors(); | 81 void computePredecessors(); |
| 74 void computeSuccessors(); | 82 void computeSuccessors(); |
| 75 CfgNode *splitIncomingEdge(CfgNode *Pred, SizeT InEdgeIndex); | 83 CfgNode *splitIncomingEdge(CfgNode *Pred, SizeT InEdgeIndex); |
| 84 /// @} |
| 76 | 85 |
| 77 void placePhiLoads(); | 86 void placePhiLoads(); |
| 78 void placePhiStores(); | 87 void placePhiStores(); |
| 79 void deletePhis(); | 88 void deletePhis(); |
| 80 void advancedPhiLowering(); | 89 void advancedPhiLowering(); |
| 81 void doAddressOpt(); | 90 void doAddressOpt(); |
| 82 void doNopInsertion(); | 91 void doNopInsertion(); |
| 83 void genCode(); | 92 void genCode(); |
| 84 void livenessLightweight(); | 93 void livenessLightweight(); |
| 85 bool liveness(Liveness *Liveness); | 94 bool liveness(Liveness *Liveness); |
| 86 void livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum, | 95 void livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum, |
| 87 InstNumberT LastInstNum); | 96 InstNumberT LastInstNum); |
| 88 void contractIfEmpty(); | 97 void contractIfEmpty(); |
| 89 void doBranchOpt(const CfgNode *NextNode); | 98 void doBranchOpt(const CfgNode *NextNode); |
| 90 void emit(Cfg *Func) const; | 99 void emit(Cfg *Func) const; |
| 91 void emitIAS(Cfg *Func) const; | 100 void emitIAS(Cfg *Func) const; |
| 92 void dump(Cfg *Func) const; | 101 void dump(Cfg *Func) const; |
| 93 | 102 |
| 94 void profileExecutionCount(VariableDeclaration *Var); | 103 void profileExecutionCount(VariableDeclaration *Var); |
| 95 | 104 |
| 96 private: | 105 private: |
| 97 CfgNode(Cfg *Func, SizeT LabelIndex); | 106 CfgNode(Cfg *Func, SizeT LabelIndex); |
| 98 Cfg *const Func; | 107 Cfg *const Func; |
| 99 SizeT Number; // label index | 108 SizeT Number; /// label index |
| 100 Cfg::IdentifierIndexType NameIndex = | 109 Cfg::IdentifierIndexType NameIndex = |
| 101 Cfg::IdentifierIndexInvalid; // index into Cfg::NodeNames table | 110 Cfg::IdentifierIndexInvalid; /// index into Cfg::NodeNames table |
| 102 bool HasReturn = false; // does this block need an epilog? | 111 bool HasReturn = false; /// does this block need an epilog? |
| 103 bool NeedsPlacement = false; | 112 bool NeedsPlacement = false; |
| 104 InstNumberT InstCountEstimate = 0; // rough instruction count estimate | 113 InstNumberT InstCountEstimate = 0; /// rough instruction count estimate |
| 105 NodeList InEdges; // in no particular order | 114 NodeList InEdges; /// in no particular order |
| 106 NodeList OutEdges; // in no particular order | 115 NodeList OutEdges; /// in no particular order |
| 107 PhiList Phis; // unordered set of phi instructions | 116 PhiList Phis; /// unordered set of phi instructions |
| 108 InstList Insts; // ordered list of non-phi instructions | 117 InstList Insts; /// ordered list of non-phi instructions |
| 109 }; | 118 }; |
| 110 | 119 |
| 111 } // end of namespace Ice | 120 } // end of namespace Ice |
| 112 | 121 |
| 113 #endif // SUBZERO_SRC_ICECFGNODE_H | 122 #endif // SUBZERO_SRC_ICECFGNODE_H |
| OLD | NEW |