| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // the work queue is currently empty. Returns nullptr if there is | 296 // the work queue is currently empty. Returns nullptr if there is |
| 297 // no more work - the queue is empty and either end() has been | 297 // no more work - the queue is empty and either end() has been |
| 298 // called or the Sequential flag was set. | 298 // called or the Sequential flag was set. |
| 299 std::unique_ptr<Cfg> optQueueBlockingPop(); | 299 std::unique_ptr<Cfg> optQueueBlockingPop(); |
| 300 // Notifies that no more work will be added to the work queue. | 300 // Notifies that no more work will be added to the work queue. |
| 301 void optQueueNotifyEnd() { OptQ.notifyEnd(); } | 301 void optQueueNotifyEnd() { OptQ.notifyEnd(); } |
| 302 | 302 |
| 303 // Emit file header for output file. | 303 // Emit file header for output file. |
| 304 void emitFileHeader(); | 304 void emitFileHeader(); |
| 305 | 305 |
| 306 void lowerConstants(); |
| 307 |
| 306 void emitQueueBlockingPush(EmitterWorkItem *Item); | 308 void emitQueueBlockingPush(EmitterWorkItem *Item); |
| 307 EmitterWorkItem *emitQueueBlockingPop(); | 309 EmitterWorkItem *emitQueueBlockingPop(); |
| 308 void emitQueueNotifyEnd() { EmitQ.notifyEnd(); } | 310 void emitQueueNotifyEnd() { EmitQ.notifyEnd(); } |
| 309 | 311 |
| 310 void initParserThread() { | 312 void initParserThread() { |
| 311 ThreadContext *Tls = new ThreadContext(); | 313 ThreadContext *Tls = new ThreadContext(); |
| 312 auto Timers = getTimers(); | 314 auto Timers = getTimers(); |
| 313 Timers->initInto(Tls->Timers); | 315 Timers->initInto(Tls->Timers); |
| 314 AllThreadContexts.push_back(Tls); | 316 AllThreadContexts.push_back(Tls); |
| 315 ICE_TLS_SET_FIELD(TLS, Tls); | 317 ICE_TLS_SET_FIELD(TLS, Tls); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 375 |
| 374 // Emitter thread startup routine. | 376 // Emitter thread startup routine. |
| 375 void emitterWrapper(ThreadContext *MyTLS) { | 377 void emitterWrapper(ThreadContext *MyTLS) { |
| 376 ICE_TLS_SET_FIELD(TLS, MyTLS); | 378 ICE_TLS_SET_FIELD(TLS, MyTLS); |
| 377 emitItems(); | 379 emitItems(); |
| 378 } | 380 } |
| 379 // Emit functions and global initializers from the emitter queue | 381 // Emit functions and global initializers from the emitter queue |
| 380 // until the queue is empty. | 382 // until the queue is empty. |
| 381 void emitItems(); | 383 void emitItems(); |
| 382 | 384 |
| 385 // Uses DataLowering to lower Globals. As a side effect, clears the Globals |
| 386 // array. |
| 387 void lowerGlobals(const IceString &SectionSuffix); |
| 388 |
| 389 // Lowers the profile information. |
| 390 void lowerProfileData(); |
| 391 |
| 383 // Utility function to match a symbol name against a match string. | 392 // Utility function to match a symbol name against a match string. |
| 384 // This is used in a few cases where we want to take some action on | 393 // This is used in a few cases where we want to take some action on |
| 385 // a particular function or symbol based on a command-line argument, | 394 // a particular function or symbol based on a command-line argument, |
| 386 // such as changing the verbose level for a particular function. An | 395 // such as changing the verbose level for a particular function. An |
| 387 // empty Match argument means match everything. Returns true if | 396 // empty Match argument means match everything. Returns true if |
| 388 // there is a match. | 397 // there is a match. |
| 389 static bool matchSymbolName(const IceString &SymbolName, | 398 static bool matchSymbolName(const IceString &SymbolName, |
| 390 const IceString &Match) { | 399 const IceString &Match) { |
| 391 return Match.empty() || Match == SymbolName; | 400 return Match.empty() || Match == SymbolName; |
| 392 } | 401 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 Ostream *StrError; // Stream for logging errors. | 437 Ostream *StrError; // Stream for logging errors. |
| 429 | 438 |
| 430 ICE_CACHELINE_BOUNDARY; | 439 ICE_CACHELINE_BOUNDARY; |
| 431 | 440 |
| 432 Intrinsics IntrinsicsInfo; | 441 Intrinsics IntrinsicsInfo; |
| 433 const ClFlags &Flags; | 442 const ClFlags &Flags; |
| 434 RandomNumberGenerator RNG; // TODO(stichnot): Move into Cfg. | 443 RandomNumberGenerator RNG; // TODO(stichnot): Move into Cfg. |
| 435 std::unique_ptr<ELFObjectWriter> ObjectWriter; | 444 std::unique_ptr<ELFObjectWriter> ObjectWriter; |
| 436 BoundedProducerConsumerQueue<Cfg> OptQ; | 445 BoundedProducerConsumerQueue<Cfg> OptQ; |
| 437 BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ; | 446 BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ; |
| 447 // DataLowering is only ever used by a single thread at a time (either in |
| 448 // emitItems(), or in IceCompiler::run before the compilation is over.) |
| 449 std::unique_ptr<TargetDataLowering> DataLowering; |
| 450 // If !HasEmittedCode, SubZero will accumulate all Globals (which are "true" |
| 451 // program global variables) until the first code WorkItem is seen. |
| 452 bool HasSeenCode; |
| 453 VariableDeclarationList Globals; |
| 454 std::unique_ptr<VariableDeclaration> ProfileBlockInfoVarDecl; |
| 438 | 455 |
| 439 LockedPtr<ArenaAllocator<>> getAllocator() { | 456 LockedPtr<ArenaAllocator<>> getAllocator() { |
| 440 return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock); | 457 return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock); |
| 441 } | 458 } |
| 442 LockedPtr<ConstantPool> getConstPool() { | 459 LockedPtr<ConstantPool> getConstPool() { |
| 443 return LockedPtr<ConstantPool>(ConstPool.get(), &ConstPoolLock); | 460 return LockedPtr<ConstantPool>(ConstPool.get(), &ConstPoolLock); |
| 444 } | 461 } |
| 445 LockedPtr<CodeStats> getStatsCumulative() { | 462 LockedPtr<CodeStats> getStatsCumulative() { |
| 446 return LockedPtr<CodeStats>(&StatsCumulative, &StatsLock); | 463 return LockedPtr<CodeStats>(&StatsCumulative, &StatsLock); |
| 447 } | 464 } |
| 448 LockedPtr<TimerList> getTimers() { | 465 LockedPtr<TimerList> getTimers() { |
| 449 return LockedPtr<TimerList>(&Timers, &TimerLock); | 466 return LockedPtr<TimerList>(&Timers, &TimerLock); |
| 450 } | 467 } |
| 451 | 468 |
| 469 void accumulateGlobals(std::unique_ptr<VariableDeclarationList> Globls) { |
| 470 if (Globls != nullptr) |
| 471 Globals.insert(Globals.end(), Globls->begin(), Globls->end()); |
| 472 } |
| 473 |
| 474 void lowerGlobalsIfNoCodeHasBeenSeen() { |
| 475 if (HasSeenCode) |
| 476 return; |
| 477 constexpr char NoSuffix[] = ""; |
| 478 lowerGlobals(NoSuffix); |
| 479 HasSeenCode = true; |
| 480 } |
| 481 |
| 452 llvm::SmallVector<ThreadContext *, 128> AllThreadContexts; | 482 llvm::SmallVector<ThreadContext *, 128> AllThreadContexts; |
| 453 llvm::SmallVector<std::thread, 128> TranslationThreads; | 483 llvm::SmallVector<std::thread, 128> TranslationThreads; |
| 454 llvm::SmallVector<std::thread, 128> EmitterThreads; | 484 llvm::SmallVector<std::thread, 128> EmitterThreads; |
| 455 // Each thread has its own TLS pointer which is also held in | 485 // Each thread has its own TLS pointer which is also held in |
| 456 // AllThreadContexts. | 486 // AllThreadContexts. |
| 457 ICE_TLS_DECLARE_FIELD(ThreadContext *, TLS); | 487 ICE_TLS_DECLARE_FIELD(ThreadContext *, TLS); |
| 458 | 488 |
| 459 // Private helpers for mangleName() | 489 // Private helpers for mangleName() |
| 460 typedef llvm::SmallVector<char, 32> ManglerVector; | 490 typedef llvm::SmallVector<char, 32> ManglerVector; |
| 461 void incrementSubstitutions(ManglerVector &OldName) const; | 491 void incrementSubstitutions(ManglerVector &OldName) const; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } | 543 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } |
| 514 ~OstreamLocker() { Ctx->unlockStr(); } | 544 ~OstreamLocker() { Ctx->unlockStr(); } |
| 515 | 545 |
| 516 private: | 546 private: |
| 517 GlobalContext *const Ctx; | 547 GlobalContext *const Ctx; |
| 518 }; | 548 }; |
| 519 | 549 |
| 520 } // end of namespace Ice | 550 } // end of namespace Ice |
| 521 | 551 |
| 522 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 552 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| OLD | NEW |