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

Side by Side Diff: src/IceCfg.h

Issue 798693003: Subzero: Don't store std::string objects inside Variable. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 6 years 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/IceCfgNode.h » ('j') | src/IceOperand.h » ('J')
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(); 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
66 typedef int32_t IdentifierIndexType;
65 // Adds a name to the list and returns its index, suitable for the 67 // Adds a name to the list and returns its index, suitable for the
66 // argument to getNodeName(). No checking for duplicates is done. 68 // argument to getIdentifierName(). No checking for duplicates is
67 int32_t addNodeName(const IceString &Name) { 69 // done. This is generally used for node names and variable names
68 int32_t Index = NodeNames.size(); 70 // to avoid embedding a std::string inside an arena-allocated
69 NodeNames.push_back(Name); 71 // object.
72 IdentifierIndexType addIdentifierName(const IceString &Name) {
73 IdentifierIndexType Index = IdentifierNames.size();
74 IdentifierNames.push_back(Name);
70 return Index; 75 return Index;
71 } 76 }
72 const IceString &getNodeName(int32_t Index) const { return NodeNames[Index]; } 77 const IceString &getIdentifierName(IdentifierIndexType Index) const {
78 return IdentifierNames[Index];
79 }
80 enum {
81 IdentifierIndexInvalid = -1
82 };
73 83
74 // Manage instruction numbering. 84 // Manage instruction numbering.
75 InstNumberT newInstNumber() { return NextInstNumber++; } 85 InstNumberT newInstNumber() { return NextInstNumber++; }
76 InstNumberT getNextInstNumber() const { return NextInstNumber; } 86 InstNumberT getNextInstNumber() const { return NextInstNumber; }
77 87
78 // Manage Variables. 88 // Manage Variables.
79 // Create a new Variable with a particular type and an optional 89 // Create a new Variable with a particular type and an optional
80 // name. The Node argument is the node where the variable is defined. 90 // name. The Node argument is the node where the variable is defined.
81 template <typename T = Variable> 91 template <typename T = Variable> T *makeVariable(Type Ty) {
82 T *makeVariable(Type Ty, const IceString &Name = "") {
83 SizeT Index = Variables.size(); 92 SizeT Index = Variables.size();
84 T *Var = T::create(this, Ty, Index, Name); 93 T *Var = T::create(this, Ty, Index);
85 Variables.push_back(Var); 94 Variables.push_back(Var);
86 return Var; 95 return Var;
87 } 96 }
88 SizeT getNumVariables() const { return Variables.size(); } 97 SizeT getNumVariables() const { return Variables.size(); }
89 const VarList &getVariables() const { return Variables; } 98 const VarList &getVariables() const { return Variables; }
90 99
91 // Manage arguments to the function. 100 // Manage arguments to the function.
92 void addArg(Variable *Arg); 101 void addArg(Variable *Arg);
93 const VarList &getArgs() const { return Args; } 102 const VarList &getArgs() const { return Args; }
94 VarList &getArgs() { return Args; } 103 VarList &getArgs() { return Args; }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 185
177 GlobalContext *Ctx; 186 GlobalContext *Ctx;
178 IceString FunctionName; 187 IceString FunctionName;
179 Type ReturnType; 188 Type ReturnType;
180 bool IsInternalLinkage; 189 bool IsInternalLinkage;
181 bool HasError; 190 bool HasError;
182 bool FocusedTiming; 191 bool FocusedTiming;
183 IceString ErrorMessage; 192 IceString ErrorMessage;
184 CfgNode *Entry; // entry basic block 193 CfgNode *Entry; // entry basic block
185 NodeList Nodes; // linearized node list; Entry should be first 194 NodeList Nodes; // linearized node list; Entry should be first
186 std::vector<IceString> NodeNames; 195 std::vector<IceString> IdentifierNames;
187 InstNumberT NextInstNumber; 196 InstNumberT NextInstNumber;
188 VarList Variables; 197 VarList Variables;
189 VarList Args; // subset of Variables, in argument order 198 VarList Args; // subset of Variables, in argument order
190 VarList ImplicitArgs; // subset of Variables 199 VarList ImplicitArgs; // subset of Variables
191 std::unique_ptr<Liveness> Live; 200 std::unique_ptr<Liveness> Live;
192 std::unique_ptr<TargetLowering> Target; 201 std::unique_ptr<TargetLowering> Target;
193 std::unique_ptr<VariablesMetadata> VMetadata; 202 std::unique_ptr<VariablesMetadata> VMetadata;
194 std::unique_ptr<Assembler> TargetAssembler; 203 std::unique_ptr<Assembler> TargetAssembler;
195 204
196 // CurrentNode is maintained during dumping/emitting just for 205 // CurrentNode is maintained during dumping/emitting just for
197 // validating Variable::DefNode. Normally, a traversal over 206 // validating Variable::DefNode. Normally, a traversal over
198 // CfgNodes maintains this, but before global operations like 207 // CfgNodes maintains this, but before global operations like
199 // register allocation, resetCurrentNode() should be called to avoid 208 // register allocation, resetCurrentNode() should be called to avoid
200 // spurious validation failures. 209 // spurious validation failures.
201 const CfgNode *CurrentNode; 210 const CfgNode *CurrentNode;
202 }; 211 };
203 212
204 } // end of namespace Ice 213 } // end of namespace Ice
205 214
206 #endif // SUBZERO_SRC_ICECFG_H 215 #endif // SUBZERO_SRC_ICECFG_H
OLDNEW
« no previous file with comments | « no previous file | src/IceCfgNode.h » ('j') | src/IceOperand.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698