| 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 /// \file | 10 /// \file |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 Cfg(const Cfg &) = delete; | 29 Cfg(const Cfg &) = delete; |
| 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 static std::unique_ptr<Cfg> create(GlobalContext *Ctx, | 35 static std::unique_ptr<Cfg> create(GlobalContext *Ctx, |
| 36 uint32_t SequenceNumber) { | 36 uint32_t SequenceNumber) { |
| 37 return std::unique_ptr<Cfg>(new Cfg(Ctx, SequenceNumber)); | 37 return std::unique_ptr<Cfg>(new Cfg(Ctx, SequenceNumber)); |
| 38 } | 38 } |
| 39 /// Gets a pointer to the current thread's Cfg. | |
| 40 static const Cfg *getCurrentCfg() { return ICE_TLS_GET_FIELD(CurrentCfg); } | |
| 41 static void setCurrentCfg(const Cfg *Func) { | |
| 42 ICE_TLS_SET_FIELD(CurrentCfg, Func); | |
| 43 } | |
| 44 /// Gets a pointer to the current thread's Cfg's allocator. | |
| 45 static ArenaAllocator<> *getCurrentCfgAllocator() { | |
| 46 assert(ICE_TLS_GET_FIELD(CurrentCfg)); | |
| 47 return ICE_TLS_GET_FIELD(CurrentCfg)->Allocator.get(); | |
| 48 } | |
| 49 | 39 |
| 50 GlobalContext *getContext() const { return Ctx; } | 40 GlobalContext *getContext() const { return Ctx; } |
| 51 uint32_t getSequenceNumber() const { return SequenceNumber; } | 41 uint32_t getSequenceNumber() const { return SequenceNumber; } |
| 52 | 42 |
| 53 static constexpr VerboseMask defaultVerboseMask() { | 43 static constexpr VerboseMask defaultVerboseMask() { |
| 54 return IceV_All & ~IceV_Status & ~IceV_AvailableRegs; | 44 return IceV_All & ~IceV_Status & ~IceV_AvailableRegs; |
| 55 } | 45 } |
| 56 /// Returns true if any of the specified options in the verbose mask are set. | 46 /// Returns true if any of the specified options in the verbose mask are set. |
| 57 /// If the argument is omitted, it checks if any verbose options at all are | 47 /// If the argument is omitted, it checks if any verbose options at all are |
| 58 /// set. | 48 /// set. |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 template <typename T> void deallocate(T *Object) { | 237 template <typename T> void deallocate(T *Object) { |
| 248 Allocator->Deallocate(Object); | 238 Allocator->Deallocate(Object); |
| 249 } | 239 } |
| 250 | 240 |
| 251 /// Deallocate data that was allocated via allocateArrayOf<T>(). | 241 /// Deallocate data that was allocated via allocateArrayOf<T>(). |
| 252 template <typename T> void deallocateArrayOf(T *Array) { | 242 template <typename T> void deallocateArrayOf(T *Array) { |
| 253 Allocator->Deallocate(Array); | 243 Allocator->Deallocate(Array); |
| 254 } | 244 } |
| 255 | 245 |
| 256 private: | 246 private: |
| 247 friend class CfgAllocatorTraits; // for Allocator access. |
| 248 |
| 257 Cfg(GlobalContext *Ctx, uint32_t SequenceNumber); | 249 Cfg(GlobalContext *Ctx, uint32_t SequenceNumber); |
| 258 | 250 |
| 259 /// Adds a call to the ProfileSummary runtime function as the first | 251 /// Adds a call to the ProfileSummary runtime function as the first |
| 260 /// instruction in this CFG's entry block. | 252 /// instruction in this CFG's entry block. |
| 261 void addCallToProfileSummary(); | 253 void addCallToProfileSummary(); |
| 262 | 254 |
| 263 /// Iterates over the basic blocks in this CFG, adding profiling code to each | 255 /// Iterates over the basic blocks in this CFG, adding profiling code to each |
| 264 /// one of them. It returns a list with all the globals that the profiling | 256 /// one of them. It returns a list with all the globals that the profiling |
| 265 /// code needs to be defined. | 257 /// code needs to be defined. |
| 266 void profileBlocks(); | 258 void profileBlocks(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 291 bool HasError = false; | 283 bool HasError = false; |
| 292 bool FocusedTiming = false; | 284 bool FocusedTiming = false; |
| 293 IceString ErrorMessage = ""; | 285 IceString ErrorMessage = ""; |
| 294 CfgNode *Entry = nullptr; /// entry basic block | 286 CfgNode *Entry = nullptr; /// entry basic block |
| 295 NodeList Nodes; /// linearized node list; Entry should be first | 287 NodeList Nodes; /// linearized node list; Entry should be first |
| 296 std::vector<IceString> IdentifierNames; | 288 std::vector<IceString> IdentifierNames; |
| 297 InstNumberT NextInstNumber; | 289 InstNumberT NextInstNumber; |
| 298 VarList Variables; | 290 VarList Variables; |
| 299 VarList Args; /// subset of Variables, in argument order | 291 VarList Args; /// subset of Variables, in argument order |
| 300 VarList ImplicitArgs; /// subset of Variables | 292 VarList ImplicitArgs; /// subset of Variables |
| 301 std::unique_ptr<ArenaAllocator<>> Allocator; | 293 std::unique_ptr<ArenaAllocator> Allocator; |
| 302 std::unique_ptr<Liveness> Live; | 294 std::unique_ptr<Liveness> Live; |
| 303 std::unique_ptr<TargetLowering> Target; | 295 std::unique_ptr<TargetLowering> Target; |
| 304 std::unique_ptr<VariablesMetadata> VMetadata; | 296 std::unique_ptr<VariablesMetadata> VMetadata; |
| 305 std::unique_ptr<Assembler> TargetAssembler; | 297 std::unique_ptr<Assembler> TargetAssembler; |
| 306 /// Globals required by this CFG. Mostly used for the profiler's globals. | 298 /// Globals required by this CFG. Mostly used for the profiler's globals. |
| 307 std::unique_ptr<VariableDeclarationList> GlobalInits; | 299 std::unique_ptr<VariableDeclarationList> GlobalInits; |
| 308 CfgVector<InstJumpTable *> JumpTables; | 300 CfgVector<InstJumpTable *> JumpTables; |
| 309 | 301 |
| 310 /// CurrentNode is maintained during dumping/emitting just for validating | 302 /// CurrentNode is maintained during dumping/emitting just for validating |
| 311 /// Variable::DefNode. Normally, a traversal over CfgNodes maintains this, but | 303 /// Variable::DefNode. Normally, a traversal over CfgNodes maintains this, but |
| 312 /// before global operations like register allocation, resetCurrentNode() | 304 /// before global operations like register allocation, resetCurrentNode() |
| 313 /// should be called to avoid spurious validation failures. | 305 /// should be called to avoid spurious validation failures. |
| 314 const CfgNode *CurrentNode = nullptr; | 306 const CfgNode *CurrentNode = nullptr; |
| 315 | 307 |
| 316 /// Maintain a pointer in TLS to the current Cfg being translated. This is | |
| 317 /// primarily for accessing its allocator statelessly, but other uses are | |
| 318 /// possible. | |
| 319 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); | |
| 320 | |
| 321 public: | 308 public: |
| 322 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } | 309 static void TlsInit() { CfgAllocatorTraits::init(); } |
| 323 }; | 310 }; |
| 324 | 311 |
| 325 template <> Variable *Cfg::makeVariable<Variable>(Type Ty); | 312 template <> Variable *Cfg::makeVariable<Variable>(Type Ty); |
| 326 | 313 |
| 327 } // end of namespace Ice | 314 } // end of namespace Ice |
| 328 | 315 |
| 329 #endif // SUBZERO_SRC_ICECFG_H | 316 #endif // SUBZERO_SRC_ICECFG_H |
| OLD | NEW |