Index: src/IceDefs.h |
diff --git a/src/IceDefs.h b/src/IceDefs.h |
index 66a500fe950f46a312caa41b1a8d84b4fe2dad36..8d4706d1700423c497bc1d31d10c822095096d9b 100644 |
--- a/src/IceDefs.h |
+++ b/src/IceDefs.h |
@@ -23,7 +23,9 @@ |
#include <limits> |
#include <list> |
#include <map> |
+#include <mutex> |
#include <string> |
+#include <system_error> |
#include <vector> |
#include "llvm/ADT/ArrayRef.h" |
#include "llvm/ADT/BitVector.h" |
@@ -65,6 +67,7 @@ class InstTarget; |
class LiveRange; |
class Liveness; |
class Operand; |
+class TargetGlobalLowering; |
class TargetLowering; |
class Variable; |
class VariableDeclaration; |
@@ -127,6 +130,17 @@ typedef llvm::BitVector LivenessBV; |
typedef uint32_t TimerStackIdT; |
typedef uint32_t TimerIdT; |
+// Use alignas(MaxCacheLineSize) to isolate variables/fields that |
+// might be contended while multithreading. Assumes the maximum cache |
+// line size is 64. |
+enum { |
+ MaxCacheLineSize = 64 |
+}; |
+// Use ICE_CACHELINE_BOUNDARY to force the next field in a declaration |
+// list to be aligned to the next cache line. |
+#define ICE_CACHELINE_BOUNDARY \ |
+ alignas(MaxCacheLineSize) struct {} |
+ |
// PNaCl is ILP32, so theoretically we should only need 32-bit offsets. |
typedef int32_t RelocOffsetT; |
enum { RelocAddrSize = 4 }; |
@@ -170,6 +184,37 @@ typedef uint32_t VerboseMask; |
typedef llvm::raw_ostream Ostream; |
typedef llvm::raw_fd_ostream Fdstream; |
+typedef std::mutex GlobalLockType; |
+ |
+enum ErrorCodes { |
+ EC_None = 0, |
+ EC_Args, |
+ EC_Bitcode, |
+ EC_Translation |
+}; |
+ |
+// Wrapper around std::error_code for allowing multiple errors to be |
+// folded into one. The current implementation keeps track of the |
+// first error, which is likely to be the most useful one, and this |
+// could be extended to e.g. collect a vector of errors. |
+class ErrorCode : public std::error_code { |
+ ErrorCode(const ErrorCode &) = delete; |
+ ErrorCode &operator=(const ErrorCode &) = delete; |
+ |
+public: |
+ ErrorCode() : std::error_code(), HasError(false) {} |
JF
2015/01/27 01:53:33
Calling the std::error_code ctor here doesn't seem
Jim Stichnoth
2015/01/27 05:35:11
Right - I was just trying to make it clear that th
|
+ void assign(ErrorCodes Code) { |
+ if (!HasError) { |
+ HasError = true; |
+ std::error_code::assign(Code, std::generic_category()); |
+ } |
+ } |
+ void assign(int Code) { assign(static_cast<ErrorCodes>(Code)); } |
+ |
+private: |
+ bool HasError; |
+}; |
+ |
// Reverse range adaptors written in terms of llvm::make_range(). |
template <typename T> |
llvm::iterator_range<typename T::const_reverse_iterator> |