Chromium Code Reviews| 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 /// This file declares aspects of the compilation that persist across | 11 /// This file declares aspects of the compilation that persist across |
| 12 /// multiple functions. | 12 /// multiple 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 "IceIntrinsics.h" | 21 #include "IceIntrinsics.h" |
| 22 #include "IceRNG.h" | 22 #include "IceRNG.h" |
| 23 #include "IceSwitchLowering.h" | |
| 23 #include "IceThreading.h" | 24 #include "IceThreading.h" |
| 24 #include "IceTimerTree.h" | 25 #include "IceTimerTree.h" |
| 25 #include "IceTypes.h" | 26 #include "IceTypes.h" |
| 26 #include "IceUtils.h" | 27 #include "IceUtils.h" |
| 27 | 28 |
| 28 #include <array> | 29 #include <array> |
| 29 #include <functional> | 30 #include <functional> |
| 30 #include <mutex> | 31 #include <mutex> |
| 31 #include <thread> | 32 #include <thread> |
| 32 #include <type_traits> | 33 #include <type_traits> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 48 public: | 49 public: |
| 49 LockedPtr(T *Value, GlobalLockType *Lock) : Value(Value), Lock(Lock) { | 50 LockedPtr(T *Value, GlobalLockType *Lock) : Value(Value), Lock(Lock) { |
| 50 Lock->lock(); | 51 Lock->lock(); |
| 51 } | 52 } |
| 52 LockedPtr(LockedPtr &&Other) : Value(Other.Value), Lock(Other.Lock) { | 53 LockedPtr(LockedPtr &&Other) : Value(Other.Value), Lock(Other.Lock) { |
| 53 Other.Value = nullptr; | 54 Other.Value = nullptr; |
| 54 Other.Lock = nullptr; | 55 Other.Lock = nullptr; |
| 55 } | 56 } |
| 56 ~LockedPtr() { Lock->unlock(); } | 57 ~LockedPtr() { Lock->unlock(); } |
| 57 T *operator->() const { return Value; } | 58 T *operator->() const { return Value; } |
| 59 T &operator*() const { return *Value; } | |
| 58 | 60 |
| 59 private: | 61 private: |
| 60 T *Value; | 62 T *Value; |
| 61 GlobalLockType *Lock; | 63 GlobalLockType *Lock; |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 class GlobalContext { | 66 class GlobalContext { |
| 65 GlobalContext() = delete; | 67 GlobalContext() = delete; |
| 66 GlobalContext(const GlobalContext &) = delete; | 68 GlobalContext(const GlobalContext &) = delete; |
| 67 GlobalContext &operator=(const GlobalContext &) = delete; | 69 GlobalContext &operator=(const GlobalContext &) = delete; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 /// Returns an undef. | 204 /// Returns an undef. |
| 203 Constant *getConstantUndef(Type Ty); | 205 Constant *getConstantUndef(Type Ty); |
| 204 /// Returns a zero value. | 206 /// Returns a zero value. |
| 205 Constant *getConstantZero(Type Ty); | 207 Constant *getConstantZero(Type Ty); |
| 206 /// getConstantPool() returns a copy of the constant pool for | 208 /// getConstantPool() returns a copy of the constant pool for |
| 207 /// constants of a given type. | 209 /// constants of a given type. |
| 208 ConstantList getConstantPool(Type Ty); | 210 ConstantList getConstantPool(Type Ty); |
| 209 /// Returns a copy of the list of external symbols. | 211 /// Returns a copy of the list of external symbols. |
| 210 ConstantList getConstantExternSyms(); | 212 ConstantList getConstantExternSyms(); |
| 211 | 213 |
| 214 /// Return a locked pointer to the registered jump tables. | |
| 215 LockedPtr<std::vector<JumpTableData>> getJumpTables() { | |
| 216 return LockedPtr<std::vector<JumpTableData>>(&JumpTables, &JumpTablesLock); | |
| 217 } | |
| 218 /// Create a new jump table entry and return a reference to it. | |
| 219 JumpTableData &addJumpTable(IceString FuncName, SizeT Id, SizeT NumTargets); | |
| 220 | |
| 212 const ClFlags &getFlags() const { return Flags; } | 221 const ClFlags &getFlags() const { return Flags; } |
| 213 | 222 |
| 214 bool isIRGenerationDisabled() const { | 223 bool isIRGenerationDisabled() const { |
| 215 return getFlags().getDisableIRGeneration(); | 224 return getFlags().getDisableIRGeneration(); |
| 216 } | 225 } |
| 217 | 226 |
| 218 /// Allocate data of type T using the global allocator. We allow entities | 227 /// Allocate data of type T using the global allocator. We allow entities |
| 219 /// allocated from this global allocator to be either trivially or | 228 /// allocated from this global allocator to be either trivially or |
| 220 /// non-trivially destructible. We optimize the case when T is trivially | 229 /// non-trivially destructible. We optimize the case when T is trivially |
| 221 /// destructible by not registering a destructor. Destructors will be invoked | 230 /// destructible by not registering a destructor. Destructors will be invoked |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 /// called or the Sequential flag was set. | 337 /// called or the Sequential flag was set. |
| 329 std::unique_ptr<Cfg> optQueueBlockingPop(); | 338 std::unique_ptr<Cfg> optQueueBlockingPop(); |
| 330 /// Notifies that no more work will be added to the work queue. | 339 /// Notifies that no more work will be added to the work queue. |
| 331 void optQueueNotifyEnd() { OptQ.notifyEnd(); } | 340 void optQueueNotifyEnd() { OptQ.notifyEnd(); } |
| 332 | 341 |
| 333 /// Emit file header for output file. | 342 /// Emit file header for output file. |
| 334 void emitFileHeader(); | 343 void emitFileHeader(); |
| 335 | 344 |
| 336 void lowerConstants(); | 345 void lowerConstants(); |
| 337 | 346 |
| 347 void lowerJumpTables(); | |
| 348 | |
| 338 void emitQueueBlockingPush(EmitterWorkItem *Item); | 349 void emitQueueBlockingPush(EmitterWorkItem *Item); |
| 339 EmitterWorkItem *emitQueueBlockingPop(); | 350 EmitterWorkItem *emitQueueBlockingPop(); |
| 340 void emitQueueNotifyEnd() { EmitQ.notifyEnd(); } | 351 void emitQueueNotifyEnd() { EmitQ.notifyEnd(); } |
| 341 | 352 |
| 342 void initParserThread() { | 353 void initParserThread() { |
| 343 ThreadContext *Tls = new ThreadContext(); | 354 ThreadContext *Tls = new ThreadContext(); |
| 344 auto Timers = getTimers(); | 355 auto Timers = getTimers(); |
| 345 Timers->initInto(Tls->Timers); | 356 Timers->initInto(Tls->Timers); |
| 346 AllThreadContexts.push_back(Tls); | 357 AllThreadContexts.push_back(Tls); |
| 347 ICE_TLS_SET_FIELD(TLS, Tls); | 358 ICE_TLS_SET_FIELD(TLS, Tls); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 449 typedef std::vector<std::function<void()>> DestructorArray; | 460 typedef std::vector<std::function<void()>> DestructorArray; |
| 450 GlobalLockType DestructorsLock; | 461 GlobalLockType DestructorsLock; |
| 451 DestructorArray Destructors; | 462 DestructorArray Destructors; |
| 452 | 463 |
| 453 ICE_CACHELINE_BOUNDARY; | 464 ICE_CACHELINE_BOUNDARY; |
| 454 // Managed by getConstantPool() | 465 // Managed by getConstantPool() |
| 455 GlobalLockType ConstPoolLock; | 466 GlobalLockType ConstPoolLock; |
| 456 std::unique_ptr<ConstantPool> ConstPool; | 467 std::unique_ptr<ConstantPool> ConstPool; |
| 457 | 468 |
| 458 ICE_CACHELINE_BOUNDARY; | 469 ICE_CACHELINE_BOUNDARY; |
| 470 // Managed by getJumpTables() | |
| 471 GlobalLockType JumpTablesLock; | |
| 472 std::vector<JumpTableData> JumpTables; | |
|
Jim Stichnoth
2015/07/30 15:20:23
Make vector<JumpTableData> into a typedef, like Ju
ascull
2015/07/30 17:29:59
Despite my dislike of hiding the type, done.
Jim Stichnoth
2015/07/30 17:40:44
I share this dislike, but I find it less displeasi
| |
| 473 | |
| 474 ICE_CACHELINE_BOUNDARY; | |
| 459 // Managed by getErrorStatus() | 475 // Managed by getErrorStatus() |
| 460 GlobalLockType ErrorStatusLock; | 476 GlobalLockType ErrorStatusLock; |
| 461 ErrorCode ErrorStatus; | 477 ErrorCode ErrorStatus; |
| 462 | 478 |
| 463 ICE_CACHELINE_BOUNDARY; | 479 ICE_CACHELINE_BOUNDARY; |
| 464 // Managed by getStatsCumulative() | 480 // Managed by getStatsCumulative() |
| 465 GlobalLockType StatsLock; | 481 GlobalLockType StatsLock; |
| 466 CodeStats StatsCumulative; | 482 CodeStats StatsCumulative; |
| 467 | 483 |
| 468 ICE_CACHELINE_BOUNDARY; | 484 ICE_CACHELINE_BOUNDARY; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } | 614 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } |
| 599 ~OstreamLocker() { Ctx->unlockStr(); } | 615 ~OstreamLocker() { Ctx->unlockStr(); } |
| 600 | 616 |
| 601 private: | 617 private: |
| 602 GlobalContext *const Ctx; | 618 GlobalContext *const Ctx; |
| 603 }; | 619 }; |
| 604 | 620 |
| 605 } // end of namespace Ice | 621 } // end of namespace Ice |
| 606 | 622 |
| 607 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 623 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| OLD | NEW |