| OLD | NEW |
| 1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===// | 1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 template <typename T> | 236 template <typename T> |
| 237 typename std::enable_if<!std::is_trivially_destructible<T>::value, T>::type * | 237 typename std::enable_if<!std::is_trivially_destructible<T>::value, T>::type * |
| 238 allocate() { | 238 allocate() { |
| 239 T *Ret = getAllocator()->Allocate<T>(); | 239 T *Ret = getAllocator()->Allocate<T>(); |
| 240 getDestructors()->emplace_back([Ret]() { Ret->~T(); }); | 240 getDestructors()->emplace_back([Ret]() { Ret->~T(); }); |
| 241 return Ret; | 241 return Ret; |
| 242 } | 242 } |
| 243 | 243 |
| 244 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } | 244 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } |
| 245 | 245 |
| 246 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded | |
| 247 // translation. | |
| 248 RandomNumberGenerator &getRNG() { return RNG; } | |
| 249 | |
| 250 ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); } | 246 ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); } |
| 251 | 247 |
| 252 /// Reset stats at the beginning of a function. | 248 /// Reset stats at the beginning of a function. |
| 253 void resetStats() { | 249 void resetStats() { |
| 254 if (BuildDefs::dump()) | 250 if (BuildDefs::dump()) |
| 255 ICE_TLS_GET_FIELD(TLS)->StatsFunction.reset(); | 251 ICE_TLS_GET_FIELD(TLS)->StatsFunction.reset(); |
| 256 } | 252 } |
| 257 void dumpStats(const IceString &Name, bool Final = false); | 253 void dumpStats(const IceString &Name, bool Final = false); |
| 258 void statsUpdateEmitted(uint32_t InstCount) { | 254 void statsUpdateEmitted(uint32_t InstCount) { |
| 259 if (!getFlags().getDumpStats()) | 255 if (!getFlags().getDumpStats()) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 /// This is used in a few cases where we want to take some action on | 429 /// This is used in a few cases where we want to take some action on |
| 434 /// a particular function or symbol based on a command-line argument, | 430 /// a particular function or symbol based on a command-line argument, |
| 435 /// such as changing the verbose level for a particular function. An | 431 /// such as changing the verbose level for a particular function. An |
| 436 /// empty Match argument means match everything. Returns true if | 432 /// empty Match argument means match everything. Returns true if |
| 437 /// there is a match. | 433 /// there is a match. |
| 438 static bool matchSymbolName(const IceString &SymbolName, | 434 static bool matchSymbolName(const IceString &SymbolName, |
| 439 const IceString &Match) { | 435 const IceString &Match) { |
| 440 return Match.empty() || Match == SymbolName; | 436 return Match.empty() || Match == SymbolName; |
| 441 } | 437 } |
| 442 | 438 |
| 443 /// Return the randomization cookie for diversification. | |
| 444 /// Initialize the cookie if necessary | |
| 445 uint32_t getRandomizationCookie() const { return RandomizationCookie; } | |
| 446 | |
| 447 private: | 439 private: |
| 448 // Try to ensure mutexes are allocated on separate cache lines. | 440 // Try to ensure mutexes are allocated on separate cache lines. |
| 449 | 441 |
| 450 // Destructors collaborate with Allocator | 442 // Destructors collaborate with Allocator |
| 451 ICE_CACHELINE_BOUNDARY; | 443 ICE_CACHELINE_BOUNDARY; |
| 452 // Managed by getAllocator() | 444 // Managed by getAllocator() |
| 453 GlobalLockType AllocLock; | 445 GlobalLockType AllocLock; |
| 454 ArenaAllocator<> Allocator; | 446 ArenaAllocator<> Allocator; |
| 455 | 447 |
| 456 ICE_CACHELINE_BOUNDARY; | 448 ICE_CACHELINE_BOUNDARY; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 typedef std::mutex StrLockType; | 481 typedef std::mutex StrLockType; |
| 490 StrLockType StrLock; | 482 StrLockType StrLock; |
| 491 Ostream *StrDump; /// Stream for dumping / diagnostics | 483 Ostream *StrDump; /// Stream for dumping / diagnostics |
| 492 Ostream *StrEmit; /// Stream for code emission | 484 Ostream *StrEmit; /// Stream for code emission |
| 493 Ostream *StrError; /// Stream for logging errors. | 485 Ostream *StrError; /// Stream for logging errors. |
| 494 | 486 |
| 495 ICE_CACHELINE_BOUNDARY; | 487 ICE_CACHELINE_BOUNDARY; |
| 496 | 488 |
| 497 Intrinsics IntrinsicsInfo; | 489 Intrinsics IntrinsicsInfo; |
| 498 const ClFlags &Flags; | 490 const ClFlags &Flags; |
| 499 RandomNumberGenerator RNG; // TODO(stichnot): Move into Cfg. | |
| 500 // TODO(jpp): move to EmitterContext. | 491 // TODO(jpp): move to EmitterContext. |
| 501 std::unique_ptr<ELFObjectWriter> ObjectWriter; | 492 std::unique_ptr<ELFObjectWriter> ObjectWriter; |
| 502 BoundedProducerConsumerQueue<Cfg> OptQ; | 493 BoundedProducerConsumerQueue<Cfg> OptQ; |
| 503 BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ; | 494 BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ; |
| 504 // DataLowering is only ever used by a single thread at a time (either in | 495 // DataLowering is only ever used by a single thread at a time (either in |
| 505 // emitItems(), or in IceCompiler::run before the compilation is over.) | 496 // emitItems(), or in IceCompiler::run before the compilation is over.) |
| 506 // TODO(jpp): move to EmitterContext. | 497 // TODO(jpp): move to EmitterContext. |
| 507 std::unique_ptr<TargetDataLowering> DataLowering; | 498 std::unique_ptr<TargetDataLowering> DataLowering; |
| 508 /// If !HasEmittedCode, SubZero will accumulate all Globals (which are "true" | 499 /// If !HasEmittedCode, SubZero will accumulate all Globals (which are "true" |
| 509 /// program global variables) until the first code WorkItem is seen. | 500 /// program global variables) until the first code WorkItem is seen. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 llvm::SmallVector<std::thread, 128> TranslationThreads; | 541 llvm::SmallVector<std::thread, 128> TranslationThreads; |
| 551 llvm::SmallVector<std::thread, 128> EmitterThreads; | 542 llvm::SmallVector<std::thread, 128> EmitterThreads; |
| 552 // Each thread has its own TLS pointer which is also held in | 543 // Each thread has its own TLS pointer which is also held in |
| 553 // AllThreadContexts. | 544 // AllThreadContexts. |
| 554 ICE_TLS_DECLARE_FIELD(ThreadContext *, TLS); | 545 ICE_TLS_DECLARE_FIELD(ThreadContext *, TLS); |
| 555 | 546 |
| 556 // Private helpers for mangleName() | 547 // Private helpers for mangleName() |
| 557 typedef llvm::SmallVector<char, 32> ManglerVector; | 548 typedef llvm::SmallVector<char, 32> ManglerVector; |
| 558 void incrementSubstitutions(ManglerVector &OldName) const; | 549 void incrementSubstitutions(ManglerVector &OldName) const; |
| 559 | 550 |
| 560 // Randomization Cookie | |
| 561 // Managed by getRandomizationCookie() | |
| 562 GlobalLockType RandomizationCookieLock; | |
| 563 uint32_t RandomizationCookie = 0; | |
| 564 | |
| 565 public: | 551 public: |
| 566 static void TlsInit() { ICE_TLS_INIT_FIELD(TLS); } | 552 static void TlsInit() { ICE_TLS_INIT_FIELD(TLS); } |
| 567 }; | 553 }; |
| 568 | 554 |
| 569 /// Helper class to push and pop a timer marker. The constructor | 555 /// Helper class to push and pop a timer marker. The constructor |
| 570 /// pushes a marker, and the destructor pops it. This is for | 556 /// pushes a marker, and the destructor pops it. This is for |
| 571 /// convenient timing of regions of code. | 557 /// convenient timing of regions of code. |
| 572 class TimerMarker { | 558 class TimerMarker { |
| 573 TimerMarker() = delete; | 559 TimerMarker() = delete; |
| 574 TimerMarker(const TimerMarker &) = delete; | 560 TimerMarker(const TimerMarker &) = delete; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } | 601 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } |
| 616 ~OstreamLocker() { Ctx->unlockStr(); } | 602 ~OstreamLocker() { Ctx->unlockStr(); } |
| 617 | 603 |
| 618 private: | 604 private: |
| 619 GlobalContext *const Ctx; | 605 GlobalContext *const Ctx; |
| 620 }; | 606 }; |
| 621 | 607 |
| 622 } // end of namespace Ice | 608 } // end of namespace Ice |
| 623 | 609 |
| 624 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 610 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| OLD | NEW |