| 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 |
| 11 // basic block as its instruction list, in-edge list, and out-edge | 11 // basic block as its instruction list, in-edge list, and out-edge |
| 12 // list. | 12 // 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 | 21 |
| 22 namespace Ice { | 22 namespace Ice { |
| 23 | 23 |
| 24 class CfgNode { | 24 class CfgNode { |
| 25 CfgNode(const CfgNode &) = delete; | 25 CfgNode(const CfgNode &) = delete; |
| 26 CfgNode &operator=(const CfgNode &) = delete; | 26 CfgNode &operator=(const CfgNode &) = delete; |
| 27 | 27 |
| 28 public: | 28 public: |
| 29 static CfgNode *create(Cfg *Func, SizeT LabelIndex, IceString Name = "") { | 29 static CfgNode *create(Cfg *Func, SizeT LabelIndex) { |
| 30 return new (Func->allocate<CfgNode>()) CfgNode(Func, LabelIndex, Name); | 30 return new (Func->allocate<CfgNode>()) CfgNode(Func, LabelIndex); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // Access the label number and name for this node. | 33 // Access the label number and name for this node. |
| 34 SizeT getIndex() const { return Number; } | 34 SizeT getIndex() const { return Number; } |
| 35 IceString getName() const; | 35 IceString getName() const; |
| 36 void setName(IceString &NewName) { | 36 void setName(const IceString &NewName) { |
| 37 // Make sure that the name can only be set once. | 37 // Make sure that the name can only be set once. |
| 38 assert(Name.empty()); | 38 assert(NameIndex < 0); |
| 39 Name = NewName; | 39 if (!NewName.empty()) |
| 40 NameIndex = Func->addNodeName(NewName); |
| 40 } | 41 } |
| 41 IceString getAsmName() const { | 42 IceString getAsmName() const { |
| 42 return ".L" + Func->getFunctionName() + "$" + getName(); | 43 return ".L" + Func->getFunctionName() + "$" + getName(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 // The HasReturn flag indicates that this node contains a return | 46 // The HasReturn flag indicates that this node contains a return |
| 46 // instruction and therefore needs an epilog. | 47 // instruction and therefore needs an epilog. |
| 47 void setHasReturn() { HasReturn = true; } | 48 void setHasReturn() { HasReturn = true; } |
| 48 bool getHasReturn() const { return HasReturn; } | 49 bool getHasReturn() const { return HasReturn; } |
| 49 | 50 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 80 void livenessLightweight(); | 81 void livenessLightweight(); |
| 81 bool liveness(Liveness *Liveness); | 82 bool liveness(Liveness *Liveness); |
| 82 void livenessPostprocess(LivenessMode Mode, Liveness *Liveness); | 83 void livenessPostprocess(LivenessMode Mode, Liveness *Liveness); |
| 83 void contractIfEmpty(); | 84 void contractIfEmpty(); |
| 84 void doBranchOpt(const CfgNode *NextNode); | 85 void doBranchOpt(const CfgNode *NextNode); |
| 85 void emit(Cfg *Func) const; | 86 void emit(Cfg *Func) const; |
| 86 void emitIAS(Cfg *Func) const; | 87 void emitIAS(Cfg *Func) const; |
| 87 void dump(Cfg *Func) const; | 88 void dump(Cfg *Func) const; |
| 88 | 89 |
| 89 private: | 90 private: |
| 90 CfgNode(Cfg *Func, SizeT LabelIndex, IceString Name); | 91 CfgNode(Cfg *Func, SizeT LabelIndex); |
| 91 Cfg *const Func; | 92 Cfg *const Func; |
| 92 const SizeT Number; // label index | 93 const SizeT Number; // label index |
| 93 IceString Name; // for dumping only | 94 int32_t NameIndex; // index into Cfg::NodeNames table |
| 94 bool HasReturn; // does this block need an epilog? | 95 bool HasReturn; // does this block need an epilog? |
| 95 bool NeedsPlacement; | 96 bool NeedsPlacement; |
| 96 InstNumberT InstCountEstimate; // rough instruction count estimate | 97 InstNumberT InstCountEstimate; // rough instruction count estimate |
| 97 NodeList InEdges; // in no particular order | 98 NodeList InEdges; // in no particular order |
| 98 NodeList OutEdges; // in no particular order | 99 NodeList OutEdges; // in no particular order |
| 99 PhiList Phis; // unordered set of phi instructions | 100 PhiList Phis; // unordered set of phi instructions |
| 100 InstList Insts; // ordered list of non-phi instructions | 101 InstList Insts; // ordered list of non-phi instructions |
| 101 }; | 102 }; |
| 102 | 103 |
| 103 } // end of namespace Ice | 104 } // end of namespace Ice |
| 104 | 105 |
| 105 #endif // SUBZERO_SRC_ICECFGNODE_H | 106 #endif // SUBZERO_SRC_ICECFGNODE_H |
| OLD | NEW |