Chromium Code Reviews| 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 struct UnalignedAccessConfig { | |
|
titzer
2016/05/06 16:06:47
Can we call this simply AlignmentRequirements?
ivica.bogosavljevic
2016/05/10 08:32:22
Acknowledged.
| |
| 127 public: | |
| 128 explicit UnalignedAccessConfig(bool fullUnalignedAccessSupport, | |
| 129 bool noUnalignedAccessSupport) | |
| 130 : fullUnalignedAccessSupport_(fullUnalignedAccessSupport), | |
| 131 noUnalignedAccessSupport_(noUnalignedAccessSupport), | |
| 132 unalingedLoadSupportedTypes_(NULL, 0), | |
| 133 unalingedStoreSupportedTypes_(NULL, 0) { | |
| 134 DCHECK(fullUnalignedAccessSupport != noUnalignedAccessSupport); | |
| 135 } | |
| 136 explicit UnalignedAccessConfig( | |
| 137 Vector<MachineType> unalingedLoadSupportedTypes, | |
| 138 Vector<MachineType> unalignedStoreSupportedTypes) | |
| 139 : fullUnalignedAccessSupport_(false), | |
| 140 noUnalignedAccessSupport_(false), | |
| 141 unalingedLoadSupportedTypes_(unalingedLoadSupportedTypes), | |
| 142 unalingedStoreSupportedTypes_(unalignedStoreSupportedTypes) {} | |
| 143 | |
| 144 bool IsUnalignedLoadSupported(const MachineType& machineType, | |
| 145 uint8_t alignment) const { | |
| 146 return IsUnalingedSupported(unalingedLoadSupportedTypes_, machineType, | |
| 147 alignment); | |
| 148 } | |
| 149 | |
| 150 bool IsUnalignedStoreSupported(const MachineType& machineType, | |
| 151 uint8_t alignment) const { | |
| 152 return IsUnalingedSupported(unalingedStoreSupportedTypes_, machineType, | |
| 153 alignment); | |
| 154 } | |
| 155 | |
| 156 static UnalignedAccessConfig FullUnalignedAccessSupport() { | |
| 157 return UnalignedAccessConfig(true, false); | |
| 158 } | |
| 159 static UnalignedAccessConfig NoUnalignedAccessSupport() { | |
| 160 return UnalignedAccessConfig(false, true); | |
| 161 } | |
| 162 | |
| 163 private: | |
| 164 bool IsUnalingedSupported(const Vector<MachineType>& supported, | |
| 165 const MachineType& machineType, | |
| 166 uint8_t alignment) const { | |
| 167 if (fullUnalignedAccessSupport_) { | |
| 168 return true; | |
| 169 } else if (noUnalignedAccessSupport_) { | |
| 170 return false; | |
| 171 } else { | |
| 172 for (MachineType m : supported) { | |
| 173 if (m == machineType) { | |
| 174 return true; | |
| 175 } | |
| 176 } | |
| 177 return false; | |
| 178 } | |
| 179 } | |
| 180 | |
| 181 const bool fullUnalignedAccessSupport_; | |
| 182 const bool noUnalignedAccessSupport_; | |
| 183 const Vector<MachineType> unalingedLoadSupportedTypes_; | |
| 184 const Vector<MachineType> unalingedStoreSupportedTypes_; | |
| 185 }; | |
| 186 | |
| 126 explicit MachineOperatorBuilder( | 187 explicit MachineOperatorBuilder( |
| 127 Zone* zone, | 188 Zone* zone, |
| 128 MachineRepresentation word = MachineType::PointerRepresentation(), | 189 MachineRepresentation word = MachineType::PointerRepresentation(), |
| 129 Flags supportedOperators = kNoFlags); | 190 Flags supportedOperators = kNoFlags, |
| 191 UnalignedAccessConfig unalignedAccessConfig = | |
| 192 UnalignedAccessConfig::NoUnalignedAccessSupport()); | |
| 130 | 193 |
| 131 const Operator* Word32And(); | 194 const Operator* Word32And(); |
| 132 const Operator* Word32Or(); | 195 const Operator* Word32Or(); |
| 133 const Operator* Word32Xor(); | 196 const Operator* Word32Xor(); |
| 134 const Operator* Word32Shl(); | 197 const Operator* Word32Shl(); |
| 135 const Operator* Word32Shr(); | 198 const Operator* Word32Shr(); |
| 136 const Operator* Word32Sar(); | 199 const Operator* Word32Sar(); |
| 137 const Operator* Word32Ror(); | 200 const Operator* Word32Ror(); |
| 138 const Operator* Word32Equal(); | 201 const Operator* Word32Equal(); |
| 139 const Operator* Word32Clz(); | 202 const Operator* Word32Clz(); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 // atomic-load [base + index] | 567 // atomic-load [base + index] |
| 505 const Operator* AtomicLoad(LoadRepresentation rep); | 568 const Operator* AtomicLoad(LoadRepresentation rep); |
| 506 // atomic-store [base + index], value | 569 // atomic-store [base + index], value |
| 507 const Operator* AtomicStore(MachineRepresentation rep); | 570 const Operator* AtomicStore(MachineRepresentation rep); |
| 508 | 571 |
| 509 // Target machine word-size assumed by this builder. | 572 // Target machine word-size assumed by this builder. |
| 510 bool Is32() const { return word() == MachineRepresentation::kWord32; } | 573 bool Is32() const { return word() == MachineRepresentation::kWord32; } |
| 511 bool Is64() const { return word() == MachineRepresentation::kWord64; } | 574 bool Is64() const { return word() == MachineRepresentation::kWord64; } |
| 512 MachineRepresentation word() const { return word_; } | 575 MachineRepresentation word() const { return word_; } |
| 513 | 576 |
| 577 bool UnalignedLoadSupported(const MachineType& machineType, | |
| 578 uint8_t alignment) { | |
| 579 return unalignedAccessConfig_.IsUnalignedLoadSupported(machineType, | |
| 580 alignment); | |
| 581 } | |
| 582 | |
| 583 bool UnalignedStoreSupported(const MachineType& machineType, | |
| 584 uint8_t alignment) { | |
| 585 return unalignedAccessConfig_.IsUnalignedStoreSupported(machineType, | |
| 586 alignment); | |
| 587 } | |
| 588 | |
| 514 // Pseudo operators that translate to 32/64-bit operators depending on the | 589 // Pseudo operators that translate to 32/64-bit operators depending on the |
| 515 // word-size of the target machine assumed by this builder. | 590 // word-size of the target machine assumed by this builder. |
| 516 #define PSEUDO_OP_LIST(V) \ | 591 #define PSEUDO_OP_LIST(V) \ |
| 517 V(Word, And) \ | 592 V(Word, And) \ |
| 518 V(Word, Or) \ | 593 V(Word, Or) \ |
| 519 V(Word, Xor) \ | 594 V(Word, Xor) \ |
| 520 V(Word, Shl) \ | 595 V(Word, Shl) \ |
| 521 V(Word, Shr) \ | 596 V(Word, Shr) \ |
| 522 V(Word, Sar) \ | 597 V(Word, Sar) \ |
| 523 V(Word, Ror) \ | 598 V(Word, Ror) \ |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 538 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ | 613 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ |
| 539 } | 614 } |
| 540 PSEUDO_OP_LIST(PSEUDO_OP) | 615 PSEUDO_OP_LIST(PSEUDO_OP) |
| 541 #undef PSEUDO_OP | 616 #undef PSEUDO_OP |
| 542 #undef PSEUDO_OP_LIST | 617 #undef PSEUDO_OP_LIST |
| 543 | 618 |
| 544 private: | 619 private: |
| 545 MachineOperatorGlobalCache const& cache_; | 620 MachineOperatorGlobalCache const& cache_; |
| 546 MachineRepresentation const word_; | 621 MachineRepresentation const word_; |
| 547 Flags const flags_; | 622 Flags const flags_; |
| 623 UnalignedAccessConfig const unalignedAccessConfig_; | |
| 548 | 624 |
| 549 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); | 625 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); |
| 550 }; | 626 }; |
| 551 | 627 |
| 552 | 628 |
| 553 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) | 629 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) |
| 554 | 630 |
| 555 } // namespace compiler | 631 } // namespace compiler |
| 556 } // namespace internal | 632 } // namespace internal |
| 557 } // namespace v8 | 633 } // namespace v8 |
| 558 | 634 |
| 559 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 635 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
| OLD | NEW |