Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1515)

Side by Side Diff: src/IceDefs.h

Issue 1838753002: Subzero: Remove IceString. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceELFObjectWriter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 /// LockedPtr is an RAII wrapper that allows automatically locked access to a
360 /// given pointer, automatically unlocking it when when the LockedPtr goes out
361 /// of scope.
362 template <typename T> class LockedPtr {
363 LockedPtr() = delete;
364 LockedPtr(const LockedPtr &) = delete;
365 LockedPtr &operator=(const LockedPtr &) = delete;
366
367 public:
368 LockedPtr(T *Value, GlobalLockType *Lock) : Value(Value), Lock(Lock) {
369 Lock->lock();
370 }
371 LockedPtr(LockedPtr &&Other) : Value(Other.Value), Lock(Other.Lock) {
372 Other.Value = nullptr;
373 Other.Lock = nullptr;
374 }
375 ~LockedPtr() { Lock->unlock(); }
376 T *operator->() const { return Value; }
377 T &operator*() const { return *Value; }
378 T *get() { return Value; }
379
380 private:
381 T *Value;
382 GlobalLockType *Lock;
383 };
384
360 enum ErrorCodes { EC_None = 0, EC_Args, EC_Bitcode, EC_Translation }; 385 enum ErrorCodes { EC_None = 0, EC_Args, EC_Bitcode, EC_Translation };
361 386
362 /// Wrapper around std::error_code for allowing multiple errors to be folded 387 /// 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 388 /// 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. 389 /// is likely to be the most useful one, and this could be extended to e.g.
365 /// collect a vector of errors. 390 /// collect a vector of errors.
366 class ErrorCode : public std::error_code { 391 class ErrorCode : public std::error_code {
367 ErrorCode(const ErrorCode &) = delete; 392 ErrorCode(const ErrorCode &) = delete;
368 ErrorCode &operator=(const ErrorCode &) = delete; 393 ErrorCode &operator=(const ErrorCode &) = delete;
369 394
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 RPE_PooledConstantReordering, 430 RPE_PooledConstantReordering,
406 RPE_RegAllocRandomization, 431 RPE_RegAllocRandomization,
407 RPE_num 432 RPE_num
408 }; 433 };
409 434
410 using RelocOffsetArray = llvm::SmallVector<class RelocOffset *, 4>; 435 using RelocOffsetArray = llvm::SmallVector<class RelocOffset *, 4>;
411 436
412 } // end of namespace Ice 437 } // end of namespace Ice
413 438
414 #endif // SUBZERO_SRC_ICEDEFS_H 439 #endif // SUBZERO_SRC_ICEDEFS_H
OLDNEW
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceELFObjectWriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698