| 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 12 matching lines...) Expand all Loading... |
| 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 // TODO(stichnot): Change this to return unique_ptr<Cfg>, and plumb | 33 static std::unique_ptr<Cfg> create(GlobalContext *Ctx) { |
| 34 // it through the callers, to make ownership and lifetime and | 34 return std::unique_ptr<Cfg>(new Cfg(Ctx)); |
| 35 // destruction requirements more explicit. | |
| 36 static Cfg *create(GlobalContext *Ctx) { | |
| 37 Cfg *Func = new Cfg(Ctx); | |
| 38 ICE_TLS_SET_FIELD(CurrentCfg, Func); | |
| 39 return Func; | |
| 40 } | 35 } |
| 41 // Gets a pointer to the current thread's Cfg. | 36 // Gets a pointer to the current thread's Cfg. |
| 42 static const Cfg *getCurrentCfg() { return ICE_TLS_GET_FIELD(CurrentCfg); } | 37 static const Cfg *getCurrentCfg() { return ICE_TLS_GET_FIELD(CurrentCfg); } |
| 43 void updateTLS() const { ICE_TLS_SET_FIELD(CurrentCfg, this); } | 38 static void setCurrentCfg(const Cfg *Func) { |
| 39 ICE_TLS_SET_FIELD(CurrentCfg, Func); |
| 40 } |
| 44 // Gets a pointer to the current thread's Cfg's allocator. | 41 // Gets a pointer to the current thread's Cfg's allocator. |
| 45 static ArenaAllocator<> *getCurrentCfgAllocator() { | 42 static ArenaAllocator<> *getCurrentCfgAllocator() { |
| 46 assert(ICE_TLS_GET_FIELD(CurrentCfg)); | 43 assert(ICE_TLS_GET_FIELD(CurrentCfg)); |
| 47 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get(); | 44 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get(); |
| 48 } | 45 } |
| 49 | 46 |
| 50 GlobalContext *getContext() const { return Ctx; } | 47 GlobalContext *getContext() const { return Ctx; } |
| 51 | 48 |
| 52 // Returns true if any of the specified options in the verbose mask | 49 // 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 | 50 // are set. If the argument is omitted, it checks if any verbose |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // other uses are possible. | 216 // other uses are possible. |
| 220 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); | 217 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); |
| 221 | 218 |
| 222 public: | 219 public: |
| 223 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } | 220 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } |
| 224 }; | 221 }; |
| 225 | 222 |
| 226 } // end of namespace Ice | 223 } // end of namespace Ice |
| 227 | 224 |
| 228 #endif // SUBZERO_SRC_ICECFG_H | 225 #endif // SUBZERO_SRC_ICECFG_H |
| OLD | NEW |