| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 kAllOptionalOps = kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min | | 116 kAllOptionalOps = kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min | |
| 117 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | | 117 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | |
| 118 kFloat64RoundUp | kFloat32RoundTruncate | | 118 kFloat64RoundUp | kFloat32RoundTruncate | |
| 119 kFloat64RoundTruncate | kFloat64RoundTiesAway | | 119 kFloat64RoundTruncate | kFloat64RoundTiesAway | |
| 120 kFloat32RoundTiesEven | kFloat64RoundTiesEven | | 120 kFloat32RoundTiesEven | kFloat64RoundTiesEven | |
| 121 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | | 121 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | |
| 122 kWord32ReverseBits | kWord64ReverseBits | 122 kWord32ReverseBits | kWord64ReverseBits |
| 123 }; | 123 }; |
| 124 typedef base::Flags<Flag, unsigned> Flags; | 124 typedef base::Flags<Flag, unsigned> Flags; |
| 125 | 125 |
| 126 class AlignmentRequirements { |
| 127 public: |
| 128 enum UnalignedAccessSupport { kNoSupport, kSomeSupport, kFullSupport }; |
| 129 |
| 130 bool IsUnalignedLoadSupported(const MachineType& machineType, |
| 131 uint8_t alignment) const { |
| 132 return IsUnalignedSupported(unalignedLoadSupportedTypes_, machineType, |
| 133 alignment); |
| 134 } |
| 135 |
| 136 bool IsUnalignedStoreSupported(const MachineType& machineType, |
| 137 uint8_t alignment) const { |
| 138 return IsUnalignedSupported(unalignedStoreSupportedTypes_, machineType, |
| 139 alignment); |
| 140 } |
| 141 |
| 142 static AlignmentRequirements FullUnalignedAccessSupport() { |
| 143 return AlignmentRequirements(kFullSupport); |
| 144 } |
| 145 static AlignmentRequirements NoUnalignedAccessSupport() { |
| 146 return AlignmentRequirements(kNoSupport); |
| 147 } |
| 148 static AlignmentRequirements SomeUnalignedAccessSupport( |
| 149 const Vector<MachineType>& unalignedLoadSupportedTypes, |
| 150 const Vector<MachineType>& unalignedStoreSupportedTypes) { |
| 151 return AlignmentRequirements(kSomeSupport, unalignedLoadSupportedTypes, |
| 152 unalignedStoreSupportedTypes); |
| 153 } |
| 154 |
| 155 private: |
| 156 explicit AlignmentRequirements( |
| 157 AlignmentRequirements::UnalignedAccessSupport unalignedAccessSupport, |
| 158 Vector<MachineType> unalignedLoadSupportedTypes = |
| 159 Vector<MachineType>(NULL, 0), |
| 160 Vector<MachineType> unalignedStoreSupportedTypes = |
| 161 Vector<MachineType>(NULL, 0)) |
| 162 : unalignedSupport_(unalignedAccessSupport), |
| 163 unalignedLoadSupportedTypes_(unalignedLoadSupportedTypes), |
| 164 unalignedStoreSupportedTypes_(unalignedStoreSupportedTypes) {} |
| 165 |
| 166 bool IsUnalignedSupported(const Vector<MachineType>& supported, |
| 167 const MachineType& machineType, |
| 168 uint8_t alignment) const { |
| 169 if (unalignedSupport_ == kFullSupport) { |
| 170 return true; |
| 171 } else if (unalignedSupport_ == kNoSupport) { |
| 172 return false; |
| 173 } else { |
| 174 for (MachineType m : supported) { |
| 175 if (m == machineType) { |
| 176 return true; |
| 177 } |
| 178 } |
| 179 return false; |
| 180 } |
| 181 } |
| 182 |
| 183 const AlignmentRequirements::UnalignedAccessSupport unalignedSupport_; |
| 184 const Vector<MachineType> unalignedLoadSupportedTypes_; |
| 185 const Vector<MachineType> unalignedStoreSupportedTypes_; |
| 186 }; |
| 187 |
| 126 explicit MachineOperatorBuilder( | 188 explicit MachineOperatorBuilder( |
| 127 Zone* zone, | 189 Zone* zone, |
| 128 MachineRepresentation word = MachineType::PointerRepresentation(), | 190 MachineRepresentation word = MachineType::PointerRepresentation(), |
| 129 Flags supportedOperators = kNoFlags); | 191 Flags supportedOperators = kNoFlags, |
| 192 AlignmentRequirements alignmentRequirements = |
| 193 AlignmentRequirements::NoUnalignedAccessSupport()); |
| 130 | 194 |
| 131 const Operator* DebugBreak(); | 195 const Operator* DebugBreak(); |
| 132 | 196 |
| 133 const Operator* Word32And(); | 197 const Operator* Word32And(); |
| 134 const Operator* Word32Or(); | 198 const Operator* Word32Or(); |
| 135 const Operator* Word32Xor(); | 199 const Operator* Word32Xor(); |
| 136 const Operator* Word32Shl(); | 200 const Operator* Word32Shl(); |
| 137 const Operator* Word32Shr(); | 201 const Operator* Word32Shr(); |
| 138 const Operator* Word32Sar(); | 202 const Operator* Word32Sar(); |
| 139 const Operator* Word32Ror(); | 203 const Operator* Word32Ror(); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 // atomic-load [base + index] | 572 // atomic-load [base + index] |
| 509 const Operator* AtomicLoad(LoadRepresentation rep); | 573 const Operator* AtomicLoad(LoadRepresentation rep); |
| 510 // atomic-store [base + index], value | 574 // atomic-store [base + index], value |
| 511 const Operator* AtomicStore(MachineRepresentation rep); | 575 const Operator* AtomicStore(MachineRepresentation rep); |
| 512 | 576 |
| 513 // Target machine word-size assumed by this builder. | 577 // Target machine word-size assumed by this builder. |
| 514 bool Is32() const { return word() == MachineRepresentation::kWord32; } | 578 bool Is32() const { return word() == MachineRepresentation::kWord32; } |
| 515 bool Is64() const { return word() == MachineRepresentation::kWord64; } | 579 bool Is64() const { return word() == MachineRepresentation::kWord64; } |
| 516 MachineRepresentation word() const { return word_; } | 580 MachineRepresentation word() const { return word_; } |
| 517 | 581 |
| 582 bool UnalignedLoadSupported(const MachineType& machineType, |
| 583 uint8_t alignment) { |
| 584 return alignment_requirements_.IsUnalignedLoadSupported(machineType, |
| 585 alignment); |
| 586 } |
| 587 |
| 588 bool UnalignedStoreSupported(const MachineType& machineType, |
| 589 uint8_t alignment) { |
| 590 return alignment_requirements_.IsUnalignedStoreSupported(machineType, |
| 591 alignment); |
| 592 } |
| 593 |
| 518 // Pseudo operators that translate to 32/64-bit operators depending on the | 594 // Pseudo operators that translate to 32/64-bit operators depending on the |
| 519 // word-size of the target machine assumed by this builder. | 595 // word-size of the target machine assumed by this builder. |
| 520 #define PSEUDO_OP_LIST(V) \ | 596 #define PSEUDO_OP_LIST(V) \ |
| 521 V(Word, And) \ | 597 V(Word, And) \ |
| 522 V(Word, Or) \ | 598 V(Word, Or) \ |
| 523 V(Word, Xor) \ | 599 V(Word, Xor) \ |
| 524 V(Word, Shl) \ | 600 V(Word, Shl) \ |
| 525 V(Word, Shr) \ | 601 V(Word, Shr) \ |
| 526 V(Word, Sar) \ | 602 V(Word, Sar) \ |
| 527 V(Word, Ror) \ | 603 V(Word, Ror) \ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 542 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ | 618 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ |
| 543 } | 619 } |
| 544 PSEUDO_OP_LIST(PSEUDO_OP) | 620 PSEUDO_OP_LIST(PSEUDO_OP) |
| 545 #undef PSEUDO_OP | 621 #undef PSEUDO_OP |
| 546 #undef PSEUDO_OP_LIST | 622 #undef PSEUDO_OP_LIST |
| 547 | 623 |
| 548 private: | 624 private: |
| 549 MachineOperatorGlobalCache const& cache_; | 625 MachineOperatorGlobalCache const& cache_; |
| 550 MachineRepresentation const word_; | 626 MachineRepresentation const word_; |
| 551 Flags const flags_; | 627 Flags const flags_; |
| 628 AlignmentRequirements const alignment_requirements_; |
| 552 | 629 |
| 553 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); | 630 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); |
| 554 }; | 631 }; |
| 555 | 632 |
| 556 | 633 |
| 557 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) | 634 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) |
| 558 | 635 |
| 559 } // namespace compiler | 636 } // namespace compiler |
| 560 } // namespace internal | 637 } // namespace internal |
| 561 } // namespace v8 | 638 } // namespace v8 |
| 562 | 639 |
| 563 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 640 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
| OLD | NEW |