OLD | NEW |
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 19 matching lines...) Expand all Loading... |
30 Cfg &operator=(const Cfg &) = delete; | 30 Cfg &operator=(const Cfg &) = delete; |
31 | 31 |
32 public: | 32 public: |
33 ~Cfg(); | 33 ~Cfg(); |
34 | 34 |
35 // TODO(stichnot): Change this to return unique_ptr<Cfg>, and plumb | 35 // TODO(stichnot): Change this to return unique_ptr<Cfg>, and plumb |
36 // it through the callers, to make ownership and lifetime and | 36 // it through the callers, to make ownership and lifetime and |
37 // destruction requirements more explicit. | 37 // destruction requirements more explicit. |
38 static Cfg *create(GlobalContext *Ctx) { | 38 static Cfg *create(GlobalContext *Ctx) { |
39 Cfg *Func = new Cfg(Ctx); | 39 Cfg *Func = new Cfg(Ctx); |
40 CurrentCfg = Func; | 40 ICE_TLS_SET_FIELD(CurrentCfg, Func); |
41 return Func; | 41 return Func; |
42 } | 42 } |
43 // Gets a pointer to the current thread's Cfg. | 43 // Gets a pointer to the current thread's Cfg. |
44 static const Cfg *getCurrentCfg() { return CurrentCfg; } | 44 static const Cfg *getCurrentCfg() { |
| 45 return ICE_TLS_GET_FIELD(CurrentCfg, const Cfg *); |
| 46 } |
45 // Gets a pointer to the current thread's Cfg's allocator. | 47 // Gets a pointer to the current thread's Cfg's allocator. |
46 static ArenaAllocator<> *getCurrentCfgAllocator() { | 48 static ArenaAllocator<> *getCurrentCfgAllocator() { |
47 assert(CurrentCfg); | 49 assert(ICE_TLS_GET_FIELD(CurrentCfg, const Cfg *)); |
48 return CurrentCfg->Allocator.get(); | 50 return ICE_TLS_GET_FIELD(CurrentCfg, const Cfg *)->Allocator.get(); |
49 } | 51 } |
50 | 52 |
51 GlobalContext *getContext() const { return Ctx; } | 53 GlobalContext *getContext() const { return Ctx; } |
52 | 54 |
53 // Manage the name and return type of the function being translated. | 55 // Manage the name and return type of the function being translated. |
54 void setFunctionName(const IceString &Name) { FunctionName = Name; } | 56 void setFunctionName(const IceString &Name) { FunctionName = Name; } |
55 IceString getFunctionName() const { return FunctionName; } | 57 IceString getFunctionName() const { return FunctionName; } |
56 void setReturnType(Type Ty) { ReturnType = Ty; } | 58 void setReturnType(Type Ty) { ReturnType = Ty; } |
57 | 59 |
58 // Manage the "internal" attribute of the function. | 60 // Manage the "internal" attribute of the function. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // CurrentNode is maintained during dumping/emitting just for | 208 // CurrentNode is maintained during dumping/emitting just for |
207 // validating Variable::DefNode. Normally, a traversal over | 209 // validating Variable::DefNode. Normally, a traversal over |
208 // CfgNodes maintains this, but before global operations like | 210 // CfgNodes maintains this, but before global operations like |
209 // register allocation, resetCurrentNode() should be called to avoid | 211 // register allocation, resetCurrentNode() should be called to avoid |
210 // spurious validation failures. | 212 // spurious validation failures. |
211 const CfgNode *CurrentNode; | 213 const CfgNode *CurrentNode; |
212 | 214 |
213 // Maintain a pointer in TLS to the current Cfg being translated. | 215 // Maintain a pointer in TLS to the current Cfg being translated. |
214 // This is primarily for accessing its allocator statelessly, but | 216 // This is primarily for accessing its allocator statelessly, but |
215 // other uses are possible. | 217 // other uses are possible. |
216 ICE_ATTRIBUTE_TLS static const Cfg *CurrentCfg; | 218 ICE_TLS_DECLARE_FIELD(CurrentCfg, const Cfg *); |
217 }; | 219 }; |
218 | 220 |
219 } // end of namespace Ice | 221 } // end of namespace Ice |
220 | 222 |
221 #endif // SUBZERO_SRC_ICECFG_H | 223 #endif // SUBZERO_SRC_ICECFG_H |
OLD | NEW |