| 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() { return ICE_TLS_GET_FIELD(CurrentCfg); } |
| 45 // Gets a pointer to the current thread's Cfg's allocator. | 45 // Gets a pointer to the current thread's Cfg's allocator. |
| 46 static ArenaAllocator<> *getCurrentCfgAllocator() { | 46 static ArenaAllocator<> *getCurrentCfgAllocator() { |
| 47 assert(CurrentCfg); | 47 assert(ICE_TLS_GET_FIELD(CurrentCfg)); |
| 48 return CurrentCfg->Allocator.get(); | 48 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 GlobalContext *getContext() const { return Ctx; } | 51 GlobalContext *getContext() const { return Ctx; } |
| 52 | 52 |
| 53 // Manage the name and return type of the function being translated. | 53 // Manage the name and return type of the function being translated. |
| 54 void setFunctionName(const IceString &Name) { FunctionName = Name; } | 54 void setFunctionName(const IceString &Name) { FunctionName = Name; } |
| 55 IceString getFunctionName() const { return FunctionName; } | 55 IceString getFunctionName() const { return FunctionName; } |
| 56 void setReturnType(Type Ty) { ReturnType = Ty; } | 56 void setReturnType(Type Ty) { ReturnType = Ty; } |
| 57 | 57 |
| 58 // Manage the "internal" attribute of the function. | 58 // 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 | 206 // CurrentNode is maintained during dumping/emitting just for |
| 207 // validating Variable::DefNode. Normally, a traversal over | 207 // validating Variable::DefNode. Normally, a traversal over |
| 208 // CfgNodes maintains this, but before global operations like | 208 // CfgNodes maintains this, but before global operations like |
| 209 // register allocation, resetCurrentNode() should be called to avoid | 209 // register allocation, resetCurrentNode() should be called to avoid |
| 210 // spurious validation failures. | 210 // spurious validation failures. |
| 211 const CfgNode *CurrentNode; | 211 const CfgNode *CurrentNode; |
| 212 | 212 |
| 213 // Maintain a pointer in TLS to the current Cfg being translated. | 213 // Maintain a pointer in TLS to the current Cfg being translated. |
| 214 // This is primarily for accessing its allocator statelessly, but | 214 // This is primarily for accessing its allocator statelessly, but |
| 215 // other uses are possible. | 215 // other uses are possible. |
| 216 ICE_ATTRIBUTE_TLS static const Cfg *CurrentCfg; | 216 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); |
| 217 |
| 218 public: |
| 219 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } |
| 217 }; | 220 }; |
| 218 | 221 |
| 219 } // end of namespace Ice | 222 } // end of namespace Ice |
| 220 | 223 |
| 221 #endif // SUBZERO_SRC_ICECFG_H | 224 #endif // SUBZERO_SRC_ICECFG_H |
| OLD | NEW |