Chromium Code Reviews| 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 | |
| 35 // destruction requirements more explicit. | |
| 36 static Cfg *create(GlobalContext *Ctx) { | |
| 37 Cfg *Func = new Cfg(Ctx); | 34 Cfg *Func = new Cfg(Ctx); |
|
JF
2015/02/02 20:59:19
It's slightly better to make this a unique_ptr too
Jim Stichnoth
2015/02/03 00:48:51
Done.
| |
| 38 ICE_TLS_SET_FIELD(CurrentCfg, Func); | 35 ICE_TLS_SET_FIELD(CurrentCfg, Func); |
| 39 return Func; | 36 return std::unique_ptr<Cfg>(Func); |
| 40 } | 37 } |
| 41 // Gets a pointer to the current thread's Cfg. | 38 // Gets a pointer to the current thread's Cfg. |
| 42 static const Cfg *getCurrentCfg() { return ICE_TLS_GET_FIELD(CurrentCfg); } | 39 static const Cfg *getCurrentCfg() { return ICE_TLS_GET_FIELD(CurrentCfg); } |
| 43 void updateTLS() const { ICE_TLS_SET_FIELD(CurrentCfg, this); } | 40 static void updateTLS(const Cfg *Func) { |
| 41 ICE_TLS_SET_FIELD(CurrentCfg, Func); | |
| 42 } | |
| 44 // Gets a pointer to the current thread's Cfg's allocator. | 43 // Gets a pointer to the current thread's Cfg's allocator. |
| 45 static ArenaAllocator<> *getCurrentCfgAllocator() { | 44 static ArenaAllocator<> *getCurrentCfgAllocator() { |
| 46 assert(ICE_TLS_GET_FIELD(CurrentCfg)); | 45 assert(ICE_TLS_GET_FIELD(CurrentCfg)); |
| 47 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get(); | 46 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get(); |
| 48 } | 47 } |
| 49 | 48 |
| 50 GlobalContext *getContext() const { return Ctx; } | 49 GlobalContext *getContext() const { return Ctx; } |
| 51 | 50 |
| 52 // 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 |
| 53 // 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 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 // other uses are possible. | 218 // other uses are possible. |
| 220 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); | 219 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); |
| 221 | 220 |
| 222 public: | 221 public: |
| 223 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } | 222 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } |
| 224 }; | 223 }; |
| 225 | 224 |
| 226 } // end of namespace Ice | 225 } // end of namespace Ice |
| 227 | 226 |
| 228 #endif // SUBZERO_SRC_ICECFG_H | 227 #endif // SUBZERO_SRC_ICECFG_H |
| OLD | NEW |