| 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 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const MachineType kMachUint32 = | 63 const MachineType kMachUint32 = |
| 64 static_cast<MachineType>(kRepWord32 | kTypeUint32); | 64 static_cast<MachineType>(kRepWord32 | kTypeUint32); |
| 65 const MachineType kMachInt64 = | 65 const MachineType kMachInt64 = |
| 66 static_cast<MachineType>(kRepWord64 | kTypeInt64); | 66 static_cast<MachineType>(kRepWord64 | kTypeInt64); |
| 67 const MachineType kMachUint64 = | 67 const MachineType kMachUint64 = |
| 68 static_cast<MachineType>(kRepWord64 | kTypeUint64); | 68 static_cast<MachineType>(kRepWord64 | kTypeUint64); |
| 69 const MachineType kMachPtr = kPointerSize == 4 ? kRepWord32 : kRepWord64; | 69 const MachineType kMachPtr = kPointerSize == 4 ? kRepWord32 : kRepWord64; |
| 70 const MachineType kMachAnyTagged = | 70 const MachineType kMachAnyTagged = |
| 71 static_cast<MachineType>(kRepTagged | kTypeAny); | 71 static_cast<MachineType>(kRepTagged | kTypeAny); |
| 72 | 72 |
| 73 // Gets only the type of the given type. |
| 74 inline MachineType TypeOf(MachineType machine_type) { |
| 75 int result = machine_type & kTypeMask; |
| 76 return static_cast<MachineType>(result); |
| 77 } |
| 78 |
| 73 // Gets only the representation of the given type. | 79 // Gets only the representation of the given type. |
| 74 inline MachineType RepresentationOf(MachineType machine_type) { | 80 inline MachineType RepresentationOf(MachineType machine_type) { |
| 75 int result = machine_type & kRepMask; | 81 int result = machine_type & kRepMask; |
| 76 CHECK(IsPowerOf2(result)); | 82 CHECK(IsPowerOf2(result)); |
| 77 return static_cast<MachineType>(result); | 83 return static_cast<MachineType>(result); |
| 78 } | 84 } |
| 79 | 85 |
| 80 // Gets the element size in bytes of the machine type. | 86 // Gets the element size in bytes of the machine type. |
| 81 inline int ElementSizeOf(MachineType machine_type) { | 87 inline int ElementSizeOf(MachineType machine_type) { |
| 82 switch (RepresentationOf(machine_type)) { | 88 switch (RepresentationOf(machine_type)) { |
| 83 case kRepBit: | 89 case kRepBit: |
| 84 case kRepWord8: | 90 case kRepWord8: |
| 85 return 1; | 91 return 1; |
| 86 case kRepWord16: | 92 case kRepWord16: |
| 87 return 2; | 93 return 2; |
| 88 case kRepWord32: | 94 case kRepWord32: |
| 89 return 4; | 95 return 4; |
| 90 case kRepWord64: | 96 case kRepWord64: |
| 91 case kRepFloat64: | 97 case kRepFloat64: |
| 92 return 8; | 98 return 8; |
| 93 case kRepTagged: | 99 case kRepTagged: |
| 94 return kPointerSize; | 100 return kPointerSize; |
| 95 default: | 101 default: |
| 96 UNREACHABLE(); | 102 UNREACHABLE(); |
| 97 return kPointerSize; | 103 return kPointerSize; |
| 98 } | 104 } |
| 99 } | 105 } |
| 100 } | 106 |
| 101 } | 107 } // namespace compiler |
| 102 } // namespace v8::internal::compiler | 108 } // namespace internal |
| 109 } // namespace v8 |
| 103 | 110 |
| 104 #endif // V8_COMPILER_MACHINE_TYPE_H_ | 111 #endif // V8_COMPILER_MACHINE_TYPE_H_ |
| OLD | NEW |