OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_MACHINE_TYPE_H_ | 5 #ifndef V8_MACHINE_TYPE_H_ |
6 #define V8_MACHINE_TYPE_H_ | 6 #define V8_MACHINE_TYPE_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 kWord16, | 22 kWord16, |
23 kWord32, | 23 kWord32, |
24 kWord64, | 24 kWord64, |
25 kTaggedSigned, | 25 kTaggedSigned, |
26 kTaggedPointer, | 26 kTaggedPointer, |
27 kTagged, | 27 kTagged, |
28 // FP representations must be last, and in order of increasing size. | 28 // FP representations must be last, and in order of increasing size. |
29 kFloat32, | 29 kFloat32, |
30 kFloat64, | 30 kFloat64, |
31 kSimd128, | 31 kSimd128, |
| 32 kSimdBool4, // SIMD boolean vector types. |
| 33 kSimdBool8, |
| 34 kSimdBool16, |
32 kFirstFPRepresentation = kFloat32, | 35 kFirstFPRepresentation = kFloat32, |
33 kLastRepresentation = kSimd128 | 36 kLastRepresentation = kSimdBool16 |
34 }; | 37 }; |
35 | 38 |
36 static_assert(static_cast<int>(MachineRepresentation::kLastRepresentation) < | 39 static_assert(static_cast<int>(MachineRepresentation::kLastRepresentation) < |
37 kIntSize * kBitsPerByte, | 40 kIntSize * kBitsPerByte, |
38 "Bit masks of MachineRepresentation should fit in an int"); | 41 "Bit masks of MachineRepresentation should fit in an int"); |
39 | 42 |
40 const char* MachineReprToString(MachineRepresentation); | 43 const char* MachineReprToString(MachineRepresentation); |
41 | 44 |
42 enum class MachineSemantic { | 45 enum class MachineSemantic { |
43 kNone, | 46 kNone, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 return MachineType(MachineRepresentation::kFloat32, | 123 return MachineType(MachineRepresentation::kFloat32, |
121 MachineSemantic::kNumber); | 124 MachineSemantic::kNumber); |
122 } | 125 } |
123 static MachineType Float64() { | 126 static MachineType Float64() { |
124 return MachineType(MachineRepresentation::kFloat64, | 127 return MachineType(MachineRepresentation::kFloat64, |
125 MachineSemantic::kNumber); | 128 MachineSemantic::kNumber); |
126 } | 129 } |
127 static MachineType Simd128() { | 130 static MachineType Simd128() { |
128 return MachineType(MachineRepresentation::kSimd128, MachineSemantic::kNone); | 131 return MachineType(MachineRepresentation::kSimd128, MachineSemantic::kNone); |
129 } | 132 } |
| 133 static MachineType SimdBool4() { |
| 134 return MachineType(MachineRepresentation::kSimdBool4, |
| 135 MachineSemantic::kNone); |
| 136 } |
| 137 static MachineType SimdBool8() { |
| 138 return MachineType(MachineRepresentation::kSimdBool8, |
| 139 MachineSemantic::kNone); |
| 140 } |
| 141 static MachineType SimdBool16() { |
| 142 return MachineType(MachineRepresentation::kSimdBool16, |
| 143 MachineSemantic::kNone); |
| 144 } |
130 static MachineType Pointer() { | 145 static MachineType Pointer() { |
131 return MachineType(PointerRepresentation(), MachineSemantic::kNone); | 146 return MachineType(PointerRepresentation(), MachineSemantic::kNone); |
132 } | 147 } |
133 static MachineType TaggedPointer() { | 148 static MachineType TaggedPointer() { |
134 return MachineType(MachineRepresentation::kTaggedPointer, | 149 return MachineType(MachineRepresentation::kTaggedPointer, |
135 MachineSemantic::kAny); | 150 MachineSemantic::kAny); |
136 } | 151 } |
137 static MachineType TaggedSigned() { | 152 static MachineType TaggedSigned() { |
138 return MachineType(MachineRepresentation::kTaggedSigned, | 153 return MachineType(MachineRepresentation::kTaggedSigned, |
139 MachineSemantic::kInt32); | 154 MachineSemantic::kInt32); |
(...skipping 26 matching lines...) Expand all Loading... |
166 } | 181 } |
167 static MachineType RepFloat32() { | 182 static MachineType RepFloat32() { |
168 return MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone); | 183 return MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone); |
169 } | 184 } |
170 static MachineType RepFloat64() { | 185 static MachineType RepFloat64() { |
171 return MachineType(MachineRepresentation::kFloat64, MachineSemantic::kNone); | 186 return MachineType(MachineRepresentation::kFloat64, MachineSemantic::kNone); |
172 } | 187 } |
173 static MachineType RepSimd128() { | 188 static MachineType RepSimd128() { |
174 return MachineType(MachineRepresentation::kSimd128, MachineSemantic::kNone); | 189 return MachineType(MachineRepresentation::kSimd128, MachineSemantic::kNone); |
175 } | 190 } |
| 191 static MachineType RepSimdBool4() { |
| 192 return MachineType(MachineRepresentation::kSimdBool4, |
| 193 MachineSemantic::kNone); |
| 194 } |
| 195 static MachineType RepSimdBool8() { |
| 196 return MachineType(MachineRepresentation::kSimdBool8, |
| 197 MachineSemantic::kNone); |
| 198 } |
| 199 static MachineType RepSimdBool16() { |
| 200 return MachineType(MachineRepresentation::kSimdBool16, |
| 201 MachineSemantic::kNone); |
| 202 } |
176 static MachineType RepTagged() { | 203 static MachineType RepTagged() { |
177 return MachineType(MachineRepresentation::kTagged, MachineSemantic::kNone); | 204 return MachineType(MachineRepresentation::kTagged, MachineSemantic::kNone); |
178 } | 205 } |
179 static MachineType RepBit() { | 206 static MachineType RepBit() { |
180 return MachineType(MachineRepresentation::kBit, MachineSemantic::kNone); | 207 return MachineType(MachineRepresentation::kBit, MachineSemantic::kNone); |
181 } | 208 } |
182 | 209 |
183 static MachineType TypeForRepresentation(const MachineRepresentation& rep, | 210 static MachineType TypeForRepresentation(const MachineRepresentation& rep, |
184 bool isSigned = true) { | 211 bool isSigned = true) { |
185 switch (rep) { | 212 switch (rep) { |
186 case MachineRepresentation::kNone: | 213 case MachineRepresentation::kNone: |
187 return MachineType::None(); | 214 return MachineType::None(); |
188 case MachineRepresentation::kBit: | 215 case MachineRepresentation::kBit: |
189 return MachineType::Bool(); | 216 return MachineType::Bool(); |
190 case MachineRepresentation::kWord8: | 217 case MachineRepresentation::kWord8: |
191 return isSigned ? MachineType::Int8() : MachineType::Uint8(); | 218 return isSigned ? MachineType::Int8() : MachineType::Uint8(); |
192 case MachineRepresentation::kWord16: | 219 case MachineRepresentation::kWord16: |
193 return isSigned ? MachineType::Int16() : MachineType::Uint16(); | 220 return isSigned ? MachineType::Int16() : MachineType::Uint16(); |
194 case MachineRepresentation::kWord32: | 221 case MachineRepresentation::kWord32: |
195 return isSigned ? MachineType::Int32() : MachineType::Uint32(); | 222 return isSigned ? MachineType::Int32() : MachineType::Uint32(); |
196 case MachineRepresentation::kWord64: | 223 case MachineRepresentation::kWord64: |
197 return isSigned ? MachineType::Int64() : MachineType::Uint64(); | 224 return isSigned ? MachineType::Int64() : MachineType::Uint64(); |
198 case MachineRepresentation::kFloat32: | 225 case MachineRepresentation::kFloat32: |
199 return MachineType::Float32(); | 226 return MachineType::Float32(); |
200 case MachineRepresentation::kFloat64: | 227 case MachineRepresentation::kFloat64: |
201 return MachineType::Float64(); | 228 return MachineType::Float64(); |
202 case MachineRepresentation::kSimd128: | 229 case MachineRepresentation::kSimd128: |
203 return MachineType::Simd128(); | 230 return MachineType::Simd128(); |
| 231 case MachineRepresentation::kSimdBool4: |
| 232 return MachineType::SimdBool4(); |
| 233 case MachineRepresentation::kSimdBool8: |
| 234 return MachineType::SimdBool8(); |
| 235 case MachineRepresentation::kSimdBool16: |
| 236 return MachineType::SimdBool16(); |
204 case MachineRepresentation::kTagged: | 237 case MachineRepresentation::kTagged: |
205 return MachineType::AnyTagged(); | 238 return MachineType::AnyTagged(); |
206 case MachineRepresentation::kTaggedSigned: | 239 case MachineRepresentation::kTaggedSigned: |
207 return MachineType::TaggedSigned(); | 240 return MachineType::TaggedSigned(); |
208 case MachineRepresentation::kTaggedPointer: | 241 case MachineRepresentation::kTaggedPointer: |
209 return MachineType::TaggedPointer(); | 242 return MachineType::TaggedPointer(); |
210 default: | 243 default: |
211 UNREACHABLE(); | 244 UNREACHABLE(); |
212 return MachineType::None(); | 245 return MachineType::None(); |
213 } | 246 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 UNREACHABLE(); | 309 UNREACHABLE(); |
277 return -1; | 310 return -1; |
278 } | 311 } |
279 | 312 |
280 typedef Signature<MachineType> MachineSignature; | 313 typedef Signature<MachineType> MachineSignature; |
281 | 314 |
282 } // namespace internal | 315 } // namespace internal |
283 } // namespace v8 | 316 } // namespace v8 |
284 | 317 |
285 #endif // V8_MACHINE_TYPE_H_ | 318 #endif // V8_MACHINE_TYPE_H_ |
OLD | NEW |