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

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

Issue 1928513002: Implement UnalignedLoad and UnalignedStore in WASM using LoadByte/Shift/Or and StoreByte/Shift/And. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Renamed UnalignedAccessConfig to AlignmentRequirements Created 4 years, 7 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 AlignmentRequirements {
Benedikt Meurer 2016/05/12 04:12:14 Nit: class
127 public:
128 explicit AlignmentRequirements(bool fullUnalignedAccessSupport,
129 bool noUnalignedAccessSupport)
Jarin 2016/05/12 04:26:13 Nit: Could you make the constructor private now th
130 : fullUnalignedAccessSupport_(fullUnalignedAccessSupport),
131 noUnalignedAccessSupport_(noUnalignedAccessSupport),
132 unalignedLoadSupportedTypes_(NULL, 0),
133 unalignedStoreSupportedTypes_(NULL, 0) {
134 DCHECK(fullUnalignedAccessSupport != noUnalignedAccessSupport);
135 }
136 explicit AlignmentRequirements(
137 Vector<MachineType> unalingedLoadSupportedTypes,
Jarin 2016/05/12 04:26:13 Typo: unalinged -> unaligned
138 Vector<MachineType> unalignedStoreSupportedTypes)
139 : fullUnalignedAccessSupport_(false),
140 noUnalignedAccessSupport_(false),
141 unalignedLoadSupportedTypes_(unalingedLoadSupportedTypes),
142 unalignedStoreSupportedTypes_(unalignedStoreSupportedTypes) {}
143
144 bool IsUnalignedLoadSupported(const MachineType& machineType,
145 uint8_t alignment) const {
146 return IsUnalingedSupported(unalignedLoadSupportedTypes_, machineType,
147 alignment);
148 }
149
150 bool IsUnalignedStoreSupported(const MachineType& machineType,
151 uint8_t alignment) const {
152 return IsUnalingedSupported(unalignedStoreSupportedTypes_, machineType,
153 alignment);
154 }
155
156 static AlignmentRequirements FullUnalignedAccessSupport() {
157 return AlignmentRequirements(true, false);
158 }
159 static AlignmentRequirements NoUnalignedAccessSupport() {
160 return AlignmentRequirements(false, true);
161 }
162
163 private:
164 bool IsUnalingedSupported(const Vector<MachineType>& supported,
Jarin 2016/05/12 04:26:13 Typo: Unalinged -> Unaligned
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_;
Benedikt Meurer 2016/05/12 04:12:14 How about an enum here for this tristate logic? Th
182 const bool noUnalignedAccessSupport_;
183 const Vector<MachineType> unalignedLoadSupportedTypes_;
184 const Vector<MachineType> unalignedStoreSupportedTypes_;
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 AlignmentRequirements alignmentConfig =
192 AlignmentRequirements::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
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 alignmentConfig_.IsUnalignedLoadSupported(machineType, alignment);
580 }
581
582 bool UnalignedStoreSupported(const MachineType& machineType,
583 uint8_t alignment) {
584 return alignmentConfig_.IsUnalignedStoreSupported(machineType, alignment);
585 }
586
514 // Pseudo operators that translate to 32/64-bit operators depending on the 587 // Pseudo operators that translate to 32/64-bit operators depending on the
515 // word-size of the target machine assumed by this builder. 588 // word-size of the target machine assumed by this builder.
516 #define PSEUDO_OP_LIST(V) \ 589 #define PSEUDO_OP_LIST(V) \
517 V(Word, And) \ 590 V(Word, And) \
518 V(Word, Or) \ 591 V(Word, Or) \
519 V(Word, Xor) \ 592 V(Word, Xor) \
520 V(Word, Shl) \ 593 V(Word, Shl) \
521 V(Word, Shr) \ 594 V(Word, Shr) \
522 V(Word, Sar) \ 595 V(Word, Sar) \
523 V(Word, Ror) \ 596 V(Word, Ror) \
(...skipping 14 matching lines...) Expand all
538 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ 611 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \
539 } 612 }
540 PSEUDO_OP_LIST(PSEUDO_OP) 613 PSEUDO_OP_LIST(PSEUDO_OP)
541 #undef PSEUDO_OP 614 #undef PSEUDO_OP
542 #undef PSEUDO_OP_LIST 615 #undef PSEUDO_OP_LIST
543 616
544 private: 617 private:
545 MachineOperatorGlobalCache const& cache_; 618 MachineOperatorGlobalCache const& cache_;
546 MachineRepresentation const word_; 619 MachineRepresentation const word_;
547 Flags const flags_; 620 Flags const flags_;
621 AlignmentRequirements const alignmentConfig_;
548 622
549 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); 623 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder);
550 }; 624 };
551 625
552 626
553 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) 627 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags)
554 628
555 } // namespace compiler 629 } // namespace compiler
556 } // namespace internal 630 } // namespace internal
557 } // namespace v8 631 } // namespace v8
558 632
559 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ 633 #endif // V8_COMPILER_MACHINE_OPERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698