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

Side by Side Diff: src/IceCfg.h

Issue 916653004: Subzero: Emit functions and global initializers in a separate thread. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Const change Created 5 years, 10 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 | « pydir/run-llvm2ice.py ('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 // This file declares the Cfg class, which represents the control flow 10 // This file declares the Cfg class, which represents the control flow
(...skipping 12 matching lines...) Expand all
23 23
24 namespace Ice { 24 namespace Ice {
25 25
26 class Cfg { 26 class Cfg {
27 Cfg(const Cfg &) = delete; 27 Cfg(const Cfg &) = delete;
28 Cfg &operator=(const Cfg &) = delete; 28 Cfg &operator=(const Cfg &) = delete;
29 29
30 public: 30 public:
31 ~Cfg(); 31 ~Cfg();
32 32
33 static std::unique_ptr<Cfg> create(GlobalContext *Ctx) { 33 static std::unique_ptr<Cfg> create(GlobalContext *Ctx,
34 return std::unique_ptr<Cfg>(new Cfg(Ctx)); 34 uint32_t SequenceNumber) {
35 return std::unique_ptr<Cfg>(new Cfg(Ctx, SequenceNumber));
35 } 36 }
36 // Gets a pointer to the current thread's Cfg. 37 // Gets a pointer to the current thread's Cfg.
37 static const Cfg *getCurrentCfg() { return ICE_TLS_GET_FIELD(CurrentCfg); } 38 static const Cfg *getCurrentCfg() { return ICE_TLS_GET_FIELD(CurrentCfg); }
38 static void setCurrentCfg(const Cfg *Func) { 39 static void setCurrentCfg(const Cfg *Func) {
39 ICE_TLS_SET_FIELD(CurrentCfg, Func); 40 ICE_TLS_SET_FIELD(CurrentCfg, Func);
40 } 41 }
41 // Gets a pointer to the current thread's Cfg's allocator. 42 // Gets a pointer to the current thread's Cfg's allocator.
42 static ArenaAllocator<> *getCurrentCfgAllocator() { 43 static ArenaAllocator<> *getCurrentCfgAllocator() {
43 assert(ICE_TLS_GET_FIELD(CurrentCfg)); 44 assert(ICE_TLS_GET_FIELD(CurrentCfg));
44 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get(); 45 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get();
45 } 46 }
46 47
47 GlobalContext *getContext() const { return Ctx; } 48 GlobalContext *getContext() const { return Ctx; }
49 uint32_t getSequenceNumber() const { return SequenceNumber; }
48 50
49 // Returns true if any of the specified options in the verbose mask 51 // Returns true if any of the specified options in the verbose mask
50 // are set. If the argument is omitted, it checks if any verbose 52 // are set. If the argument is omitted, it checks if any verbose
51 // options at all are set. 53 // options at all are set.
52 bool isVerbose(VerboseMask Mask = IceV_All) const { return VMask & Mask; } 54 bool isVerbose(VerboseMask Mask = IceV_All) const { return VMask & Mask; }
53 void setVerbose(VerboseMask Mask) { VMask = Mask; } 55 void setVerbose(VerboseMask Mask) { VMask = Mask; }
54 56
55 // Manage the name and return type of the function being translated. 57 // Manage the name and return type of the function being translated.
56 void setFunctionName(const IceString &Name) { FunctionName = Name; } 58 void setFunctionName(const IceString &Name) { FunctionName = Name; }
57 IceString getFunctionName() const { return FunctionName; } 59 IceString getFunctionName() const { return FunctionName; }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 void addArg(Variable *Arg); 116 void addArg(Variable *Arg);
115 const VarList &getArgs() const { return Args; } 117 const VarList &getArgs() const { return Args; }
116 VarList &getArgs() { return Args; } 118 VarList &getArgs() { return Args; }
117 void addImplicitArg(Variable *Arg); 119 void addImplicitArg(Variable *Arg);
118 const VarList &getImplicitArgs() const { return ImplicitArgs; } 120 const VarList &getImplicitArgs() const { return ImplicitArgs; }
119 121
120 // Miscellaneous accessors. 122 // Miscellaneous accessors.
121 TargetLowering *getTarget() const { return Target.get(); } 123 TargetLowering *getTarget() const { return Target.get(); }
122 VariablesMetadata *getVMetadata() const { return VMetadata.get(); } 124 VariablesMetadata *getVMetadata() const { return VMetadata.get(); }
123 Liveness *getLiveness() const { return Live.get(); } 125 Liveness *getLiveness() const { return Live.get(); }
124 template <typename T> T *getAssembler() const { 126 template <typename T = Assembler> T *getAssembler() const {
125 return static_cast<T *>(TargetAssembler.get()); 127 return static_cast<T *>(TargetAssembler.get());
126 } 128 }
129 Assembler *releaseAssembler() { return TargetAssembler.release(); }
127 bool hasComputedFrame() const; 130 bool hasComputedFrame() const;
128 bool getFocusedTiming() const { return FocusedTiming; } 131 bool getFocusedTiming() const { return FocusedTiming; }
129 void setFocusedTiming() { FocusedTiming = true; } 132 void setFocusedTiming() { FocusedTiming = true; }
130 133
131 // Passes over the CFG. 134 // Passes over the CFG.
132 void translate(); 135 void translate();
133 // After the CFG is fully constructed, iterate over the nodes and 136 // After the CFG is fully constructed, iterate over the nodes and
134 // compute the predecessor edges, in the form of 137 // compute the predecessor edges, in the form of
135 // CfgNode::InEdges[]. 138 // CfgNode::InEdges[].
136 void computePredecessors(); 139 void computePredecessors();
(...skipping 15 matching lines...) Expand all
152 void doBranchOpt(); 155 void doBranchOpt();
153 156
154 // Manage the CurrentNode field, which is used for validating the 157 // Manage the CurrentNode field, which is used for validating the
155 // Variable::DefNode field during dumping/emitting. 158 // Variable::DefNode field during dumping/emitting.
156 void setCurrentNode(const CfgNode *Node) { CurrentNode = Node; } 159 void setCurrentNode(const CfgNode *Node) { CurrentNode = Node; }
157 void resetCurrentNode() { setCurrentNode(nullptr); } 160 void resetCurrentNode() { setCurrentNode(nullptr); }
158 const CfgNode *getCurrentNode() const { return CurrentNode; } 161 const CfgNode *getCurrentNode() const { return CurrentNode; }
159 162
160 void emit(); 163 void emit();
161 void emitIAS(); 164 void emitIAS();
162 void emitTextHeader(const IceString &MangledName); 165 static void emitTextHeader(const IceString &MangledName, GlobalContext *Ctx,
166 const Assembler *Asm);
163 void dump(const IceString &Message = ""); 167 void dump(const IceString &Message = "");
164 168
165 // Allocate data of type T using the per-Cfg allocator. 169 // Allocate data of type T using the per-Cfg allocator.
166 template <typename T> T *allocate() { return Allocator->Allocate<T>(); } 170 template <typename T> T *allocate() { return Allocator->Allocate<T>(); }
167 171
168 // Allocate an array of data of type T using the per-Cfg allocator. 172 // Allocate an array of data of type T using the per-Cfg allocator.
169 template <typename T> T *allocateArrayOf(size_t NumElems) { 173 template <typename T> T *allocateArrayOf(size_t NumElems) {
170 return Allocator->Allocate<T>(NumElems); 174 return Allocator->Allocate<T>(NumElems);
171 } 175 }
172 176
173 // Deallocate data that was allocated via allocate<T>(). 177 // Deallocate data that was allocated via allocate<T>().
174 template <typename T> void deallocate(T *Object) { 178 template <typename T> void deallocate(T *Object) {
175 Allocator->Deallocate(Object); 179 Allocator->Deallocate(Object);
176 } 180 }
177 181
178 // Deallocate data that was allocated via allocateArrayOf<T>(). 182 // Deallocate data that was allocated via allocateArrayOf<T>().
179 template <typename T> void deallocateArrayOf(T *Array) { 183 template <typename T> void deallocateArrayOf(T *Array) {
180 Allocator->Deallocate(Array); 184 Allocator->Deallocate(Array);
181 } 185 }
182 186
183 private: 187 private:
184 Cfg(GlobalContext *Ctx); 188 Cfg(GlobalContext *Ctx, uint32_t SequenceNumber);
185 189
186 GlobalContext *Ctx; 190 GlobalContext *Ctx;
191 uint32_t SequenceNumber; // output order for emission
187 VerboseMask VMask; 192 VerboseMask VMask;
188 IceString FunctionName; 193 IceString FunctionName;
189 Type ReturnType; 194 Type ReturnType;
190 bool IsInternalLinkage; 195 bool IsInternalLinkage;
191 bool HasError; 196 bool HasError;
192 bool FocusedTiming; 197 bool FocusedTiming;
193 IceString ErrorMessage; 198 IceString ErrorMessage;
194 CfgNode *Entry; // entry basic block 199 CfgNode *Entry; // entry basic block
195 NodeList Nodes; // linearized node list; Entry should be first 200 NodeList Nodes; // linearized node list; Entry should be first
196 std::vector<IceString> IdentifierNames; 201 std::vector<IceString> IdentifierNames;
(...skipping 19 matching lines...) Expand all
216 // other uses are possible. 221 // other uses are possible.
217 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); 222 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg);
218 223
219 public: 224 public:
220 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } 225 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); }
221 }; 226 };
222 227
223 } // end of namespace Ice 228 } // end of namespace Ice
224 229
225 #endif // SUBZERO_SRC_ICECFG_H 230 #endif // SUBZERO_SRC_ICECFG_H
OLDNEW
« no previous file with comments | « pydir/run-llvm2ice.py ('k') | src/IceCfg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698