OLD | NEW |
---|---|
1 //===- subzero/src/IceDefs.h - Common Subzero declarations ------*- C++ -*-===// | 1 //===- subzero/src/IceDefs.h - Common Subzero declarations ------*- 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 } // end of namespace Internal | 112 } // end of namespace Internal |
113 | 113 |
114 template <class T, class... Args> | 114 template <class T, class... Args> |
115 static std::unique_ptr<T> makeUnique(Args &&... TheArgs) { | 115 static std::unique_ptr<T> makeUnique(Args &&... TheArgs) { |
116 return ::Ice::Internal::MakeUniqueEnabler::create<T>( | 116 return ::Ice::Internal::MakeUniqueEnabler::create<T>( |
117 std::forward<Args>(TheArgs)...); | 117 std::forward<Args>(TheArgs)...); |
118 } | 118 } |
119 | 119 |
120 #define ENABLE_MAKE_UNIQUE friend struct ::Ice::Internal::MakeUniqueEnabler | 120 #define ENABLE_MAKE_UNIQUE friend struct ::Ice::Internal::MakeUniqueEnabler |
121 | 121 |
122 using IceString = std::string; | |
123 using InstList = llvm::ilist<Inst>; | 122 using InstList = llvm::ilist<Inst>; |
124 // Ideally PhiList would be llvm::ilist<InstPhi>, and similar for AssignList, | 123 // Ideally PhiList would be llvm::ilist<InstPhi>, and similar for AssignList, |
125 // but this runs into issues with SFINAE. | 124 // but this runs into issues with SFINAE. |
126 using PhiList = InstList; | 125 using PhiList = InstList; |
127 using AssignList = InstList; | 126 using AssignList = InstList; |
128 | 127 |
129 // Standard library containers with CfgLocalAllocator. | 128 // Standard library containers with CfgLocalAllocator. |
130 template <typename T> using CfgList = std::list<T, CfgLocalAllocator<T>>; | 129 template <typename T> using CfgList = std::list<T, CfgLocalAllocator<T>>; |
131 template <typename T, typename H = std::hash<T>, typename Eq = std::equal_to<T>> | 130 template <typename T, typename H = std::hash<T>, typename Eq = std::equal_to<T>> |
132 using CfgUnorderedSet = std::unordered_set<T, H, Eq, CfgLocalAllocator<T>>; | 131 using CfgUnorderedSet = std::unordered_set<T, H, Eq, CfgLocalAllocator<T>>; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 FT_Elf, /// ELF .o file | 349 FT_Elf, /// ELF .o file |
351 FT_Asm, /// Assembly .s file | 350 FT_Asm, /// Assembly .s file |
352 FT_Iasm /// "Integrated assembler" .byte-style .s file | 351 FT_Iasm /// "Integrated assembler" .byte-style .s file |
353 }; | 352 }; |
354 | 353 |
355 using Ostream = llvm::raw_ostream; | 354 using Ostream = llvm::raw_ostream; |
356 using Fdstream = llvm::raw_fd_ostream; | 355 using Fdstream = llvm::raw_fd_ostream; |
357 | 356 |
358 using GlobalLockType = std::mutex; | 357 using GlobalLockType = std::mutex; |
359 | 358 |
359 template <typename T> class LockedPtr { | |
John
2016/03/29 14:23:15
Consider documenting locked ptr.
Jim Stichnoth
2016/03/29 21:40:49
Done.
| |
360 LockedPtr() = delete; | |
361 LockedPtr(const LockedPtr &) = delete; | |
362 LockedPtr &operator=(const LockedPtr &) = delete; | |
363 | |
364 public: | |
365 LockedPtr(T *Value, GlobalLockType *Lock) : Value(Value), Lock(Lock) { | |
366 Lock->lock(); | |
367 } | |
368 LockedPtr(LockedPtr &&Other) : Value(Other.Value), Lock(Other.Lock) { | |
369 Other.Value = nullptr; | |
370 Other.Lock = nullptr; | |
371 } | |
372 ~LockedPtr() { Lock->unlock(); } | |
373 T *operator->() const { return Value; } | |
374 T &operator*() const { return *Value; } | |
375 T *get() { return Value; } | |
376 | |
377 private: | |
378 T *Value; | |
379 GlobalLockType *Lock; | |
380 }; | |
381 | |
360 enum ErrorCodes { EC_None = 0, EC_Args, EC_Bitcode, EC_Translation }; | 382 enum ErrorCodes { EC_None = 0, EC_Args, EC_Bitcode, EC_Translation }; |
361 | 383 |
362 /// Wrapper around std::error_code for allowing multiple errors to be folded | 384 /// Wrapper around std::error_code for allowing multiple errors to be folded |
363 /// into one. The current implementation keeps track of the first error, which | 385 /// into one. The current implementation keeps track of the first error, which |
364 /// is likely to be the most useful one, and this could be extended to e.g. | 386 /// is likely to be the most useful one, and this could be extended to e.g. |
365 /// collect a vector of errors. | 387 /// collect a vector of errors. |
366 class ErrorCode : public std::error_code { | 388 class ErrorCode : public std::error_code { |
367 ErrorCode(const ErrorCode &) = delete; | 389 ErrorCode(const ErrorCode &) = delete; |
368 ErrorCode &operator=(const ErrorCode &) = delete; | 390 ErrorCode &operator=(const ErrorCode &) = delete; |
369 | 391 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 RPE_PooledConstantReordering, | 427 RPE_PooledConstantReordering, |
406 RPE_RegAllocRandomization, | 428 RPE_RegAllocRandomization, |
407 RPE_num | 429 RPE_num |
408 }; | 430 }; |
409 | 431 |
410 using RelocOffsetArray = llvm::SmallVector<class RelocOffset *, 4>; | 432 using RelocOffsetArray = llvm::SmallVector<class RelocOffset *, 4>; |
411 | 433 |
412 } // end of namespace Ice | 434 } // end of namespace Ice |
413 | 435 |
414 #endif // SUBZERO_SRC_ICEDEFS_H | 436 #endif // SUBZERO_SRC_ICEDEFS_H |
OLD | NEW |