OLD | NEW |
1 //===- subzero/src/IceCfg.h - Control flow graph ----------------*- C++ -*-===// | 1 //===- subzero/src/IceCfg.h - Control flow graph ----------------*- 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 Cfg class, which represents the control flow | 10 // This file declares the Cfg class, which represents the control flow |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // This way, we can gracefully fail to translate and let a fallback | 52 // This way, we can gracefully fail to translate and let a fallback |
53 // translator handle the function. | 53 // translator handle the function. |
54 void setError(const IceString &Message); | 54 void setError(const IceString &Message); |
55 bool hasError() const { return HasError; } | 55 bool hasError() const { return HasError; } |
56 IceString getError() const { return ErrorMessage; } | 56 IceString getError() const { return ErrorMessage; } |
57 | 57 |
58 // Manage nodes (a.k.a. basic blocks, CfgNodes). | 58 // Manage nodes (a.k.a. basic blocks, CfgNodes). |
59 void setEntryNode(CfgNode *EntryNode) { Entry = EntryNode; } | 59 void setEntryNode(CfgNode *EntryNode) { Entry = EntryNode; } |
60 CfgNode *getEntryNode() const { return Entry; } | 60 CfgNode *getEntryNode() const { return Entry; } |
61 // Create a node and append it to the end of the linearized list. | 61 // Create a node and append it to the end of the linearized list. |
62 CfgNode *makeNode(const IceString &Name = ""); | 62 CfgNode *makeNode(); |
63 SizeT getNumNodes() const { return Nodes.size(); } | 63 SizeT getNumNodes() const { return Nodes.size(); } |
64 const NodeList &getNodes() const { return Nodes; } | 64 const NodeList &getNodes() const { return Nodes; } |
| 65 // Adds a name to the list and returns its index, suitable for the |
| 66 // argument to getNodeName(). No checking for duplicates is done. |
| 67 int32_t addNodeName(const IceString &Name) { |
| 68 int32_t Index = NodeNames.size(); |
| 69 NodeNames.push_back(Name); |
| 70 return Index; |
| 71 } |
| 72 const IceString &getNodeName(int32_t Index) const { return NodeNames[Index]; } |
65 | 73 |
66 // Manage instruction numbering. | 74 // Manage instruction numbering. |
67 InstNumberT newInstNumber() { return NextInstNumber++; } | 75 InstNumberT newInstNumber() { return NextInstNumber++; } |
68 InstNumberT getNextInstNumber() const { return NextInstNumber; } | 76 InstNumberT getNextInstNumber() const { return NextInstNumber; } |
69 | 77 |
70 // Manage Variables. | 78 // Manage Variables. |
71 // Create a new Variable with a particular type and an optional | 79 // Create a new Variable with a particular type and an optional |
72 // name. The Node argument is the node where the variable is defined. | 80 // name. The Node argument is the node where the variable is defined. |
73 template <typename T = Variable> | 81 template <typename T = Variable> |
74 T *makeVariable(Type Ty, const IceString &Name = "") { | 82 T *makeVariable(Type Ty, const IceString &Name = "") { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 176 |
169 GlobalContext *Ctx; | 177 GlobalContext *Ctx; |
170 IceString FunctionName; | 178 IceString FunctionName; |
171 Type ReturnType; | 179 Type ReturnType; |
172 bool IsInternalLinkage; | 180 bool IsInternalLinkage; |
173 bool HasError; | 181 bool HasError; |
174 bool FocusedTiming; | 182 bool FocusedTiming; |
175 IceString ErrorMessage; | 183 IceString ErrorMessage; |
176 CfgNode *Entry; // entry basic block | 184 CfgNode *Entry; // entry basic block |
177 NodeList Nodes; // linearized node list; Entry should be first | 185 NodeList Nodes; // linearized node list; Entry should be first |
| 186 std::vector<IceString> NodeNames; |
178 InstNumberT NextInstNumber; | 187 InstNumberT NextInstNumber; |
179 VarList Variables; | 188 VarList Variables; |
180 VarList Args; // subset of Variables, in argument order | 189 VarList Args; // subset of Variables, in argument order |
181 VarList ImplicitArgs; // subset of Variables | 190 VarList ImplicitArgs; // subset of Variables |
182 std::unique_ptr<Liveness> Live; | 191 std::unique_ptr<Liveness> Live; |
183 std::unique_ptr<TargetLowering> Target; | 192 std::unique_ptr<TargetLowering> Target; |
184 std::unique_ptr<VariablesMetadata> VMetadata; | 193 std::unique_ptr<VariablesMetadata> VMetadata; |
185 std::unique_ptr<Assembler> TargetAssembler; | 194 std::unique_ptr<Assembler> TargetAssembler; |
186 | 195 |
187 // CurrentNode is maintained during dumping/emitting just for | 196 // CurrentNode is maintained during dumping/emitting just for |
188 // validating Variable::DefNode. Normally, a traversal over | 197 // validating Variable::DefNode. Normally, a traversal over |
189 // CfgNodes maintains this, but before global operations like | 198 // CfgNodes maintains this, but before global operations like |
190 // register allocation, resetCurrentNode() should be called to avoid | 199 // register allocation, resetCurrentNode() should be called to avoid |
191 // spurious validation failures. | 200 // spurious validation failures. |
192 const CfgNode *CurrentNode; | 201 const CfgNode *CurrentNode; |
193 }; | 202 }; |
194 | 203 |
195 } // end of namespace Ice | 204 } // end of namespace Ice |
196 | 205 |
197 #endif // SUBZERO_SRC_ICECFG_H | 206 #endif // SUBZERO_SRC_ICECFG_H |
OLD | NEW |