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

Side by Side Diff: src/IceCfg.h

Issue 870653002: Subzero: Initial implementation of multithreaded translation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase 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 | « Makefile.standalone ('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
11 // graph and the overall per-function compilation context. 11 // graph and the overall per-function compilation context.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #ifndef SUBZERO_SRC_ICECFG_H 15 #ifndef SUBZERO_SRC_ICECFG_H
16 #define SUBZERO_SRC_ICECFG_H 16 #define SUBZERO_SRC_ICECFG_H
17 17
18 #include <memory>
19
20 #include "assembler.h" 18 #include "assembler.h"
21 #include "IceClFlags.h" 19 #include "IceClFlags.h"
22 #include "IceDefs.h" 20 #include "IceDefs.h"
23 #include "IceGlobalContext.h" 21 #include "IceGlobalContext.h"
24 #include "IceTypes.h" 22 #include "IceTypes.h"
25 23
26 namespace Ice { 24 namespace Ice {
27 25
28 class Cfg { 26 class Cfg {
29 Cfg(const Cfg &) = delete; 27 Cfg(const Cfg &) = delete;
30 Cfg &operator=(const Cfg &) = delete; 28 Cfg &operator=(const Cfg &) = delete;
31 29
32 public: 30 public:
33 ~Cfg(); 31 ~Cfg();
34 32
35 // TODO(stichnot): Change this to return unique_ptr<Cfg>, and plumb 33 // TODO(stichnot): Change this to return unique_ptr<Cfg>, and plumb
36 // it through the callers, to make ownership and lifetime and 34 // it through the callers, to make ownership and lifetime and
37 // destruction requirements more explicit. 35 // destruction requirements more explicit.
38 static Cfg *create(GlobalContext *Ctx) { 36 static Cfg *create(GlobalContext *Ctx) {
39 Cfg *Func = new Cfg(Ctx); 37 Cfg *Func = new Cfg(Ctx);
40 ICE_TLS_SET_FIELD(CurrentCfg, Func); 38 ICE_TLS_SET_FIELD(CurrentCfg, Func);
41 return Func; 39 return Func;
42 } 40 }
43 // Gets a pointer to the current thread's Cfg. 41 // Gets a pointer to the current thread's Cfg.
44 static const Cfg *getCurrentCfg() { return ICE_TLS_GET_FIELD(CurrentCfg); } 42 static const Cfg *getCurrentCfg() { return ICE_TLS_GET_FIELD(CurrentCfg); }
43 void updateTLS() const { ICE_TLS_SET_FIELD(CurrentCfg, this); }
45 // Gets a pointer to the current thread's Cfg's allocator. 44 // Gets a pointer to the current thread's Cfg's allocator.
46 static ArenaAllocator<> *getCurrentCfgAllocator() { 45 static ArenaAllocator<> *getCurrentCfgAllocator() {
47 assert(ICE_TLS_GET_FIELD(CurrentCfg)); 46 assert(ICE_TLS_GET_FIELD(CurrentCfg));
48 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get(); 47 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get();
49 } 48 }
50 49
51 GlobalContext *getContext() const { return Ctx; } 50 GlobalContext *getContext() const { return Ctx; }
52 51
52 // Returns true if any of the specified options in the verbose mask
53 // are set. If the argument is omitted, it checks if any verbose
54 // options at all are set.
55 bool isVerbose(VerboseMask Mask = IceV_All) const { return VMask & Mask; }
56 void setVerbose(VerboseMask Mask) { VMask = Mask; }
57
53 // Manage the name and return type of the function being translated. 58 // Manage the name and return type of the function being translated.
54 void setFunctionName(const IceString &Name) { FunctionName = Name; } 59 void setFunctionName(const IceString &Name) { FunctionName = Name; }
55 IceString getFunctionName() const { return FunctionName; } 60 IceString getFunctionName() const { return FunctionName; }
56 void setReturnType(Type Ty) { ReturnType = Ty; } 61 void setReturnType(Type Ty) { ReturnType = Ty; }
57 62
58 // Manage the "internal" attribute of the function. 63 // Manage the "internal" attribute of the function.
59 void setInternal(bool Internal) { IsInternalLinkage = Internal; } 64 void setInternal(bool Internal) { IsInternalLinkage = Internal; }
60 bool getInternal() const { return IsInternalLinkage; } 65 bool getInternal() const { return IsInternalLinkage; }
61 66
62 // Translation error flagging. If support for some construct is 67 // Translation error flagging. If support for some construct is
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 182
178 // Deallocate data that was allocated via allocateArrayOf<T>(). 183 // Deallocate data that was allocated via allocateArrayOf<T>().
179 template <typename T> void deallocateArrayOf(T *Array) { 184 template <typename T> void deallocateArrayOf(T *Array) {
180 Allocator->Deallocate(Array); 185 Allocator->Deallocate(Array);
181 } 186 }
182 187
183 private: 188 private:
184 Cfg(GlobalContext *Ctx); 189 Cfg(GlobalContext *Ctx);
185 190
186 GlobalContext *Ctx; 191 GlobalContext *Ctx;
192 VerboseMask VMask;
187 IceString FunctionName; 193 IceString FunctionName;
188 Type ReturnType; 194 Type ReturnType;
189 bool IsInternalLinkage; 195 bool IsInternalLinkage;
190 bool HasError; 196 bool HasError;
191 bool FocusedTiming; 197 bool FocusedTiming;
192 IceString ErrorMessage; 198 IceString ErrorMessage;
193 CfgNode *Entry; // entry basic block 199 CfgNode *Entry; // entry basic block
194 NodeList Nodes; // linearized node list; Entry should be first 200 NodeList Nodes; // linearized node list; Entry should be first
195 std::vector<IceString> IdentifierNames; 201 std::vector<IceString> IdentifierNames;
196 InstNumberT NextInstNumber; 202 InstNumberT NextInstNumber;
(...skipping 18 matching lines...) Expand all
215 // other uses are possible. 221 // other uses are possible.
216 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); 222 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg);
217 223
218 public: 224 public:
219 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } 225 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); }
220 }; 226 };
221 227
222 } // end of namespace Ice 228 } // end of namespace Ice
223 229
224 #endif // SUBZERO_SRC_ICECFG_H 230 #endif // SUBZERO_SRC_ICECFG_H
OLDNEW
« no previous file with comments | « Makefile.standalone ('k') | src/IceCfg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698