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 alignmentConfig = |
| 193 AlignmentRequirements::NoUnalignedAccessSupport()); |
130 | 194 |
131 const Operator* Word32And(); | 195 const Operator* Word32And(); |
132 const Operator* Word32Or(); | 196 const Operator* Word32Or(); |
133 const Operator* Word32Xor(); | 197 const Operator* Word32Xor(); |
134 const Operator* Word32Shl(); | 198 const Operator* Word32Shl(); |
135 const Operator* Word32Shr(); | 199 const Operator* Word32Shr(); |
136 const Operator* Word32Sar(); | 200 const Operator* Word32Sar(); |
137 const Operator* Word32Ror(); | 201 const Operator* Word32Ror(); |
138 const Operator* Word32Equal(); | 202 const Operator* Word32Equal(); |
139 const Operator* Word32Clz(); | 203 const Operator* Word32Clz(); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 // atomic-load [base + index] | 568 // atomic-load [base + index] |
505 const Operator* AtomicLoad(LoadRepresentation rep); | 569 const Operator* AtomicLoad(LoadRepresentation rep); |
506 // atomic-store [base + index], value | 570 // atomic-store [base + index], value |
507 const Operator* AtomicStore(MachineRepresentation rep); | 571 const Operator* AtomicStore(MachineRepresentation rep); |
508 | 572 |
509 // Target machine word-size assumed by this builder. | 573 // Target machine word-size assumed by this builder. |
510 bool Is32() const { return word() == MachineRepresentation::kWord32; } | 574 bool Is32() const { return word() == MachineRepresentation::kWord32; } |
511 bool Is64() const { return word() == MachineRepresentation::kWord64; } | 575 bool Is64() const { return word() == MachineRepresentation::kWord64; } |
512 MachineRepresentation word() const { return word_; } | 576 MachineRepresentation word() const { return word_; } |
513 | 577 |
| 578 bool UnalignedLoadSupported(const MachineType& machineType, |
| 579 uint8_t alignment) { |
| 580 return alignment_config_.IsUnalignedLoadSupported(machineType, alignment); |
| 581 } |
| 582 |
| 583 bool UnalignedStoreSupported(const MachineType& machineType, |
| 584 uint8_t alignment) { |
| 585 return alignment_config_.IsUnalignedStoreSupported(machineType, alignment); |
| 586 } |
| 587 |
514 // Pseudo operators that translate to 32/64-bit operators depending on the | 588 // Pseudo operators that translate to 32/64-bit operators depending on the |
515 // word-size of the target machine assumed by this builder. | 589 // word-size of the target machine assumed by this builder. |
516 #define PSEUDO_OP_LIST(V) \ | 590 #define PSEUDO_OP_LIST(V) \ |
517 V(Word, And) \ | 591 V(Word, And) \ |
518 V(Word, Or) \ | 592 V(Word, Or) \ |
519 V(Word, Xor) \ | 593 V(Word, Xor) \ |
520 V(Word, Shl) \ | 594 V(Word, Shl) \ |
521 V(Word, Shr) \ | 595 V(Word, Shr) \ |
522 V(Word, Sar) \ | 596 V(Word, Sar) \ |
523 V(Word, Ror) \ | 597 V(Word, Ror) \ |
(...skipping 14 matching lines...) Expand all Loading... |
538 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ | 612 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ |
539 } | 613 } |
540 PSEUDO_OP_LIST(PSEUDO_OP) | 614 PSEUDO_OP_LIST(PSEUDO_OP) |
541 #undef PSEUDO_OP | 615 #undef PSEUDO_OP |
542 #undef PSEUDO_OP_LIST | 616 #undef PSEUDO_OP_LIST |
543 | 617 |
544 private: | 618 private: |
545 MachineOperatorGlobalCache const& cache_; | 619 MachineOperatorGlobalCache const& cache_; |
546 MachineRepresentation const word_; | 620 MachineRepresentation const word_; |
547 Flags const flags_; | 621 Flags const flags_; |
| 622 AlignmentRequirements const alignment_config_; |
548 | 623 |
549 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); | 624 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); |
550 }; | 625 }; |
551 | 626 |
552 | 627 |
553 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) | 628 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) |
554 | 629 |
555 } // namespace compiler | 630 } // namespace compiler |
556 } // namespace internal | 631 } // namespace internal |
557 } // namespace v8 | 632 } // namespace v8 |
558 | 633 |
559 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 634 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
OLD | NEW |