Chromium Code Reviews| 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 // This file declares various useful types and classes that have widespread use | 10 // This file declares various useful types and classes that have widespread use |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 // AssignList, but this runs into issues with SFINAE. | 140 // AssignList, but this runs into issues with SFINAE. |
| 141 typedef InstList PhiList; | 141 typedef InstList PhiList; |
| 142 typedef InstList AssignList; | 142 typedef InstList AssignList; |
| 143 // VarList and NodeList are arena-allocated from the Cfg's allocator. | 143 // VarList and NodeList are arena-allocated from the Cfg's allocator. |
| 144 typedef std::vector<Variable *, CfgLocalAllocator<Variable *>> VarList; | 144 typedef std::vector<Variable *, CfgLocalAllocator<Variable *>> VarList; |
| 145 typedef std::vector<CfgNode *, CfgLocalAllocator<CfgNode *>> NodeList; | 145 typedef std::vector<CfgNode *, CfgLocalAllocator<CfgNode *>> NodeList; |
| 146 typedef std::vector<Constant *> ConstantList; | 146 typedef std::vector<Constant *> ConstantList; |
| 147 | 147 |
| 148 typedef std::vector<VariableDeclaration *> VariableDeclarationList; | 148 typedef std::vector<VariableDeclaration *> VariableDeclarationList; |
| 149 | 149 |
| 150 // SizeT is for holding small-ish limits like number of source | 150 /// SizeT is for holding small-ish limits like number of source |
| 151 // operands in an instruction. It is used instead of size_t (which | 151 /// operands in an instruction. It is used instead of size_t (which |
| 152 // may be 64-bits wide) when we want to save space. | 152 /// may be 64-bits wide) when we want to save space. |
| 153 typedef uint32_t SizeT; | 153 typedef uint32_t SizeT; |
| 154 | 154 |
| 155 // InstNumberT is for holding an instruction number. Instruction | 155 /// InstNumberT is for holding an instruction number. Instruction |
| 156 // numbers are used for representing Variable live ranges. | 156 /// numbers are used for representing Variable live ranges. |
| 157 typedef int32_t InstNumberT; | 157 typedef int32_t InstNumberT; |
| 158 | 158 |
| 159 // A LiveBeginEndMapEntry maps a Variable::Number value to an | 159 /// A LiveBeginEndMapEntry maps a Variable::Number value to an |
| 160 // Inst::Number value, giving the instruction number that begins or | 160 /// Inst::Number value, giving the instruction number that begins or |
| 161 // ends a variable's live range. | 161 /// ends a variable's live range. |
| 162 typedef std::pair<SizeT, InstNumberT> LiveBeginEndMapEntry; | 162 typedef std::pair<SizeT, InstNumberT> LiveBeginEndMapEntry; |
| 163 typedef std::vector<LiveBeginEndMapEntry, | 163 typedef std::vector<LiveBeginEndMapEntry, |
| 164 CfgLocalAllocator<LiveBeginEndMapEntry>> LiveBeginEndMap; | 164 CfgLocalAllocator<LiveBeginEndMapEntry>> LiveBeginEndMap; |
| 165 typedef llvm::BitVector LivenessBV; | 165 typedef llvm::BitVector LivenessBV; |
| 166 | 166 |
| 167 typedef uint32_t TimerStackIdT; | 167 typedef uint32_t TimerStackIdT; |
| 168 typedef uint32_t TimerIdT; | 168 typedef uint32_t TimerIdT; |
| 169 | 169 |
| 170 // Use alignas(MaxCacheLineSize) to isolate variables/fields that | 170 /// Use alignas(MaxCacheLineSize) to isolate variables/fields that |
| 171 // might be contended while multithreading. Assumes the maximum cache | 171 /// might be contended while multithreading. Assumes the maximum cache |
| 172 // line size is 64. | 172 /// line size is 64. |
| 173 enum { MaxCacheLineSize = 64 }; | 173 enum { MaxCacheLineSize = 64 }; |
| 174 // Use ICE_CACHELINE_BOUNDARY to force the next field in a declaration | 174 // Use ICE_CACHELINE_BOUNDARY to force the next field in a declaration |
| 175 // list to be aligned to the next cache line. | 175 // list to be aligned to the next cache line. |
| 176 // Note: zero is added to work around the following GCC 4.8 bug (fixed in 4.9): | 176 // Note: zero is added to work around the following GCC 4.8 bug (fixed in 4.9): |
| 177 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55382 | 177 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55382 |
| 178 #define ICE_CACHELINE_BOUNDARY \ | 178 #define ICE_CACHELINE_BOUNDARY \ |
| 179 __attribute__((aligned(MaxCacheLineSize + 0))) int : 0 | 179 __attribute__((aligned(MaxCacheLineSize + 0))) int : 0 |
| 180 | 180 |
| 181 // PNaCl is ILP32, so theoretically we should only need 32-bit offsets. | 181 /// PNaCl is ILP32, so theoretically we should only need 32-bit offsets. |
| 182 typedef int32_t RelocOffsetT; | 182 typedef int32_t RelocOffsetT; |
| 183 enum { RelocAddrSize = 4 }; | 183 enum { RelocAddrSize = 4 }; |
| 184 | 184 |
| 185 enum LivenessMode { | 185 enum LivenessMode { |
| 186 // Basic version of live-range-end calculation. Marks the last uses | 186 /// Basic version of live-range-end calculation. Marks the last uses |
| 187 // of variables based on dataflow analysis. Records the set of | 187 /// of variables based on dataflow analysis. Records the set of |
| 188 // live-in and live-out variables for each block. Identifies and | 188 /// live-in and live-out variables for each block. Identifies and |
| 189 // deletes dead instructions (primarily stores). | 189 /// deletes dead instructions (primarily stores). |
| 190 Liveness_Basic, | 190 Liveness_Basic, |
| 191 | 191 |
| 192 // In addition to Liveness_Basic, also calculate the complete | 192 /// In addition to Liveness_Basic, also calculate the complete |
| 193 // live range for each variable in a form suitable for interference | 193 /// live range for each variable in a form suitable for interference |
| 194 // calculation and register allocation. | 194 /// calculation and register allocation. |
| 195 Liveness_Intervals | 195 Liveness_Intervals |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 enum RegAllocKind { | 198 enum RegAllocKind { |
| 199 RAK_Global, // full, global register allocation | 199 RAK_Global, /// full, global register allocation |
| 200 RAK_InfOnly // allocation only for infinite-weight Variables | 200 RAK_InfOnly /// allocation only for infinite-weight Variables |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 enum VerboseItem { | 203 enum VerboseItem { |
| 204 IceV_None = 0, | 204 IceV_None = 0, |
| 205 IceV_Instructions = 1 << 0, | 205 IceV_Instructions = 1 << 0, |
| 206 IceV_Deleted = 1 << 1, | 206 IceV_Deleted = 1 << 1, |
| 207 IceV_InstNumbers = 1 << 2, | 207 IceV_InstNumbers = 1 << 2, |
| 208 IceV_Preds = 1 << 3, | 208 IceV_Preds = 1 << 3, |
| 209 IceV_Succs = 1 << 4, | 209 IceV_Succs = 1 << 4, |
| 210 IceV_Liveness = 1 << 5, | 210 IceV_Liveness = 1 << 5, |
| 211 IceV_RegOrigins = 1 << 6, | 211 IceV_RegOrigins = 1 << 6, |
| 212 IceV_LinearScan = 1 << 7, | 212 IceV_LinearScan = 1 << 7, |
| 213 IceV_Frame = 1 << 8, | 213 IceV_Frame = 1 << 8, |
| 214 IceV_AddrOpt = 1 << 9, | 214 IceV_AddrOpt = 1 << 9, |
| 215 IceV_Random = 1 << 10, | 215 IceV_Random = 1 << 10, |
| 216 IceV_Folding = 1 << 11, | 216 IceV_Folding = 1 << 11, |
| 217 IceV_RMW = 1 << 12, | 217 IceV_RMW = 1 << 12, |
| 218 IceV_All = ~IceV_None, | 218 IceV_All = ~IceV_None, |
| 219 IceV_Most = IceV_All & ~IceV_LinearScan | 219 IceV_Most = IceV_All & ~IceV_LinearScan |
| 220 }; | 220 }; |
| 221 typedef uint32_t VerboseMask; | 221 typedef uint32_t VerboseMask; |
| 222 | 222 |
| 223 enum FileType { | 223 enum FileType { |
| 224 FT_Elf, // ELF .o file | 224 FT_Elf, /// ELF .o file |
| 225 FT_Asm, // Assembly .s file | 225 FT_Asm, /// Assembly .s file |
| 226 FT_Iasm // "Integrated assembler" .byte-style .s file | 226 FT_Iasm /// "Integrated assembler" .byte-style .s file |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 typedef llvm::raw_ostream Ostream; | 229 typedef llvm::raw_ostream Ostream; |
| 230 typedef llvm::raw_fd_ostream Fdstream; | 230 typedef llvm::raw_fd_ostream Fdstream; |
| 231 | 231 |
| 232 typedef std::mutex GlobalLockType; | 232 typedef std::mutex GlobalLockType; |
| 233 | 233 |
| 234 enum ErrorCodes { EC_None = 0, EC_Args, EC_Bitcode, EC_Translation }; | 234 enum ErrorCodes { EC_None = 0, EC_Args, EC_Bitcode, EC_Translation }; |
| 235 | 235 |
| 236 // Wrapper around std::error_code for allowing multiple errors to be | 236 /// Wrapper around std::error_code for allowing multiple errors to be |
| 237 // folded into one. The current implementation keeps track of the | 237 /// folded into one. The current implementation keeps track of the |
| 238 // first error, which is likely to be the most useful one, and this | 238 /// first error, which is likely to be the most useful one, and this |
| 239 // could be extended to e.g. collect a vector of errors. | 239 /// could be extended to e.g. collect a vector of errors. |
| 240 class ErrorCode : public std::error_code { | 240 class ErrorCode : public std::error_code { |
| 241 ErrorCode(const ErrorCode &) = delete; | 241 ErrorCode(const ErrorCode &) = delete; |
| 242 ErrorCode &operator=(const ErrorCode &) = delete; | 242 ErrorCode &operator=(const ErrorCode &) = delete; |
| 243 | 243 |
| 244 public: | 244 public: |
| 245 ErrorCode() = default; | 245 ErrorCode() = default; |
| 246 void assign(ErrorCodes Code) { | 246 void assign(ErrorCodes Code) { |
| 247 if (!HasError) { | 247 if (!HasError) { |
| 248 HasError = true; | 248 HasError = true; |
| 249 std::error_code::assign(Code, std::generic_category()); | 249 std::error_code::assign(Code, std::generic_category()); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 void assign(int Code) { assign(static_cast<ErrorCodes>(Code)); } | 252 void assign(int Code) { assign(static_cast<ErrorCodes>(Code)); } |
| 253 | 253 |
| 254 private: | 254 private: |
| 255 bool HasError = false; | 255 bool HasError = false; |
| 256 }; | 256 }; |
| 257 | 257 |
| 258 // Reverse range adaptors written in terms of llvm::make_range(). | 258 /// Reverse range adaptors written in terms of llvm::make_range(). |
| 259 template <typename T> | 259 template <typename T> |
| 260 llvm::iterator_range<typename T::const_reverse_iterator> | 260 llvm::iterator_range<typename T::const_reverse_iterator> |
| 261 reverse_range(const T &Container) { | 261 reverse_range(const T &Container) { |
| 262 return llvm::make_range(Container.rbegin(), Container.rend()); | 262 return llvm::make_range(Container.rbegin(), Container.rend()); |
| 263 } | 263 } |
| 264 template <typename T> | 264 template <typename T> |
| 265 llvm::iterator_range<typename T::reverse_iterator> reverse_range(T &Container) { | 265 llvm::iterator_range<typename T::reverse_iterator> reverse_range(T &Container) { |
| 266 return llvm::make_range(Container.rbegin(), Container.rend()); | 266 return llvm::make_range(Container.rbegin(), Container.rend()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 // Options for pooling and randomization of immediates | 269 /// Options for pooling and randomization of immediates |
|
jvoung (off chromium)
2015/06/30 22:05:48
If you're up for it while you're here, could add a
ascull
2015/07/06 19:29:08
Done.
| |
| 270 enum RandomizeAndPoolImmediatesEnum { RPI_None, RPI_Randomize, RPI_Pool }; | 270 enum RandomizeAndPoolImmediatesEnum { RPI_None, RPI_Randomize, RPI_Pool }; |
| 271 | 271 |
| 272 } // end of namespace Ice | 272 } // end of namespace Ice |
| 273 | 273 |
| 274 #endif // SUBZERO_SRC_ICEDEFS_H | 274 #endif // SUBZERO_SRC_ICEDEFS_H |
| OLD | NEW |