Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: src/compiler/machine-operator.h

Issue 2045943002: [compiler] [wasm] Introduce Word32/64ReverseBytes as TF Optional Opcode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: implement machops tests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 kAllOptionalOps = 124 kWord32ReverseBytes = 1u << 24,
125 kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min | 125 kWord64ReverseBytes = 1u << 25,
126 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | 126 kAllOptionalOps = kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min |
127 kFloat64RoundUp | kFloat32RoundTruncate | kFloat64RoundTruncate | 127 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp |
128 kFloat64RoundTiesAway | kFloat32RoundTiesEven | kFloat64RoundTiesEven | 128 kFloat64RoundUp | kFloat32RoundTruncate |
129 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | 129 kFloat64RoundTruncate | kFloat64RoundTiesAway |
130 kWord32ReverseBits | kWord64ReverseBits | kFloat32Neg | kFloat64Neg 130 kFloat32RoundTiesEven | kFloat64RoundTiesEven |
131 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt |
132 kWord32ReverseBits | kWord64ReverseBits | kFloat32Neg |
133 kFloat64Neg | kWord32ReverseBytes | kWord64ReverseBytes
131 }; 134 };
132 typedef base::Flags<Flag, unsigned> Flags; 135 typedef base::Flags<Flag, unsigned> Flags;
133 136
134 class AlignmentRequirements { 137 class AlignmentRequirements {
135 public: 138 public:
136 enum UnalignedAccessSupport { kNoSupport, kSomeSupport, kFullSupport }; 139 enum UnalignedAccessSupport { kNoSupport, kSomeSupport, kFullSupport };
137 140
138 bool IsUnalignedLoadSupported(const MachineType& machineType, 141 bool IsUnalignedLoadSupported(const MachineType& machineType,
139 uint8_t alignment) const { 142 uint8_t alignment) const {
140 return IsUnalignedSupported(unalignedLoadSupportedTypes_, machineType, 143 return IsUnalignedSupported(unalignedLoadSupportedTypes_, machineType,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 const Operator* Word32Shr(); 213 const Operator* Word32Shr();
211 const Operator* Word32Sar(); 214 const Operator* Word32Sar();
212 const Operator* Word32Ror(); 215 const Operator* Word32Ror();
213 const Operator* Word32Equal(); 216 const Operator* Word32Equal();
214 const Operator* Word32Clz(); 217 const Operator* Word32Clz();
215 const OptionalOperator Word32Ctz(); 218 const OptionalOperator Word32Ctz();
216 const OptionalOperator Word32Popcnt(); 219 const OptionalOperator Word32Popcnt();
217 const OptionalOperator Word64Popcnt(); 220 const OptionalOperator Word64Popcnt();
218 const OptionalOperator Word32ReverseBits(); 221 const OptionalOperator Word32ReverseBits();
219 const OptionalOperator Word64ReverseBits(); 222 const OptionalOperator Word64ReverseBits();
223 const OptionalOperator Word32ReverseBytes();
224 const OptionalOperator Word64ReverseBytes();
220 bool Word32ShiftIsSafe() const { return flags_ & kWord32ShiftIsSafe; } 225 bool Word32ShiftIsSafe() const { return flags_ & kWord32ShiftIsSafe; }
221 226
222 const Operator* Word64And(); 227 const Operator* Word64And();
223 const Operator* Word64Or(); 228 const Operator* Word64Or();
224 const Operator* Word64Xor(); 229 const Operator* Word64Xor();
225 const Operator* Word64Shl(); 230 const Operator* Word64Shl();
226 const Operator* Word64Shr(); 231 const Operator* Word64Shr();
227 const Operator* Word64Sar(); 232 const Operator* Word64Sar();
228 const Operator* Word64Ror(); 233 const Operator* Word64Ror();
229 const Operator* Word64Clz(); 234 const Operator* Word64Clz();
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 return alignment_requirements_.IsUnalignedLoadSupported(machineType, 634 return alignment_requirements_.IsUnalignedLoadSupported(machineType,
630 alignment); 635 alignment);
631 } 636 }
632 637
633 bool UnalignedStoreSupported(const MachineType& machineType, 638 bool UnalignedStoreSupported(const MachineType& machineType,
634 uint8_t alignment) { 639 uint8_t alignment) {
635 return alignment_requirements_.IsUnalignedStoreSupported(machineType, 640 return alignment_requirements_.IsUnalignedStoreSupported(machineType,
636 alignment); 641 alignment);
637 } 642 }
638 643
644 bool ReverseBytesSupported(size_t size_in_bytes) {
ahaas 2016/07/28 14:12:59 Could this function not just be a helper function
john.yan 2016/07/28 18:03:50 Sure.
645 switch (size_in_bytes) {
646 case 4:
647 return Word32ReverseBytes().IsSupported();
648 case 8:
649 return Word64ReverseBytes().IsSupported();
650 default:
651 break;
ahaas 2016/07/28 14:12:59 Do you expect that the default case is ever reache
john.yan 2016/07/28 18:03:50 No, I expect it to return false (unsupported).
652 }
653 return false;
654 }
655
639 // Pseudo operators that translate to 32/64-bit operators depending on the 656 // Pseudo operators that translate to 32/64-bit operators depending on the
640 // word-size of the target machine assumed by this builder. 657 // word-size of the target machine assumed by this builder.
641 #define PSEUDO_OP_LIST(V) \ 658 #define PSEUDO_OP_LIST(V) \
642 V(Word, And) \ 659 V(Word, And) \
643 V(Word, Or) \ 660 V(Word, Or) \
644 V(Word, Xor) \ 661 V(Word, Xor) \
645 V(Word, Shl) \ 662 V(Word, Shl) \
646 V(Word, Shr) \ 663 V(Word, Shr) \
647 V(Word, Sar) \ 664 V(Word, Sar) \
648 V(Word, Ror) \ 665 V(Word, Ror) \
(...skipping 28 matching lines...) Expand all
677 }; 694 };
678 695
679 696
680 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) 697 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags)
681 698
682 } // namespace compiler 699 } // namespace compiler
683 } // namespace internal 700 } // namespace internal
684 } // namespace v8 701 } // namespace v8
685 702
686 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ 703 #endif // V8_COMPILER_MACHINE_OPERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698