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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 kUint32DivIsSafe = 1u << 14, | 114 kUint32DivIsSafe = 1u << 14, |
115 kWord32ShiftIsSafe = 1u << 15, | 115 kWord32ShiftIsSafe = 1u << 15, |
116 kWord32Ctz = 1u << 16, | 116 kWord32Ctz = 1u << 16, |
117 kWord64Ctz = 1u << 17, | 117 kWord64Ctz = 1u << 17, |
118 kWord32Popcnt = 1u << 18, | 118 kWord32Popcnt = 1u << 18, |
119 kWord64Popcnt = 1u << 19, | 119 kWord64Popcnt = 1u << 19, |
120 kWord32ReverseBits = 1u << 20, | 120 kWord32ReverseBits = 1u << 20, |
121 kWord64ReverseBits = 1u << 21, | 121 kWord64ReverseBits = 1u << 21, |
122 kFloat32Neg = 1u << 22, | 122 kFloat32Neg = 1u << 22, |
123 kFloat64Neg = 1u << 23, | 123 kFloat64Neg = 1u << 23, |
124 kWord16ReverseBytes = 1u << 24, | |
125 kWord32ReverseBytes = 1u << 25, | |
126 kWord64ReverseBytes = 1u << 26, | |
124 kAllOptionalOps = | 127 kAllOptionalOps = |
125 kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min | | 128 kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min | |
126 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | | 129 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | |
127 kFloat64RoundUp | kFloat32RoundTruncate | kFloat64RoundTruncate | | 130 kFloat64RoundUp | kFloat32RoundTruncate | kFloat64RoundTruncate | |
128 kFloat64RoundTiesAway | kFloat32RoundTiesEven | kFloat64RoundTiesEven | | 131 kFloat64RoundTiesAway | kFloat32RoundTiesEven | kFloat64RoundTiesEven | |
129 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | | 132 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | |
130 kWord32ReverseBits | kWord64ReverseBits | kFloat32Neg | kFloat64Neg | 133 kWord32ReverseBits | kWord64ReverseBits | kFloat32Neg | kFloat64Neg | |
134 kWord16ReverseBytes | kWord32ReverseBytes | kWord64ReverseBytes | |
131 }; | 135 }; |
132 typedef base::Flags<Flag, unsigned> Flags; | 136 typedef base::Flags<Flag, unsigned> Flags; |
133 | 137 |
134 class AlignmentRequirements { | 138 class AlignmentRequirements { |
135 public: | 139 public: |
136 enum UnalignedAccessSupport { kNoSupport, kSomeSupport, kFullSupport }; | 140 enum UnalignedAccessSupport { kNoSupport, kSomeSupport, kFullSupport }; |
137 | 141 |
138 bool IsUnalignedLoadSupported(const MachineType& machineType, | 142 bool IsUnalignedLoadSupported(const MachineType& machineType, |
139 uint8_t alignment) const { | 143 uint8_t alignment) const { |
140 return IsUnalignedSupported(unalignedLoadSupportedTypes_, machineType, | 144 return IsUnalignedSupported(unalignedLoadSupportedTypes_, machineType, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 const Operator* Word32Shr(); | 214 const Operator* Word32Shr(); |
211 const Operator* Word32Sar(); | 215 const Operator* Word32Sar(); |
212 const Operator* Word32Ror(); | 216 const Operator* Word32Ror(); |
213 const Operator* Word32Equal(); | 217 const Operator* Word32Equal(); |
214 const Operator* Word32Clz(); | 218 const Operator* Word32Clz(); |
215 const OptionalOperator Word32Ctz(); | 219 const OptionalOperator Word32Ctz(); |
216 const OptionalOperator Word32Popcnt(); | 220 const OptionalOperator Word32Popcnt(); |
217 const OptionalOperator Word64Popcnt(); | 221 const OptionalOperator Word64Popcnt(); |
218 const OptionalOperator Word32ReverseBits(); | 222 const OptionalOperator Word32ReverseBits(); |
219 const OptionalOperator Word64ReverseBits(); | 223 const OptionalOperator Word64ReverseBits(); |
224 const OptionalOperator Word16ReverseBytes(); | |
225 const OptionalOperator Word32ReverseBytes(); | |
226 const OptionalOperator Word64ReverseBytes(); | |
220 bool Word32ShiftIsSafe() const { return flags_ & kWord32ShiftIsSafe; } | 227 bool Word32ShiftIsSafe() const { return flags_ & kWord32ShiftIsSafe; } |
221 | 228 |
222 const Operator* Word64And(); | 229 const Operator* Word64And(); |
223 const Operator* Word64Or(); | 230 const Operator* Word64Or(); |
224 const Operator* Word64Xor(); | 231 const Operator* Word64Xor(); |
225 const Operator* Word64Shl(); | 232 const Operator* Word64Shl(); |
226 const Operator* Word64Shr(); | 233 const Operator* Word64Shr(); |
227 const Operator* Word64Sar(); | 234 const Operator* Word64Sar(); |
228 const Operator* Word64Ror(); | 235 const Operator* Word64Ror(); |
229 const Operator* Word64Clz(); | 236 const Operator* Word64Clz(); |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 const Operator* CheckedLoad(CheckedLoadRepresentation); | 620 const Operator* CheckedLoad(CheckedLoadRepresentation); |
614 // checked-store heap, index, length, value | 621 // checked-store heap, index, length, value |
615 const Operator* CheckedStore(CheckedStoreRepresentation); | 622 const Operator* CheckedStore(CheckedStoreRepresentation); |
616 | 623 |
617 // atomic-load [base + index] | 624 // atomic-load [base + index] |
618 const Operator* AtomicLoad(LoadRepresentation rep); | 625 const Operator* AtomicLoad(LoadRepresentation rep); |
619 // atomic-store [base + index], value | 626 // atomic-store [base + index], value |
620 const Operator* AtomicStore(MachineRepresentation rep); | 627 const Operator* AtomicStore(MachineRepresentation rep); |
621 | 628 |
622 // Target machine word-size assumed by this builder. | 629 // Target machine word-size assumed by this builder. |
630 bool Is16() const { return word() == MachineRepresentation::kWord16; } | |
ahaas
2016/07/27 01:31:15
The introduction of Is16() worries me. Is a word s
john.yan
2016/07/27 18:18:19
Ok, I agree. Word16ReverseBytes Opcode is now remo
| |
623 bool Is32() const { return word() == MachineRepresentation::kWord32; } | 631 bool Is32() const { return word() == MachineRepresentation::kWord32; } |
624 bool Is64() const { return word() == MachineRepresentation::kWord64; } | 632 bool Is64() const { return word() == MachineRepresentation::kWord64; } |
625 MachineRepresentation word() const { return word_; } | 633 MachineRepresentation word() const { return word_; } |
626 | 634 |
627 bool UnalignedLoadSupported(const MachineType& machineType, | 635 bool UnalignedLoadSupported(const MachineType& machineType, |
628 uint8_t alignment) { | 636 uint8_t alignment) { |
629 return alignment_requirements_.IsUnalignedLoadSupported(machineType, | 637 return alignment_requirements_.IsUnalignedLoadSupported(machineType, |
630 alignment); | 638 alignment); |
631 } | 639 } |
632 | 640 |
633 bool UnalignedStoreSupported(const MachineType& machineType, | 641 bool UnalignedStoreSupported(const MachineType& machineType, |
634 uint8_t alignment) { | 642 uint8_t alignment) { |
635 return alignment_requirements_.IsUnalignedStoreSupported(machineType, | 643 return alignment_requirements_.IsUnalignedStoreSupported(machineType, |
636 alignment); | 644 alignment); |
637 } | 645 } |
638 | 646 |
647 bool ReverseBytesSupported(const MachineType& machineType) { | |
ahaas
2016/07/27 01:31:15
Why is the machineType passed in if it is not used
john.yan
2016/07/27 18:18:19
Thanks for pointing out. This is my mistake.
| |
648 if (Is16()) | |
649 return Word16ReverseBytes().IsSupported(); | |
650 else if (Is32()) | |
651 return Word32ReverseBytes().IsSupported(); | |
652 else if (Is64()) | |
653 return Word64ReverseBytes().IsSupported(); | |
654 else | |
655 return false; | |
656 } | |
657 | |
639 // Pseudo operators that translate to 32/64-bit operators depending on the | 658 // Pseudo operators that translate to 32/64-bit operators depending on the |
640 // word-size of the target machine assumed by this builder. | 659 // word-size of the target machine assumed by this builder. |
641 #define PSEUDO_OP_LIST(V) \ | 660 #define PSEUDO_OP_LIST(V) \ |
642 V(Word, And) \ | 661 V(Word, And) \ |
643 V(Word, Or) \ | 662 V(Word, Or) \ |
644 V(Word, Xor) \ | 663 V(Word, Xor) \ |
645 V(Word, Shl) \ | 664 V(Word, Shl) \ |
646 V(Word, Shr) \ | 665 V(Word, Shr) \ |
647 V(Word, Sar) \ | 666 V(Word, Sar) \ |
648 V(Word, Ror) \ | 667 V(Word, Ror) \ |
(...skipping 28 matching lines...) Expand all Loading... | |
677 }; | 696 }; |
678 | 697 |
679 | 698 |
680 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) | 699 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) |
681 | 700 |
682 } // namespace compiler | 701 } // namespace compiler |
683 } // namespace internal | 702 } // namespace internal |
684 } // namespace v8 | 703 } // namespace v8 |
685 | 704 |
686 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 705 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
OLD | NEW |