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 // This file declares aspects of the compilation that persist across | 10 // This file declares aspects of the compilation that persist across |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 132 } |
133 }; | 133 }; |
134 | 134 |
135 // ThreadContext contains thread-local data. This data can be | 135 // ThreadContext contains thread-local data. This data can be |
136 // combined/reduced as needed after all threads complete. | 136 // combined/reduced as needed after all threads complete. |
137 class ThreadContext { | 137 class ThreadContext { |
138 ThreadContext(const ThreadContext &) = delete; | 138 ThreadContext(const ThreadContext &) = delete; |
139 ThreadContext &operator=(const ThreadContext &) = delete; | 139 ThreadContext &operator=(const ThreadContext &) = delete; |
140 | 140 |
141 public: | 141 public: |
142 ThreadContext() {} | 142 ThreadContext() = default; |
143 CodeStats StatsFunction; | 143 CodeStats StatsFunction; |
144 CodeStats StatsCumulative; | 144 CodeStats StatsCumulative; |
145 TimerList Timers; | 145 TimerList Timers; |
146 }; | 146 }; |
147 | 147 |
148 public: | 148 public: |
149 // The dump stream is a log stream while emit is the stream code | 149 // The dump stream is a log stream while emit is the stream code |
150 // is emitted to. The error stream is strictly for logging errors. | 150 // is emitted to. The error stream is strictly for logging errors. |
151 GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError, | 151 GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError, |
152 ELFStreamer *ELFStreamer, const ClFlags &Flags); | 152 ELFStreamer *ELFStreamer, const ClFlags &Flags); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 std::unique_ptr<ELFObjectWriter> ObjectWriter; | 459 std::unique_ptr<ELFObjectWriter> ObjectWriter; |
460 BoundedProducerConsumerQueue<Cfg> OptQ; | 460 BoundedProducerConsumerQueue<Cfg> OptQ; |
461 BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ; | 461 BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ; |
462 // DataLowering is only ever used by a single thread at a time (either in | 462 // DataLowering is only ever used by a single thread at a time (either in |
463 // emitItems(), or in IceCompiler::run before the compilation is over.) | 463 // emitItems(), or in IceCompiler::run before the compilation is over.) |
464 // TODO(jpp): move to EmitterContext. | 464 // TODO(jpp): move to EmitterContext. |
465 std::unique_ptr<TargetDataLowering> DataLowering; | 465 std::unique_ptr<TargetDataLowering> DataLowering; |
466 // If !HasEmittedCode, SubZero will accumulate all Globals (which are "true" | 466 // If !HasEmittedCode, SubZero will accumulate all Globals (which are "true" |
467 // program global variables) until the first code WorkItem is seen. | 467 // program global variables) until the first code WorkItem is seen. |
468 // TODO(jpp): move to EmitterContext. | 468 // TODO(jpp): move to EmitterContext. |
469 bool HasSeenCode; | 469 bool HasSeenCode = false; |
470 // TODO(jpp): move to EmitterContext. | 470 // TODO(jpp): move to EmitterContext. |
471 VariableDeclarationList Globals; | 471 VariableDeclarationList Globals; |
472 // TODO(jpp): move to EmitterContext. | 472 // TODO(jpp): move to EmitterContext. |
473 std::unique_ptr<VariableDeclaration> ProfileBlockInfoVarDecl; | 473 std::unique_ptr<VariableDeclaration> ProfileBlockInfoVarDecl; |
474 | 474 |
475 LockedPtr<ArenaAllocator<>> getAllocator() { | 475 LockedPtr<ArenaAllocator<>> getAllocator() { |
476 return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock); | 476 return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock); |
477 } | 477 } |
478 LockedPtr<ConstantPool> getConstPool() { | 478 LockedPtr<ConstantPool> getConstPool() { |
479 return LockedPtr<ConstantPool>(ConstPool.get(), &ConstPoolLock); | 479 return LockedPtr<ConstantPool>(ConstPool.get(), &ConstPoolLock); |
(...skipping 25 matching lines...) Expand all Loading... |
505 // AllThreadContexts. | 505 // AllThreadContexts. |
506 ICE_TLS_DECLARE_FIELD(ThreadContext *, TLS); | 506 ICE_TLS_DECLARE_FIELD(ThreadContext *, TLS); |
507 | 507 |
508 // Private helpers for mangleName() | 508 // Private helpers for mangleName() |
509 typedef llvm::SmallVector<char, 32> ManglerVector; | 509 typedef llvm::SmallVector<char, 32> ManglerVector; |
510 void incrementSubstitutions(ManglerVector &OldName) const; | 510 void incrementSubstitutions(ManglerVector &OldName) const; |
511 | 511 |
512 // Randomization Cookie | 512 // Randomization Cookie |
513 // Managed by getRandomizationCookie() | 513 // Managed by getRandomizationCookie() |
514 GlobalLockType RandomizationCookieLock; | 514 GlobalLockType RandomizationCookieLock; |
515 uint32_t RandomizationCookie; | 515 uint32_t RandomizationCookie = 0; |
516 | 516 |
517 public: | 517 public: |
518 static void TlsInit() { ICE_TLS_INIT_FIELD(TLS); } | 518 static void TlsInit() { ICE_TLS_INIT_FIELD(TLS); } |
519 }; | 519 }; |
520 | 520 |
521 // Helper class to push and pop a timer marker. The constructor | 521 // Helper class to push and pop a timer marker. The constructor |
522 // pushes a marker, and the destructor pops it. This is for | 522 // pushes a marker, and the destructor pops it. This is for |
523 // convenient timing of regions of code. | 523 // convenient timing of regions of code. |
524 class TimerMarker { | 524 class TimerMarker { |
525 TimerMarker() = delete; | 525 TimerMarker() = delete; |
526 TimerMarker(const TimerMarker &) = delete; | 526 TimerMarker(const TimerMarker &) = delete; |
527 TimerMarker &operator=(const TimerMarker &) = delete; | 527 TimerMarker &operator=(const TimerMarker &) = delete; |
528 | 528 |
529 public: | 529 public: |
530 TimerMarker(TimerIdT ID, GlobalContext *Ctx, | 530 TimerMarker(TimerIdT ID, GlobalContext *Ctx, |
531 TimerStackIdT StackID = GlobalContext::TSK_Default) | 531 TimerStackIdT StackID = GlobalContext::TSK_Default) |
532 : ID(ID), Ctx(Ctx), StackID(StackID), Active(false) { | 532 : ID(ID), Ctx(Ctx), StackID(StackID) { |
533 if (ALLOW_DUMP) | 533 if (ALLOW_DUMP) |
534 push(); | 534 push(); |
535 } | 535 } |
536 TimerMarker(TimerIdT ID, const Cfg *Func, | 536 TimerMarker(TimerIdT ID, const Cfg *Func, |
537 TimerStackIdT StackID = GlobalContext::TSK_Default) | 537 TimerStackIdT StackID = GlobalContext::TSK_Default) |
538 : ID(ID), Ctx(nullptr), StackID(StackID), Active(false) { | 538 : ID(ID), Ctx(nullptr), StackID(StackID) { |
539 // Ctx gets set at the beginning of pushCfg(). | 539 // Ctx gets set at the beginning of pushCfg(). |
540 if (ALLOW_DUMP) | 540 if (ALLOW_DUMP) |
541 pushCfg(Func); | 541 pushCfg(Func); |
542 } | 542 } |
543 | 543 |
544 ~TimerMarker() { | 544 ~TimerMarker() { |
545 if (ALLOW_DUMP && Active) | 545 if (ALLOW_DUMP && Active) |
546 Ctx->popTimer(ID, StackID); | 546 Ctx->popTimer(ID, StackID); |
547 } | 547 } |
548 | 548 |
549 private: | 549 private: |
550 void push(); | 550 void push(); |
551 void pushCfg(const Cfg *Func); | 551 void pushCfg(const Cfg *Func); |
552 const TimerIdT ID; | 552 const TimerIdT ID; |
553 GlobalContext *Ctx; | 553 GlobalContext *Ctx; |
554 const TimerStackIdT StackID; | 554 const TimerStackIdT StackID; |
555 bool Active; | 555 bool Active = false; |
556 }; | 556 }; |
557 | 557 |
558 // Helper class for locking the streams and then automatically | 558 // Helper class for locking the streams and then automatically |
559 // unlocking them. | 559 // unlocking them. |
560 class OstreamLocker { | 560 class OstreamLocker { |
561 private: | 561 private: |
562 OstreamLocker() = delete; | 562 OstreamLocker() = delete; |
563 OstreamLocker(const OstreamLocker &) = delete; | 563 OstreamLocker(const OstreamLocker &) = delete; |
564 OstreamLocker &operator=(const OstreamLocker &) = delete; | 564 OstreamLocker &operator=(const OstreamLocker &) = delete; |
565 | 565 |
566 public: | 566 public: |
567 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } | 567 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } |
568 ~OstreamLocker() { Ctx->unlockStr(); } | 568 ~OstreamLocker() { Ctx->unlockStr(); } |
569 | 569 |
570 private: | 570 private: |
571 GlobalContext *const Ctx; | 571 GlobalContext *const Ctx; |
572 }; | 572 }; |
573 | 573 |
574 } // end of namespace Ice | 574 } // end of namespace Ice |
575 | 575 |
576 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 576 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
OLD | NEW |