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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 CfgNode *makeNode(const IceString &Name = ""); | 56 CfgNode *makeNode(const IceString &Name = ""); |
57 SizeT getNumNodes() const { return Nodes.size(); } | 57 SizeT getNumNodes() const { return Nodes.size(); } |
58 const NodeList &getNodes() const { return Nodes; } | 58 const NodeList &getNodes() const { return Nodes; } |
59 | 59 |
60 // Manage instruction numbering. | 60 // Manage instruction numbering. |
61 InstNumberT newInstNumber() { return NextInstNumber++; } | 61 InstNumberT newInstNumber() { return NextInstNumber++; } |
62 | 62 |
63 // Manage Variables. | 63 // Manage Variables. |
64 // Create a new Variable with a particular type and an optional | 64 // Create a new Variable with a particular type and an optional |
65 // name. The Node argument is the node where the variable is defined. | 65 // name. The Node argument is the node where the variable is defined. |
66 template <typename T> | 66 template <typename T> T *makeVariable(Type Ty, const IceString &Name = "") { |
67 T *makeVariable(Type Ty, const CfgNode *Node, const IceString &Name = "") { | |
68 SizeT Index = Variables.size(); | 67 SizeT Index = Variables.size(); |
69 T *Var = T::create(this, Ty, Node, Index, Name); | 68 T *Var = T::create(this, Ty, Index, Name); |
70 Variables.push_back(Var); | 69 Variables.push_back(Var); |
71 return Var; | 70 return Var; |
72 } | 71 } |
73 // TODO(stichnot): Remove this function with C++11, and use default | 72 // TODO(stichnot): Remove this function with C++11, and use default |
74 // argument <typename T=Variable> above. | 73 // argument <typename T=Variable> above. |
75 Variable *makeVariable(Type Ty, const CfgNode *Node, | 74 Variable *makeVariable(Type Ty, const IceString &Name = ""); |
76 const IceString &Name = ""); | |
77 SizeT getNumVariables() const { return Variables.size(); } | 75 SizeT getNumVariables() const { return Variables.size(); } |
78 const VarList &getVariables() const { return Variables; } | 76 const VarList &getVariables() const { return Variables; } |
79 | 77 |
80 // Manage arguments to the function. | 78 // Manage arguments to the function. |
81 void addArg(Variable *Arg); | 79 void addArg(Variable *Arg); |
82 const VarList &getArgs() const { return Args; } | 80 const VarList &getArgs() const { return Args; } |
83 VarList &getArgs() { return Args; } | 81 VarList &getArgs() { return Args; } |
84 | 82 |
85 // Miscellaneous accessors. | 83 // Miscellaneous accessors. |
86 TargetLowering *getTarget() const { return Target.get(); } | 84 TargetLowering *getTarget() const { return Target.get(); } |
| 85 VariablesMetadata *getVMetadata() const { return VMetadata.get(); } |
87 Liveness *getLiveness() const { return Live.get(); } | 86 Liveness *getLiveness() const { return Live.get(); } |
88 bool hasComputedFrame() const; | 87 bool hasComputedFrame() const; |
89 | 88 |
90 // Passes over the CFG. | 89 // Passes over the CFG. |
91 void translate(); | 90 void translate(); |
92 // After the CFG is fully constructed, iterate over the nodes and | 91 // After the CFG is fully constructed, iterate over the nodes and |
93 // compute the predecessor edges, in the form of | 92 // compute the predecessor edges, in the form of |
94 // CfgNode::InEdges[]. | 93 // CfgNode::InEdges[]. |
95 void computePredecessors(); | 94 void computePredecessors(); |
96 void renumberInstructions(); | 95 void renumberInstructions(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 bool IsInternalLinkage; | 155 bool IsInternalLinkage; |
157 bool HasError; | 156 bool HasError; |
158 IceString ErrorMessage; | 157 IceString ErrorMessage; |
159 CfgNode *Entry; // entry basic block | 158 CfgNode *Entry; // entry basic block |
160 NodeList Nodes; // linearized node list; Entry should be first | 159 NodeList Nodes; // linearized node list; Entry should be first |
161 InstNumberT NextInstNumber; | 160 InstNumberT NextInstNumber; |
162 VarList Variables; | 161 VarList Variables; |
163 VarList Args; // subset of Variables, in argument order | 162 VarList Args; // subset of Variables, in argument order |
164 llvm::OwningPtr<Liveness> Live; | 163 llvm::OwningPtr<Liveness> Live; |
165 llvm::OwningPtr<TargetLowering> Target; | 164 llvm::OwningPtr<TargetLowering> Target; |
| 165 llvm::OwningPtr<VariablesMetadata> VMetadata; |
166 | 166 |
167 // CurrentNode is maintained during dumping/emitting just for | 167 // CurrentNode is maintained during dumping/emitting just for |
168 // validating Variable::DefNode. Normally, a traversal over | 168 // validating Variable::DefNode. Normally, a traversal over |
169 // CfgNodes maintains this, but before global operations like | 169 // CfgNodes maintains this, but before global operations like |
170 // register allocation, resetCurrentNode() should be called to avoid | 170 // register allocation, resetCurrentNode() should be called to avoid |
171 // spurious validation failures. | 171 // spurious validation failures. |
172 const CfgNode *CurrentNode; | 172 const CfgNode *CurrentNode; |
173 | 173 |
174 Cfg(const Cfg &) LLVM_DELETED_FUNCTION; | 174 Cfg(const Cfg &) LLVM_DELETED_FUNCTION; |
175 Cfg &operator=(const Cfg &) LLVM_DELETED_FUNCTION; | 175 Cfg &operator=(const Cfg &) LLVM_DELETED_FUNCTION; |
176 }; | 176 }; |
177 | 177 |
178 } // end of namespace Ice | 178 } // end of namespace Ice |
179 | 179 |
180 #endif // SUBZERO_SRC_ICECFG_H | 180 #endif // SUBZERO_SRC_ICECFG_H |
OLD | NEW |