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/globals.h" | 8 #include "src/globals.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 class OStream; | 13 class OStream; |
14 | 14 |
15 namespace compiler { | 15 namespace compiler { |
16 | 16 |
17 // Machine-level types and representations. | 17 // Machine-level types and representations. |
18 // TODO(titzer): Use the real type system instead of MachineType. | 18 // TODO(titzer): Use the real type system instead of MachineType. |
19 enum MachineType { | 19 enum MachineType { |
20 // Representations. | 20 // Representations. |
21 kRepBit = 1 << 0, | 21 kRepBit = 1 << 0, |
22 kRepWord8 = 1 << 1, | 22 kRepWord8 = 1 << 1, |
23 kRepWord16 = 1 << 2, | 23 kRepWord16 = 1 << 2, |
24 kRepWord32 = 1 << 3, | 24 kRepWord32 = 1 << 3, |
25 kRepWord64 = 1 << 4, | 25 kRepWord64 = 1 << 4, |
26 kRepFloat64 = 1 << 5, | 26 kRepFloat32 = 1 << 5, |
27 kRepTagged = 1 << 6, | 27 kRepFloat64 = 1 << 6, |
| 28 kRepTagged = 1 << 7, |
28 | 29 |
29 // Types. | 30 // Types. |
30 kTypeBool = 1 << 7, | 31 kTypeBool = 1 << 8, |
31 kTypeInt32 = 1 << 8, | 32 kTypeInt32 = 1 << 9, |
32 kTypeUint32 = 1 << 9, | 33 kTypeUint32 = 1 << 10, |
33 kTypeInt64 = 1 << 10, | 34 kTypeInt64 = 1 << 11, |
34 kTypeUint64 = 1 << 11, | 35 kTypeUint64 = 1 << 12, |
35 kTypeNumber = 1 << 12, | 36 kTypeNumber = 1 << 13, |
36 kTypeAny = 1 << 13 | 37 kTypeAny = 1 << 14 |
37 }; | 38 }; |
38 | 39 |
39 OStream& operator<<(OStream& os, const MachineType& type); | 40 OStream& operator<<(OStream& os, const MachineType& type); |
40 | 41 |
41 typedef uint16_t MachineTypeUnion; | 42 typedef uint16_t MachineTypeUnion; |
42 | 43 |
43 // Globally useful machine types and constants. | 44 // Globally useful machine types and constants. |
44 const MachineTypeUnion kRepMask = kRepBit | kRepWord8 | kRepWord16 | | 45 const MachineTypeUnion kRepMask = kRepBit | kRepWord8 | kRepWord16 | |
45 kRepWord32 | kRepWord64 | kRepFloat64 | | 46 kRepWord32 | kRepWord64 | kRepFloat32 | |
46 kRepTagged; | 47 kRepFloat64 | kRepTagged; |
47 const MachineTypeUnion kTypeMask = kTypeBool | kTypeInt32 | kTypeUint32 | | 48 const MachineTypeUnion kTypeMask = kTypeBool | kTypeInt32 | kTypeUint32 | |
48 kTypeInt64 | kTypeUint64 | kTypeNumber | | 49 kTypeInt64 | kTypeUint64 | kTypeNumber | |
49 kTypeAny; | 50 kTypeAny; |
50 | 51 |
51 const MachineType kMachNone = static_cast<MachineType>(0); | 52 const MachineType kMachNone = static_cast<MachineType>(0); |
| 53 const MachineType kMachFloat32 = |
| 54 static_cast<MachineType>(kRepFloat32 | kTypeNumber); |
52 const MachineType kMachFloat64 = | 55 const MachineType kMachFloat64 = |
53 static_cast<MachineType>(kRepFloat64 | kTypeNumber); | 56 static_cast<MachineType>(kRepFloat64 | kTypeNumber); |
54 const MachineType kMachInt8 = static_cast<MachineType>(kRepWord8 | kTypeInt32); | 57 const MachineType kMachInt8 = static_cast<MachineType>(kRepWord8 | kTypeInt32); |
55 const MachineType kMachUint8 = | 58 const MachineType kMachUint8 = |
56 static_cast<MachineType>(kRepWord8 | kTypeUint32); | 59 static_cast<MachineType>(kRepWord8 | kTypeUint32); |
57 const MachineType kMachInt16 = | 60 const MachineType kMachInt16 = |
58 static_cast<MachineType>(kRepWord16 | kTypeInt32); | 61 static_cast<MachineType>(kRepWord16 | kTypeInt32); |
59 const MachineType kMachUint16 = | 62 const MachineType kMachUint16 = |
60 static_cast<MachineType>(kRepWord16 | kTypeUint32); | 63 static_cast<MachineType>(kRepWord16 | kTypeUint32); |
61 const MachineType kMachInt32 = | 64 const MachineType kMachInt32 = |
(...skipping 23 matching lines...) Expand all Loading... |
85 | 88 |
86 // Gets the element size in bytes of the machine type. | 89 // Gets the element size in bytes of the machine type. |
87 inline int ElementSizeOf(MachineType machine_type) { | 90 inline int ElementSizeOf(MachineType machine_type) { |
88 switch (RepresentationOf(machine_type)) { | 91 switch (RepresentationOf(machine_type)) { |
89 case kRepBit: | 92 case kRepBit: |
90 case kRepWord8: | 93 case kRepWord8: |
91 return 1; | 94 return 1; |
92 case kRepWord16: | 95 case kRepWord16: |
93 return 2; | 96 return 2; |
94 case kRepWord32: | 97 case kRepWord32: |
| 98 case kRepFloat32: |
95 return 4; | 99 return 4; |
96 case kRepWord64: | 100 case kRepWord64: |
97 case kRepFloat64: | 101 case kRepFloat64: |
98 return 8; | 102 return 8; |
99 case kRepTagged: | 103 case kRepTagged: |
100 return kPointerSize; | 104 return kPointerSize; |
101 default: | 105 default: |
102 UNREACHABLE(); | 106 UNREACHABLE(); |
103 return kPointerSize; | 107 return kPointerSize; |
104 } | 108 } |
105 } | 109 } |
106 | 110 |
107 } // namespace compiler | 111 } // namespace compiler |
108 } // namespace internal | 112 } // namespace internal |
109 } // namespace v8 | 113 } // namespace v8 |
110 | 114 |
111 #endif // V8_COMPILER_MACHINE_TYPE_H_ | 115 #endif // V8_COMPILER_MACHINE_TYPE_H_ |
OLD | NEW |