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_COMPILER_MACHINE_TYPE_H_ | 5 #ifndef V8_COMPILER_MACHINE_TYPE_H_ |
6 #define V8_COMPILER_MACHINE_TYPE_H_ | 6 #define V8_COMPILER_MACHINE_TYPE_H_ |
7 | 7 |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/globals.h" | 9 #include "src/globals.h" |
10 #include "src/zone.h" | 10 #include "src/zone.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 kRepFloat64 = 1 << 6, | 29 kRepFloat64 = 1 << 6, |
30 kRepTagged = 1 << 7, | 30 kRepTagged = 1 << 7, |
31 | 31 |
32 // Types. | 32 // Types. |
33 kTypeBool = 1 << 8, | 33 kTypeBool = 1 << 8, |
34 kTypeInt32 = 1 << 9, | 34 kTypeInt32 = 1 << 9, |
35 kTypeUint32 = 1 << 10, | 35 kTypeUint32 = 1 << 10, |
36 kTypeInt64 = 1 << 11, | 36 kTypeInt64 = 1 << 11, |
37 kTypeUint64 = 1 << 12, | 37 kTypeUint64 = 1 << 12, |
38 kTypeNumber = 1 << 13, | 38 kTypeNumber = 1 << 13, |
39 kTypeAny = 1 << 14 | 39 kTypeAny = 1 << 14, |
| 40 |
| 41 // Machine types. |
| 42 kMachNone = 0, |
| 43 kMachFloat32 = kRepFloat32 | kTypeNumber, |
| 44 kMachFloat64 = kRepFloat64 | kTypeNumber, |
| 45 kMachInt8 = kRepWord8 | kTypeInt32, |
| 46 kMachUint8 = kRepWord8 | kTypeUint32, |
| 47 kMachInt16 = kRepWord16 | kTypeInt32, |
| 48 kMachUint16 = kRepWord16 | kTypeUint32, |
| 49 kMachInt32 = kRepWord32 | kTypeInt32, |
| 50 kMachUint32 = kRepWord32 | kTypeUint32, |
| 51 kMachInt64 = kRepWord64 | kTypeInt64, |
| 52 kMachUint64 = kRepWord64 | kTypeUint64, |
| 53 kMachPtr = (kPointerSize == 4) ? kRepWord32 : kRepWord64, |
| 54 kMachAnyTagged = kRepTagged | kTypeAny |
40 }; | 55 }; |
41 | 56 |
42 OStream& operator<<(OStream& os, const MachineType& type); | 57 OStream& operator<<(OStream& os, const MachineType& type); |
43 | 58 |
44 typedef uint16_t MachineTypeUnion; | 59 typedef uint16_t MachineTypeUnion; |
45 | 60 |
46 // Globally useful machine types and constants. | 61 // Globally useful machine types and constants. |
47 const MachineTypeUnion kRepMask = kRepBit | kRepWord8 | kRepWord16 | | 62 const MachineTypeUnion kRepMask = kRepBit | kRepWord8 | kRepWord16 | |
48 kRepWord32 | kRepWord64 | kRepFloat32 | | 63 kRepWord32 | kRepWord64 | kRepFloat32 | |
49 kRepFloat64 | kRepTagged; | 64 kRepFloat64 | kRepTagged; |
50 const MachineTypeUnion kTypeMask = kTypeBool | kTypeInt32 | kTypeUint32 | | 65 const MachineTypeUnion kTypeMask = kTypeBool | kTypeInt32 | kTypeUint32 | |
51 kTypeInt64 | kTypeUint64 | kTypeNumber | | 66 kTypeInt64 | kTypeUint64 | kTypeNumber | |
52 kTypeAny; | 67 kTypeAny; |
53 | 68 |
54 const MachineType kMachNone = static_cast<MachineType>(0); | |
55 const MachineType kMachFloat32 = | |
56 static_cast<MachineType>(kRepFloat32 | kTypeNumber); | |
57 const MachineType kMachFloat64 = | |
58 static_cast<MachineType>(kRepFloat64 | kTypeNumber); | |
59 const MachineType kMachInt8 = static_cast<MachineType>(kRepWord8 | kTypeInt32); | |
60 const MachineType kMachUint8 = | |
61 static_cast<MachineType>(kRepWord8 | kTypeUint32); | |
62 const MachineType kMachInt16 = | |
63 static_cast<MachineType>(kRepWord16 | kTypeInt32); | |
64 const MachineType kMachUint16 = | |
65 static_cast<MachineType>(kRepWord16 | kTypeUint32); | |
66 const MachineType kMachInt32 = | |
67 static_cast<MachineType>(kRepWord32 | kTypeInt32); | |
68 const MachineType kMachUint32 = | |
69 static_cast<MachineType>(kRepWord32 | kTypeUint32); | |
70 const MachineType kMachInt64 = | |
71 static_cast<MachineType>(kRepWord64 | kTypeInt64); | |
72 const MachineType kMachUint64 = | |
73 static_cast<MachineType>(kRepWord64 | kTypeUint64); | |
74 const MachineType kMachPtr = kPointerSize == 4 ? kRepWord32 : kRepWord64; | |
75 const MachineType kMachAnyTagged = | |
76 static_cast<MachineType>(kRepTagged | kTypeAny); | |
77 | |
78 // Gets only the type of the given type. | 69 // Gets only the type of the given type. |
79 inline MachineType TypeOf(MachineType machine_type) { | 70 inline MachineType TypeOf(MachineType machine_type) { |
80 int result = machine_type & kTypeMask; | 71 int result = machine_type & kTypeMask; |
81 return static_cast<MachineType>(result); | 72 return static_cast<MachineType>(result); |
82 } | 73 } |
83 | 74 |
84 // Gets only the representation of the given type. | 75 // Gets only the representation of the given type. |
85 inline MachineType RepresentationOf(MachineType machine_type) { | 76 inline MachineType RepresentationOf(MachineType machine_type) { |
86 int result = machine_type & kRepMask; | 77 int result = machine_type & kRepMask; |
87 CHECK(base::bits::IsPowerOfTwo32(result)); | 78 CHECK(base::bits::IsPowerOfTwo32(result)); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 size_t parameter_count_; | 164 size_t parameter_count_; |
174 T* reps_; | 165 T* reps_; |
175 }; | 166 }; |
176 | 167 |
177 typedef Signature<MachineType> MachineSignature; | 168 typedef Signature<MachineType> MachineSignature; |
178 } // namespace compiler | 169 } // namespace compiler |
179 } // namespace internal | 170 } // namespace internal |
180 } // namespace v8 | 171 } // namespace v8 |
181 | 172 |
182 #endif // V8_COMPILER_MACHINE_TYPE_H_ | 173 #endif // V8_COMPILER_MACHINE_TYPE_H_ |
OLD | NEW |