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

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

Powered by Google App Engine
This is Rietveld 408576698