| 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 |
| 11 /// \brief Declares aspects of the compilation that persist across multiple | 11 /// \brief Declares aspects of the compilation that persist across multiple |
| 12 /// functions. | 12 /// functions. |
| 13 /// | 13 /// |
| 14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 15 | 15 |
| 16 #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H | 16 #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| 17 #define SUBZERO_SRC_ICEGLOBALCONTEXT_H | 17 #define SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| 18 | 18 |
| 19 #include "IceDefs.h" | 19 #include "IceDefs.h" |
| 20 #include "IceClFlags.h" | 20 #include "IceClFlags.h" |
| 21 #include "IceInstrumentation.h" |
| 21 #include "IceIntrinsics.h" | 22 #include "IceIntrinsics.h" |
| 22 #include "IceRNG.h" | 23 #include "IceRNG.h" |
| 23 #include "IceStringPool.h" | 24 #include "IceStringPool.h" |
| 24 #include "IceSwitchLowering.h" | 25 #include "IceSwitchLowering.h" |
| 25 #include "IceTargetLowering.def" | 26 #include "IceTargetLowering.def" |
| 26 #include "IceThreading.h" | 27 #include "IceThreading.h" |
| 27 #include "IceTimerTree.h" | 28 #include "IceTimerTree.h" |
| 28 #include "IceTypes.h" | 29 #include "IceTypes.h" |
| 29 #include "IceUtils.h" | 30 #include "IceUtils.h" |
| 30 | 31 |
| 31 #include <array> | 32 #include <array> |
| 32 #include <atomic> | 33 #include <atomic> |
| 33 #include <cassert> | 34 #include <cassert> |
| 34 #include <functional> | 35 #include <functional> |
| 35 #include <memory> | 36 #include <memory> |
| 36 #include <mutex> | 37 #include <mutex> |
| 37 #include <thread> | 38 #include <thread> |
| 38 #include <type_traits> | 39 #include <type_traits> |
| 39 #include <utility> | 40 #include <utility> |
| 40 #include <vector> | 41 #include <vector> |
| 41 | 42 |
| 42 namespace Ice { | 43 namespace Ice { |
| 43 | 44 |
| 44 class ConstantPool; | 45 class ConstantPool; |
| 45 class EmitterWorkItem; | 46 class EmitterWorkItem; |
| 46 class FuncSigType; | 47 class FuncSigType; |
| 48 class Instrumentation; |
| 47 | 49 |
| 48 // Runtime helper function IDs | 50 // Runtime helper function IDs |
| 49 | 51 |
| 50 enum class RuntimeHelper { | 52 enum class RuntimeHelper { |
| 51 #define X(Tag, Name) H_##Tag, | 53 #define X(Tag, Name) H_##Tag, |
| 52 RUNTIME_HELPER_FUNCTIONS_TABLE | 54 RUNTIME_HELPER_FUNCTIONS_TABLE |
| 53 #undef X | 55 #undef X |
| 54 H_Num | 56 H_Num |
| 55 }; | 57 }; |
| 56 | 58 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 ThreadContext *WorkerTLS = new ThreadContext(); | 421 ThreadContext *WorkerTLS = new ThreadContext(); |
| 420 Timers->initInto(WorkerTLS->Timers); | 422 Timers->initInto(WorkerTLS->Timers); |
| 421 AllThreadContexts.push_back(WorkerTLS); | 423 AllThreadContexts.push_back(WorkerTLS); |
| 422 EmitterThreads.push_back( | 424 EmitterThreads.push_back( |
| 423 std::thread(&GlobalContext::emitterWrapper, this, WorkerTLS)); | 425 std::thread(&GlobalContext::emitterWrapper, this, WorkerTLS)); |
| 424 } | 426 } |
| 425 } | 427 } |
| 426 | 428 |
| 427 void waitForWorkerThreads(); | 429 void waitForWorkerThreads(); |
| 428 | 430 |
| 431 /// sets the instrumentation object to use. |
| 432 void setInstrumentation(std::unique_ptr<Instrumentation> Instr) { |
| 433 if (!BuildDefs::minimal()) |
| 434 Instrumentor = std::move(Instr); |
| 435 } |
| 436 |
| 437 void instrumentFunc(Cfg *Func) { |
| 438 if (!BuildDefs::minimal() && Instrumentor) |
| 439 Instrumentor->instrumentFunc(Func); |
| 440 } |
| 441 |
| 429 /// Translation thread startup routine. | 442 /// Translation thread startup routine. |
| 430 void translateFunctionsWrapper(ThreadContext *MyTLS) { | 443 void translateFunctionsWrapper(ThreadContext *MyTLS) { |
| 431 ICE_TLS_SET_FIELD(TLS, MyTLS); | 444 ICE_TLS_SET_FIELD(TLS, MyTLS); |
| 432 translateFunctions(); | 445 translateFunctions(); |
| 433 } | 446 } |
| 434 /// Translate functions from the Cfg queue until the queue is empty. | 447 /// Translate functions from the Cfg queue until the queue is empty. |
| 435 void translateFunctions(); | 448 void translateFunctions(); |
| 436 | 449 |
| 437 /// Emitter thread startup routine. | 450 /// Emitter thread startup routine. |
| 438 void emitterWrapper(ThreadContext *MyTLS) { | 451 void emitterWrapper(ThreadContext *MyTLS) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 BoundedProducerConsumerQueue<OptWorkItem, MaxOptQSize> OptQ; | 558 BoundedProducerConsumerQueue<OptWorkItem, MaxOptQSize> OptQ; |
| 546 BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ; | 559 BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ; |
| 547 // DataLowering is only ever used by a single thread at a time (either in | 560 // DataLowering is only ever used by a single thread at a time (either in |
| 548 // emitItems(), or in IceCompiler::run before the compilation is over.) | 561 // emitItems(), or in IceCompiler::run before the compilation is over.) |
| 549 // TODO(jpp): move to EmitterContext. | 562 // TODO(jpp): move to EmitterContext. |
| 550 std::unique_ptr<TargetDataLowering> DataLowering; | 563 std::unique_ptr<TargetDataLowering> DataLowering; |
| 551 /// If !HasEmittedCode, SubZero will accumulate all Globals (which are "true" | 564 /// If !HasEmittedCode, SubZero will accumulate all Globals (which are "true" |
| 552 /// program global variables) until the first code WorkItem is seen. | 565 /// program global variables) until the first code WorkItem is seen. |
| 553 // TODO(jpp): move to EmitterContext. | 566 // TODO(jpp): move to EmitterContext. |
| 554 bool HasSeenCode = false; | 567 bool HasSeenCode = false; |
| 568 // If Instrumentor is not empty then it will be used to instrument globals and |
| 569 // CFGs. |
| 570 std::unique_ptr<Instrumentation> Instrumentor = nullptr; |
| 555 // TODO(jpp): move to EmitterContext. | 571 // TODO(jpp): move to EmitterContext. |
| 556 VariableDeclaration *ProfileBlockInfoVarDecl = nullptr; | 572 VariableDeclaration *ProfileBlockInfoVarDecl = nullptr; |
| 557 std::vector<VariableDeclaration *> ProfileBlockInfos; | 573 std::vector<VariableDeclaration *> ProfileBlockInfos; |
| 558 /// Indicates if global variable declarations can be disposed of right after | 574 /// Indicates if global variable declarations can be disposed of right after |
| 559 /// lowering. | 575 /// lowering. |
| 560 bool DisposeGlobalVariablesAfterLowering = true; | 576 bool DisposeGlobalVariablesAfterLowering = true; |
| 561 Constant *ConstZeroForType[IceType_NUM]; | 577 Constant *ConstZeroForType[IceType_NUM]; |
| 562 Constant *ConstantTrue; | 578 Constant *ConstantTrue; |
| 563 // Holds the constants representing each runtime helper function. | 579 // Holds the constants representing each runtime helper function. |
| 564 Constant *RuntimeHelperFunc[static_cast<size_t>(RuntimeHelper::H_Num)]; | 580 Constant *RuntimeHelperFunc[static_cast<size_t>(RuntimeHelper::H_Num)]; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } | 692 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } |
| 677 ~OstreamLocker() { Ctx->unlockStr(); } | 693 ~OstreamLocker() { Ctx->unlockStr(); } |
| 678 | 694 |
| 679 private: | 695 private: |
| 680 GlobalContext *const Ctx; | 696 GlobalContext *const Ctx; |
| 681 }; | 697 }; |
| 682 | 698 |
| 683 } // end of namespace Ice | 699 } // end of namespace Ice |
| 684 | 700 |
| 685 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 701 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| OLD | NEW |