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