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

Side by Side Diff: src/IceCfg.h

Issue 1341423002: Reflow comments to use the full width. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix spelling and rebase Created 5 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 | « src/IceBrowserCompileServer.cpp ('k') | 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 /// \file 10 /// \file
11 /// This file declares the Cfg class, which represents the control flow 11 /// This file declares the Cfg class, which represents the control flow graph
12 /// graph and the overall per-function compilation context. 12 /// and the overall per-function compilation context.
13 /// 13 ///
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #ifndef SUBZERO_SRC_ICECFG_H 16 #ifndef SUBZERO_SRC_ICECFG_H
17 #define SUBZERO_SRC_ICECFG_H 17 #define SUBZERO_SRC_ICECFG_H
18 18
19 #include "IceAssembler.h" 19 #include "IceAssembler.h"
20 #include "IceClFlags.h" 20 #include "IceClFlags.h"
21 #include "IceDefs.h" 21 #include "IceDefs.h"
22 #include "IceGlobalContext.h" 22 #include "IceGlobalContext.h"
(...skipping 20 matching lines...) Expand all
43 } 43 }
44 /// Gets a pointer to the current thread's Cfg's allocator. 44 /// Gets a pointer to the current thread's Cfg's allocator.
45 static ArenaAllocator<> *getCurrentCfgAllocator() { 45 static ArenaAllocator<> *getCurrentCfgAllocator() {
46 assert(ICE_TLS_GET_FIELD(CurrentCfg)); 46 assert(ICE_TLS_GET_FIELD(CurrentCfg));
47 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get(); 47 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get();
48 } 48 }
49 49
50 GlobalContext *getContext() const { return Ctx; } 50 GlobalContext *getContext() const { return Ctx; }
51 uint32_t getSequenceNumber() const { return SequenceNumber; } 51 uint32_t getSequenceNumber() const { return SequenceNumber; }
52 52
53 /// Returns true if any of the specified options in the verbose mask 53 /// Returns true if any of the specified options in the verbose mask are set.
54 /// are set. If the argument is omitted, it checks if any verbose 54 /// If the argument is omitted, it checks if any verbose options at all are
55 /// options at all are set. 55 /// set.
56 bool isVerbose(VerboseMask Mask = IceV_All) const { return VMask & Mask; } 56 bool isVerbose(VerboseMask Mask = IceV_All) const { return VMask & Mask; }
57 void setVerbose(VerboseMask Mask) { VMask = Mask; } 57 void setVerbose(VerboseMask Mask) { VMask = Mask; }
58 58
59 /// \name Manage the name and return type of the function being translated. 59 /// \name Manage the name and return type of the function being translated.
60 /// @{ 60 /// @{
61 void setFunctionName(const IceString &Name) { FunctionName = Name; } 61 void setFunctionName(const IceString &Name) { FunctionName = Name; }
62 IceString getFunctionName() const { return FunctionName; } 62 IceString getFunctionName() const { return FunctionName; }
63 void setReturnType(Type Ty) { ReturnType = Ty; } 63 void setReturnType(Type Ty) { ReturnType = Ty; }
64 /// @} 64 /// @}
65 65
66 /// \name Manage the "internal" attribute of the function. 66 /// \name Manage the "internal" attribute of the function.
67 /// @{ 67 /// @{
68 void setInternal(bool Internal) { IsInternalLinkage = Internal; } 68 void setInternal(bool Internal) { IsInternalLinkage = Internal; }
69 bool getInternal() const { return IsInternalLinkage; } 69 bool getInternal() const { return IsInternalLinkage; }
70 /// @} 70 /// @}
71 71
72 /// \name Manage errors. 72 /// \name Manage errors.
73 /// @{ 73 /// @{
74 74
75 /// Translation error flagging. If support for some construct is 75 /// Translation error flagging. If support for some construct is known to be
76 /// known to be missing, instead of an assertion failure, setError() 76 /// missing, instead of an assertion failure, setError() should be called and
77 /// should be called and the error should be propagated back up. 77 /// the error should be propagated back up. This way, we can gracefully fail
78 /// This way, we can gracefully fail to translate and let a fallback 78 /// to translate and let a fallback translator handle the function.
79 /// translator handle the function.
80 void setError(const IceString &Message); 79 void setError(const IceString &Message);
81 bool hasError() const { return HasError; } 80 bool hasError() const { return HasError; }
82 IceString getError() const { return ErrorMessage; } 81 IceString getError() const { return ErrorMessage; }
83 /// @} 82 /// @}
84 83
85 /// \name Manage nodes (a.k.a. basic blocks, CfgNodes). 84 /// \name Manage nodes (a.k.a. basic blocks, CfgNodes).
86 /// @{ 85 /// @{
87 void setEntryNode(CfgNode *EntryNode) { Entry = EntryNode; } 86 void setEntryNode(CfgNode *EntryNode) { Entry = EntryNode; }
88 CfgNode *getEntryNode() const { return Entry; } 87 CfgNode *getEntryNode() const { return Entry; }
89 /// Create a node and append it to the end of the linearized list. The loop 88 /// Create a node and append it to the end of the linearized list. The loop
90 /// nest depth of the new node may not be valid if it is created after 89 /// nest depth of the new node may not be valid if it is created after
91 /// computeLoopNestDepth. 90 /// computeLoopNestDepth.
92 CfgNode *makeNode(); 91 CfgNode *makeNode();
93 SizeT getNumNodes() const { return Nodes.size(); } 92 SizeT getNumNodes() const { return Nodes.size(); }
94 const NodeList &getNodes() const { return Nodes; } 93 const NodeList &getNodes() const { return Nodes; }
95 /// Swap nodes of Cfg with given list of nodes. The number of nodes must 94 /// Swap nodes of Cfg with given list of nodes. The number of nodes must
96 /// remain unchanged. 95 /// remain unchanged.
97 void swapNodes(NodeList &NewNodes); 96 void swapNodes(NodeList &NewNodes);
98 /// @} 97 /// @}
99 98
100 using IdentifierIndexType = int32_t; 99 using IdentifierIndexType = int32_t;
101 /// Adds a name to the list and returns its index, suitable for the 100 /// Adds a name to the list and returns its index, suitable for the argument
102 /// argument to getIdentifierName(). No checking for duplicates is 101 /// to getIdentifierName(). No checking for duplicates is done. This is
103 /// done. This is generally used for node names and variable names 102 /// generally used for node names and variable names to avoid embedding a
104 /// to avoid embedding a std::string inside an arena-allocated 103 /// std::string inside an arena-allocated object.
105 /// object.
106 IdentifierIndexType addIdentifierName(const IceString &Name) { 104 IdentifierIndexType addIdentifierName(const IceString &Name) {
107 IdentifierIndexType Index = IdentifierNames.size(); 105 IdentifierIndexType Index = IdentifierNames.size();
108 IdentifierNames.push_back(Name); 106 IdentifierNames.push_back(Name);
109 return Index; 107 return Index;
110 } 108 }
111 const IceString &getIdentifierName(IdentifierIndexType Index) const { 109 const IceString &getIdentifierName(IdentifierIndexType Index) const {
112 return IdentifierNames[Index]; 110 return IdentifierNames[Index];
113 } 111 }
114 enum { IdentifierIndexInvalid = -1 }; 112 enum { IdentifierIndexInvalid = -1 };
115 113
116 /// \name Manage instruction numbering. 114 /// \name Manage instruction numbering.
117 /// @{ 115 /// @{
118 InstNumberT newInstNumber() { return NextInstNumber++; } 116 InstNumberT newInstNumber() { return NextInstNumber++; }
119 InstNumberT getNextInstNumber() const { return NextInstNumber; } 117 InstNumberT getNextInstNumber() const { return NextInstNumber; }
120 /// @} 118 /// @}
121 119
122 /// \name Manage Variables. 120 /// \name Manage Variables.
123 /// @{ 121 /// @{
124 122
125 /// Create a new Variable with a particular type and an optional 123 /// Create a new Variable with a particular type and an optional name. The
126 /// name. The Node argument is the node where the variable is defined. 124 /// Node argument is the node where the variable is defined.
127 // TODO(jpp): untemplate this with separate methods: makeVariable, 125 // TODO(jpp): untemplate this with separate methods: makeVariable,
128 // makeSpillVariable, and makeStackVariable. 126 // makeSpillVariable, and makeStackVariable.
129 template <typename T = Variable> T *makeVariable(Type Ty) { 127 template <typename T = Variable> T *makeVariable(Type Ty) {
130 SizeT Index = Variables.size(); 128 SizeT Index = Variables.size();
131 T *Var = T::create(this, Ty, Index); 129 T *Var = T::create(this, Ty, Index);
132 Variables.push_back(Var); 130 Variables.push_back(Var);
133 return Var; 131 return Var;
134 } 132 }
135 SizeT getNumVariables() const { return Variables.size(); } 133 SizeT getNumVariables() const { return Variables.size(); }
136 const VarList &getVariables() const { return Variables; } 134 const VarList &getVariables() const { return Variables; }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 void setFocusedTiming() { FocusedTiming = true; } 167 void setFocusedTiming() { FocusedTiming = true; }
170 uint32_t getConstantBlindingCookie() const { return ConstantBlindingCookie; } 168 uint32_t getConstantBlindingCookie() const { return ConstantBlindingCookie; }
171 /// @} 169 /// @}
172 170
173 /// Returns true if Var is a global variable that is used by the profiling 171 /// Returns true if Var is a global variable that is used by the profiling
174 /// code. 172 /// code.
175 static bool isProfileGlobal(const VariableDeclaration &Var); 173 static bool isProfileGlobal(const VariableDeclaration &Var);
176 174
177 /// Passes over the CFG. 175 /// Passes over the CFG.
178 void translate(); 176 void translate();
179 /// After the CFG is fully constructed, iterate over the nodes and 177 /// After the CFG is fully constructed, iterate over the nodes and compute the
180 /// compute the predecessor and successor edges, in the form of 178 /// predecessor and successor edges, in the form of CfgNode::InEdges[] and
181 /// CfgNode::InEdges[] and CfgNode::OutEdges[]. 179 /// CfgNode::OutEdges[].
182 void computeInOutEdges(); 180 void computeInOutEdges();
183 void renumberInstructions(); 181 void renumberInstructions();
184 void placePhiLoads(); 182 void placePhiLoads();
185 void placePhiStores(); 183 void placePhiStores();
186 void deletePhis(); 184 void deletePhis();
187 void advancedPhiLowering(); 185 void advancedPhiLowering();
188 void reorderNodes(); 186 void reorderNodes();
189 void shuffleNodes(); 187 void shuffleNodes();
190 void doAddressOpt(); 188 void doAddressOpt();
191 void doArgLowering(); 189 void doArgLowering();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 VarList ImplicitArgs; /// subset of Variables 268 VarList ImplicitArgs; /// subset of Variables
271 std::unique_ptr<ArenaAllocator<>> Allocator; 269 std::unique_ptr<ArenaAllocator<>> Allocator;
272 std::unique_ptr<Liveness> Live; 270 std::unique_ptr<Liveness> Live;
273 std::unique_ptr<TargetLowering> Target; 271 std::unique_ptr<TargetLowering> Target;
274 std::unique_ptr<VariablesMetadata> VMetadata; 272 std::unique_ptr<VariablesMetadata> VMetadata;
275 std::unique_ptr<Assembler> TargetAssembler; 273 std::unique_ptr<Assembler> TargetAssembler;
276 /// Globals required by this CFG. Mostly used for the profiler's globals. 274 /// Globals required by this CFG. Mostly used for the profiler's globals.
277 std::unique_ptr<VariableDeclarationList> GlobalInits; 275 std::unique_ptr<VariableDeclarationList> GlobalInits;
278 std::vector<InstJumpTable *> JumpTables; 276 std::vector<InstJumpTable *> JumpTables;
279 277
280 /// CurrentNode is maintained during dumping/emitting just for 278 /// CurrentNode is maintained during dumping/emitting just for validating
281 /// validating Variable::DefNode. Normally, a traversal over 279 /// Variable::DefNode. Normally, a traversal over CfgNodes maintains this, but
282 /// CfgNodes maintains this, but before global operations like 280 /// before global operations like register allocation, resetCurrentNode()
283 /// register allocation, resetCurrentNode() should be called to avoid 281 /// should be called to avoid spurious validation failures.
284 /// spurious validation failures.
285 const CfgNode *CurrentNode = nullptr; 282 const CfgNode *CurrentNode = nullptr;
286 283
287 /// Maintain a pointer in TLS to the current Cfg being translated. 284 /// Maintain a pointer in TLS to the current Cfg being translated. This is
288 /// This is primarily for accessing its allocator statelessly, but 285 /// primarily for accessing its allocator statelessly, but other uses are
289 /// other uses are possible. 286 /// possible.
290 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); 287 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg);
291 288
292 public: 289 public:
293 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } 290 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); }
294 }; 291 };
295 292
296 } // end of namespace Ice 293 } // end of namespace Ice
297 294
298 #endif // SUBZERO_SRC_ICECFG_H 295 #endif // SUBZERO_SRC_ICECFG_H
OLDNEW
« no previous file with comments | « src/IceBrowserCompileServer.cpp ('k') | src/IceCfg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698