Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(905)

Side by Side Diff: src/IceCfg.h

Issue 589003002: Subzero: Refactor tracking of Defs and block-local Variables. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: "Mark args as being used in the entry node" was unnecessary. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/IceCfg.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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; }
82 void addImplicitArg(Variable *Arg);
83 const VarList &getImplicitArgs() const { return ImplicitArgs; }
84 84
85 // Miscellaneous accessors. 85 // Miscellaneous accessors.
86 TargetLowering *getTarget() const { return Target.get(); } 86 TargetLowering *getTarget() const { return Target.get(); }
87 VariablesMetadata *getVMetadata() const { return VMetadata.get(); }
87 Liveness *getLiveness() const { return Live.get(); } 88 Liveness *getLiveness() const { return Live.get(); }
88 bool hasComputedFrame() const; 89 bool hasComputedFrame() const;
89 90
90 // Passes over the CFG. 91 // Passes over the CFG.
91 void translate(); 92 void translate();
92 // After the CFG is fully constructed, iterate over the nodes and 93 // After the CFG is fully constructed, iterate over the nodes and
93 // compute the predecessor edges, in the form of 94 // compute the predecessor edges, in the form of
94 // CfgNode::InEdges[]. 95 // CfgNode::InEdges[].
95 void computePredecessors(); 96 void computePredecessors();
96 void renumberInstructions(); 97 void renumberInstructions();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 IceString FunctionName; 155 IceString FunctionName;
155 Type ReturnType; 156 Type ReturnType;
156 bool IsInternalLinkage; 157 bool IsInternalLinkage;
157 bool HasError; 158 bool HasError;
158 IceString ErrorMessage; 159 IceString ErrorMessage;
159 CfgNode *Entry; // entry basic block 160 CfgNode *Entry; // entry basic block
160 NodeList Nodes; // linearized node list; Entry should be first 161 NodeList Nodes; // linearized node list; Entry should be first
161 InstNumberT NextInstNumber; 162 InstNumberT NextInstNumber;
162 VarList Variables; 163 VarList Variables;
163 VarList Args; // subset of Variables, in argument order 164 VarList Args; // subset of Variables, in argument order
165 VarList ImplicitArgs; // subset of Variables
164 llvm::OwningPtr<Liveness> Live; 166 llvm::OwningPtr<Liveness> Live;
165 llvm::OwningPtr<TargetLowering> Target; 167 llvm::OwningPtr<TargetLowering> Target;
168 llvm::OwningPtr<VariablesMetadata> VMetadata;
166 169
167 // CurrentNode is maintained during dumping/emitting just for 170 // CurrentNode is maintained during dumping/emitting just for
168 // validating Variable::DefNode. Normally, a traversal over 171 // validating Variable::DefNode. Normally, a traversal over
169 // CfgNodes maintains this, but before global operations like 172 // CfgNodes maintains this, but before global operations like
170 // register allocation, resetCurrentNode() should be called to avoid 173 // register allocation, resetCurrentNode() should be called to avoid
171 // spurious validation failures. 174 // spurious validation failures.
172 const CfgNode *CurrentNode; 175 const CfgNode *CurrentNode;
173 176
174 Cfg(const Cfg &) LLVM_DELETED_FUNCTION; 177 Cfg(const Cfg &) LLVM_DELETED_FUNCTION;
175 Cfg &operator=(const Cfg &) LLVM_DELETED_FUNCTION; 178 Cfg &operator=(const Cfg &) LLVM_DELETED_FUNCTION;
176 }; 179 };
177 180
178 } // end of namespace Ice 181 } // end of namespace Ice
179 182
180 #endif // SUBZERO_SRC_ICECFG_H 183 #endif // SUBZERO_SRC_ICECFG_H
OLDNEW
« no previous file with comments | « no previous file | src/IceCfg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698