OLD | NEW |
---|---|
1 //===- subzero/src/IceDefs.h - Common Subzero declaraions -------*- C++ -*-===// | 1 //===- subzero/src/IceDefs.h - Common Subzero declaraions -------*- 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 // This file declares various useful types and classes that have | 10 // This file declares various useful types and classes that have |
11 // widespread use across Subzero. Every Subzero source file is | 11 // widespread use across Subzero. Every Subzero source file is |
12 // expected to include IceDefs.h. | 12 // expected to include IceDefs.h. |
13 // | 13 // |
14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
15 | 15 |
16 #ifndef SUBZERO_SRC_ICEDEFS_H | 16 #ifndef SUBZERO_SRC_ICEDEFS_H |
17 #define SUBZERO_SRC_ICEDEFS_H | 17 #define SUBZERO_SRC_ICEDEFS_H |
18 | 18 |
19 #include <cassert> | 19 #include <cassert> |
20 #include <cstdint> | 20 #include <cstdint> |
21 #include <cstdio> // snprintf | 21 #include <cstdio> // snprintf |
22 #include <functional> // std::less | 22 #include <functional> // std::less |
23 #include <limits> | 23 #include <limits> |
24 #include <list> | 24 #include <list> |
25 #include <map> | 25 #include <map> |
26 #include <mutex> | |
26 #include <string> | 27 #include <string> |
28 #include <system_error> | |
27 #include <vector> | 29 #include <vector> |
28 #include "llvm/ADT/ArrayRef.h" | 30 #include "llvm/ADT/ArrayRef.h" |
29 #include "llvm/ADT/BitVector.h" | 31 #include "llvm/ADT/BitVector.h" |
30 #include "llvm/ADT/ilist.h" | 32 #include "llvm/ADT/ilist.h" |
31 #include "llvm/ADT/ilist_node.h" | 33 #include "llvm/ADT/ilist_node.h" |
32 #include "llvm/ADT/iterator_range.h" | 34 #include "llvm/ADT/iterator_range.h" |
33 #include "llvm/ADT/SmallBitVector.h" | 35 #include "llvm/ADT/SmallBitVector.h" |
34 #include "llvm/ADT/SmallVector.h" | 36 #include "llvm/ADT/SmallVector.h" |
35 #include "llvm/ADT/STLExtras.h" | 37 #include "llvm/ADT/STLExtras.h" |
36 #include "llvm/Support/Allocator.h" | 38 #include "llvm/Support/Allocator.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
58 class FunctionDeclaration; | 60 class FunctionDeclaration; |
59 class GlobalContext; | 61 class GlobalContext; |
60 class GlobalDeclaration; | 62 class GlobalDeclaration; |
61 class Inst; | 63 class Inst; |
62 class InstAssign; | 64 class InstAssign; |
63 class InstPhi; | 65 class InstPhi; |
64 class InstTarget; | 66 class InstTarget; |
65 class LiveRange; | 67 class LiveRange; |
66 class Liveness; | 68 class Liveness; |
67 class Operand; | 69 class Operand; |
70 class TargetGlobalLowering; | |
68 class TargetLowering; | 71 class TargetLowering; |
69 class Variable; | 72 class Variable; |
70 class VariableDeclaration; | 73 class VariableDeclaration; |
71 class VariablesMetadata; | 74 class VariablesMetadata; |
72 | 75 |
73 template <size_t SlabSize = 1024 * 1024> | 76 template <size_t SlabSize = 1024 * 1024> |
74 using ArenaAllocator = | 77 using ArenaAllocator = |
75 llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, SlabSize>; | 78 llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, SlabSize>; |
76 | 79 |
77 ArenaAllocator<> *getCurrentCfgAllocator(); | 80 ArenaAllocator<> *getCurrentCfgAllocator(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 // Inst::Number value, giving the instruction number that begins or | 123 // Inst::Number value, giving the instruction number that begins or |
121 // ends a variable's live range. | 124 // ends a variable's live range. |
122 typedef std::pair<SizeT, InstNumberT> LiveBeginEndMapEntry; | 125 typedef std::pair<SizeT, InstNumberT> LiveBeginEndMapEntry; |
123 typedef std::vector<LiveBeginEndMapEntry, | 126 typedef std::vector<LiveBeginEndMapEntry, |
124 CfgLocalAllocator<LiveBeginEndMapEntry>> LiveBeginEndMap; | 127 CfgLocalAllocator<LiveBeginEndMapEntry>> LiveBeginEndMap; |
125 typedef llvm::BitVector LivenessBV; | 128 typedef llvm::BitVector LivenessBV; |
126 | 129 |
127 typedef uint32_t TimerStackIdT; | 130 typedef uint32_t TimerStackIdT; |
128 typedef uint32_t TimerIdT; | 131 typedef uint32_t TimerIdT; |
129 | 132 |
133 // Use alignas(MaxCacheLineSize) to isolate variables/fields that | |
134 // might be contended while multithreading. Assumes the maximum cache | |
135 // line size is 64. | |
136 enum { | |
137 MaxCacheLineSize = 64 | |
138 }; | |
139 // Use ICE_CACHELINE_BOUNDARY to force the next field in a declaration | |
140 // list to be aligned to the next cache line. | |
141 #define ICE_CACHELINE_BOUNDARY \ | |
142 alignas(MaxCacheLineSize) struct {} | |
143 | |
130 // PNaCl is ILP32, so theoretically we should only need 32-bit offsets. | 144 // PNaCl is ILP32, so theoretically we should only need 32-bit offsets. |
131 typedef int32_t RelocOffsetT; | 145 typedef int32_t RelocOffsetT; |
132 enum { RelocAddrSize = 4 }; | 146 enum { RelocAddrSize = 4 }; |
133 | 147 |
134 enum LivenessMode { | 148 enum LivenessMode { |
135 // Basic version of live-range-end calculation. Marks the last uses | 149 // Basic version of live-range-end calculation. Marks the last uses |
136 // of variables based on dataflow analysis. Records the set of | 150 // of variables based on dataflow analysis. Records the set of |
137 // live-in and live-out variables for each block. Identifies and | 151 // live-in and live-out variables for each block. Identifies and |
138 // deletes dead instructions (primarily stores). | 152 // deletes dead instructions (primarily stores). |
139 Liveness_Basic, | 153 Liveness_Basic, |
(...skipping 23 matching lines...) Expand all Loading... | |
163 IceV_AddrOpt = 1 << 9, | 177 IceV_AddrOpt = 1 << 9, |
164 IceV_Random = 1 << 10, | 178 IceV_Random = 1 << 10, |
165 IceV_All = ~IceV_None, | 179 IceV_All = ~IceV_None, |
166 IceV_Most = IceV_All & ~IceV_LinearScan | 180 IceV_Most = IceV_All & ~IceV_LinearScan |
167 }; | 181 }; |
168 typedef uint32_t VerboseMask; | 182 typedef uint32_t VerboseMask; |
169 | 183 |
170 typedef llvm::raw_ostream Ostream; | 184 typedef llvm::raw_ostream Ostream; |
171 typedef llvm::raw_fd_ostream Fdstream; | 185 typedef llvm::raw_fd_ostream Fdstream; |
172 | 186 |
187 typedef std::mutex GlobalLockType; | |
188 | |
189 enum ErrorCodes { | |
190 EC_None = 0, | |
191 EC_Args, | |
192 EC_Bitcode, | |
193 EC_Translation | |
194 }; | |
195 | |
196 // Wrapper around std::error_code for allowing multiple errors to be | |
197 // folded into one. The current implementation keeps track of the | |
198 // first error, which is likely to be the most useful one, and this | |
199 // could be extended to e.g. collect a vector of errors. | |
200 class ErrorCode : public std::error_code { | |
201 ErrorCode(const ErrorCode &) = delete; | |
202 ErrorCode &operator=(const ErrorCode &) = delete; | |
203 | |
204 public: | |
205 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
| |
206 void assign(ErrorCodes Code) { | |
207 if (!HasError) { | |
208 HasError = true; | |
209 std::error_code::assign(Code, std::generic_category()); | |
210 } | |
211 } | |
212 void assign(int Code) { assign(static_cast<ErrorCodes>(Code)); } | |
213 | |
214 private: | |
215 bool HasError; | |
216 }; | |
217 | |
173 // Reverse range adaptors written in terms of llvm::make_range(). | 218 // Reverse range adaptors written in terms of llvm::make_range(). |
174 template <typename T> | 219 template <typename T> |
175 llvm::iterator_range<typename T::const_reverse_iterator> | 220 llvm::iterator_range<typename T::const_reverse_iterator> |
176 reverse_range(const T &Container) { | 221 reverse_range(const T &Container) { |
177 return llvm::make_range(Container.rbegin(), Container.rend()); | 222 return llvm::make_range(Container.rbegin(), Container.rend()); |
178 } | 223 } |
179 template <typename T> | 224 template <typename T> |
180 llvm::iterator_range<typename T::reverse_iterator> reverse_range(T &Container) { | 225 llvm::iterator_range<typename T::reverse_iterator> reverse_range(T &Container) { |
181 return llvm::make_range(Container.rbegin(), Container.rend()); | 226 return llvm::make_range(Container.rbegin(), Container.rend()); |
182 } | 227 } |
183 | 228 |
184 } // end of namespace Ice | 229 } // end of namespace Ice |
185 | 230 |
186 #endif // SUBZERO_SRC_ICEDEFS_H | 231 #endif // SUBZERO_SRC_ICEDEFS_H |
OLD | NEW |