| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_OPERATOR_H_ | 5 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_ |
| 6 #define V8_COMPILER_MACHINE_OPERATOR_H_ | 6 #define V8_COMPILER_MACHINE_OPERATOR_H_ |
| 7 | 7 |
| 8 #include "src/base/flags.h" | 8 #include "src/base/flags.h" |
| 9 #include "src/machine-type.h" | 9 #include "src/machine-type.h" |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 bool operator==(StoreRepresentation, StoreRepresentation); | 64 bool operator==(StoreRepresentation, StoreRepresentation); |
| 65 bool operator!=(StoreRepresentation, StoreRepresentation); | 65 bool operator!=(StoreRepresentation, StoreRepresentation); |
| 66 | 66 |
| 67 size_t hash_value(StoreRepresentation); | 67 size_t hash_value(StoreRepresentation); |
| 68 | 68 |
| 69 std::ostream& operator<<(std::ostream&, StoreRepresentation); | 69 std::ostream& operator<<(std::ostream&, StoreRepresentation); |
| 70 | 70 |
| 71 StoreRepresentation const& StoreRepresentationOf(Operator const*); | 71 StoreRepresentation const& StoreRepresentationOf(Operator const*); |
| 72 | 72 |
| 73 typedef MachineType UnalignedLoadRepresentation; |
| 74 |
| 75 UnalignedLoadRepresentation UnalignedLoadRepresentationOf(Operator const*); |
| 76 |
| 77 // An UnalignedStore needs a MachineType. |
| 78 typedef MachineRepresentation UnalignedStoreRepresentation; |
| 79 |
| 80 UnalignedStoreRepresentation const& UnalignedStoreRepresentationOf( |
| 81 Operator const*); |
| 73 | 82 |
| 74 // A CheckedLoad needs a MachineType. | 83 // A CheckedLoad needs a MachineType. |
| 75 typedef MachineType CheckedLoadRepresentation; | 84 typedef MachineType CheckedLoadRepresentation; |
| 76 | 85 |
| 77 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const*); | 86 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const*); |
| 78 | 87 |
| 79 | 88 |
| 80 // A CheckedStore needs a MachineType. | 89 // A CheckedStore needs a MachineType. |
| 81 typedef MachineRepresentation CheckedStoreRepresentation; | 90 typedef MachineRepresentation CheckedStoreRepresentation; |
| 82 | 91 |
| 83 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const*); | 92 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const*); |
| 84 | 93 |
| 85 MachineRepresentation StackSlotRepresentationOf(Operator const* op); | 94 MachineRepresentation StackSlotRepresentationOf(Operator const* op); |
| 86 | 95 |
| 87 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op); | 96 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op); |
| 88 | 97 |
| 89 // Interface for building machine-level operators. These operators are | 98 // Interface for building machine-level operators. These operators are |
| 90 // machine-level but machine-independent and thus define a language suitable | 99 // machine-level but machine-independent and thus define a language suitable |
| 91 // for generating code to run on architectures such as ia32, x64, arm, etc. | 100 // for generating code to run on architectures such as ia32, x64, arm, etc. |
| 92 class MachineOperatorBuilder final : public ZoneObject { | 101 class MachineOperatorBuilder final : public ZoneObject { |
| 93 public: | 102 public: |
| 94 // Flags that specify which operations are available. This is useful | 103 // Flags that specify which operations are available. This is useful |
| 95 // for operations that are unsupported by some back-ends. | 104 // for operations that are unsupported by some back-ends. |
| 96 enum Flag : unsigned { | 105 enum Flag : unsigned { |
| 97 kNoFlags = 0u, | 106 kNoFlags = 0u, |
| 98 kFloat32RoundDown = 1u << 0, | 107 // Note that Float*Max behaves like `(b < a) ? a : b`, not like Math.max(). |
| 99 kFloat64RoundDown = 1u << 1, | 108 // Note that Float*Min behaves like `(a < b) ? a : b`, not like Math.min(). |
| 100 kFloat32RoundUp = 1u << 2, | 109 kFloat32Max = 1u << 0, |
| 101 kFloat64RoundUp = 1u << 3, | 110 kFloat32Min = 1u << 1, |
| 102 kFloat32RoundTruncate = 1u << 4, | 111 kFloat64Max = 1u << 2, |
| 103 kFloat64RoundTruncate = 1u << 5, | 112 kFloat64Min = 1u << 3, |
| 104 kFloat32RoundTiesEven = 1u << 6, | 113 kFloat32RoundDown = 1u << 4, |
| 105 kFloat64RoundTiesEven = 1u << 7, | 114 kFloat64RoundDown = 1u << 5, |
| 106 kFloat64RoundTiesAway = 1u << 8, | 115 kFloat32RoundUp = 1u << 6, |
| 107 kInt32DivIsSafe = 1u << 9, | 116 kFloat64RoundUp = 1u << 7, |
| 108 kUint32DivIsSafe = 1u << 10, | 117 kFloat32RoundTruncate = 1u << 8, |
| 109 kWord32ShiftIsSafe = 1u << 11, | 118 kFloat64RoundTruncate = 1u << 9, |
| 110 kWord32Ctz = 1u << 12, | 119 kFloat32RoundTiesEven = 1u << 10, |
| 111 kWord64Ctz = 1u << 13, | 120 kFloat64RoundTiesEven = 1u << 11, |
| 112 kWord32Popcnt = 1u << 14, | 121 kFloat64RoundTiesAway = 1u << 12, |
| 113 kWord64Popcnt = 1u << 15, | 122 kInt32DivIsSafe = 1u << 13, |
| 114 kWord32ReverseBits = 1u << 16, | 123 kUint32DivIsSafe = 1u << 14, |
| 115 kWord64ReverseBits = 1u << 17, | 124 kWord32ShiftIsSafe = 1u << 15, |
| 116 kFloat32Neg = 1u << 18, | 125 kWord32Ctz = 1u << 16, |
| 117 kFloat64Neg = 1u << 19, | 126 kWord64Ctz = 1u << 17, |
| 127 kWord32Popcnt = 1u << 18, |
| 128 kWord64Popcnt = 1u << 19, |
| 129 kWord32ReverseBits = 1u << 20, |
| 130 kWord64ReverseBits = 1u << 21, |
| 131 kFloat32Neg = 1u << 22, |
| 132 kFloat64Neg = 1u << 23, |
| 118 kAllOptionalOps = | 133 kAllOptionalOps = |
| 134 kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min | |
| 119 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | | 135 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | |
| 120 kFloat64RoundUp | kFloat32RoundTruncate | kFloat64RoundTruncate | | 136 kFloat64RoundUp | kFloat32RoundTruncate | kFloat64RoundTruncate | |
| 121 kFloat64RoundTiesAway | kFloat32RoundTiesEven | kFloat64RoundTiesEven | | 137 kFloat64RoundTiesAway | kFloat32RoundTiesEven | kFloat64RoundTiesEven | |
| 122 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | | 138 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | |
| 123 kWord32ReverseBits | kWord64ReverseBits | kFloat32Neg | kFloat64Neg | 139 kWord32ReverseBits | kWord64ReverseBits | kFloat32Neg | kFloat64Neg |
| 124 }; | 140 }; |
| 125 typedef base::Flags<Flag, unsigned> Flags; | 141 typedef base::Flags<Flag, unsigned> Flags; |
| 126 | 142 |
| 127 class AlignmentRequirements { | 143 class AlignmentRequirements { |
| 128 public: | 144 public: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 const AlignmentRequirements::UnalignedAccessSupport unalignedSupport_; | 200 const AlignmentRequirements::UnalignedAccessSupport unalignedSupport_; |
| 185 const Vector<MachineType> unalignedLoadSupportedTypes_; | 201 const Vector<MachineType> unalignedLoadSupportedTypes_; |
| 186 const Vector<MachineType> unalignedStoreSupportedTypes_; | 202 const Vector<MachineType> unalignedStoreSupportedTypes_; |
| 187 }; | 203 }; |
| 188 | 204 |
| 189 explicit MachineOperatorBuilder( | 205 explicit MachineOperatorBuilder( |
| 190 Zone* zone, | 206 Zone* zone, |
| 191 MachineRepresentation word = MachineType::PointerRepresentation(), | 207 MachineRepresentation word = MachineType::PointerRepresentation(), |
| 192 Flags supportedOperators = kNoFlags, | 208 Flags supportedOperators = kNoFlags, |
| 193 AlignmentRequirements alignmentRequirements = | 209 AlignmentRequirements alignmentRequirements = |
| 194 AlignmentRequirements::NoUnalignedAccessSupport()); | 210 AlignmentRequirements::FullUnalignedAccessSupport()); |
| 195 | 211 |
| 196 const Operator* Comment(const char* msg); | 212 const Operator* Comment(const char* msg); |
| 197 const Operator* DebugBreak(); | 213 const Operator* DebugBreak(); |
| 198 | 214 |
| 199 const Operator* Word32And(); | 215 const Operator* Word32And(); |
| 200 const Operator* Word32Or(); | 216 const Operator* Word32Or(); |
| 201 const Operator* Word32Xor(); | 217 const Operator* Word32Xor(); |
| 202 const Operator* Word32Shl(); | 218 const Operator* Word32Shl(); |
| 203 const Operator* Word32Shr(); | 219 const Operator* Word32Shr(); |
| 204 const Operator* Word32Sar(); | 220 const Operator* Word32Sar(); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 const Operator* Simd128Or(); | 600 const Operator* Simd128Or(); |
| 585 const Operator* Simd128Xor(); | 601 const Operator* Simd128Xor(); |
| 586 const Operator* Simd128Not(); | 602 const Operator* Simd128Not(); |
| 587 | 603 |
| 588 // load [base + index] | 604 // load [base + index] |
| 589 const Operator* Load(LoadRepresentation rep); | 605 const Operator* Load(LoadRepresentation rep); |
| 590 | 606 |
| 591 // store [base + index], value | 607 // store [base + index], value |
| 592 const Operator* Store(StoreRepresentation rep); | 608 const Operator* Store(StoreRepresentation rep); |
| 593 | 609 |
| 610 // unaligned load [base + index] |
| 611 const Operator* UnalignedLoad(UnalignedLoadRepresentation rep); |
| 612 |
| 613 // unaligned store [base + index], value |
| 614 const Operator* UnalignedStore(UnalignedStoreRepresentation rep); |
| 615 |
| 594 const Operator* StackSlot(MachineRepresentation rep); | 616 const Operator* StackSlot(MachineRepresentation rep); |
| 595 | 617 |
| 596 // Access to the machine stack. | 618 // Access to the machine stack. |
| 597 const Operator* LoadStackPointer(); | 619 const Operator* LoadStackPointer(); |
| 598 const Operator* LoadFramePointer(); | 620 const Operator* LoadFramePointer(); |
| 599 const Operator* LoadParentFramePointer(); | 621 const Operator* LoadParentFramePointer(); |
| 600 | 622 |
| 601 // checked-load heap, index, length | 623 // checked-load heap, index, length |
| 602 const Operator* CheckedLoad(CheckedLoadRepresentation); | 624 const Operator* CheckedLoad(CheckedLoadRepresentation); |
| 603 // checked-store heap, index, length, value | 625 // checked-store heap, index, length, value |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 }; | 688 }; |
| 667 | 689 |
| 668 | 690 |
| 669 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) | 691 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) |
| 670 | 692 |
| 671 } // namespace compiler | 693 } // namespace compiler |
| 672 } // namespace internal | 694 } // namespace internal |
| 673 } // namespace v8 | 695 } // namespace v8 |
| 674 | 696 |
| 675 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 697 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
| OLD | NEW |