• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_
6 #define V8_COMPILER_MACHINE_OPERATOR_H_
7 
8 #include "src/base/flags.h"
9 #include "src/machine-type.h"
10 
11 namespace v8 {
12 namespace internal {
13 namespace compiler {
14 
15 // Forward declarations.
16 struct MachineOperatorGlobalCache;
17 class Operator;
18 
19 
20 // For operators that are not supported on all platforms.
21 class OptionalOperator final {
22  public:
OptionalOperator(const Operator * op)23   explicit OptionalOperator(const Operator* op) : op_(op) {}
24 
IsSupported()25   bool IsSupported() const { return op_ != nullptr; }
op()26   const Operator* op() const {
27     DCHECK_NOT_NULL(op_);
28     return op_;
29   }
30 
31  private:
32   const Operator* const op_;
33 };
34 
35 
36 // A Load needs a MachineType.
37 typedef MachineType LoadRepresentation;
38 
39 LoadRepresentation LoadRepresentationOf(Operator const*);
40 
41 // A Store needs a MachineType and a WriteBarrierKind in order to emit the
42 // correct write barrier.
43 class StoreRepresentation final {
44  public:
StoreRepresentation(MachineRepresentation representation,WriteBarrierKind write_barrier_kind)45   StoreRepresentation(MachineRepresentation representation,
46                       WriteBarrierKind write_barrier_kind)
47       : representation_(representation),
48         write_barrier_kind_(write_barrier_kind) {}
49 
representation()50   MachineRepresentation representation() const { return representation_; }
write_barrier_kind()51   WriteBarrierKind write_barrier_kind() const { return write_barrier_kind_; }
52 
53  private:
54   MachineRepresentation representation_;
55   WriteBarrierKind write_barrier_kind_;
56 };
57 
58 bool operator==(StoreRepresentation, StoreRepresentation);
59 bool operator!=(StoreRepresentation, StoreRepresentation);
60 
61 size_t hash_value(StoreRepresentation);
62 
63 std::ostream& operator<<(std::ostream&, StoreRepresentation);
64 
65 StoreRepresentation const& StoreRepresentationOf(Operator const*);
66 
67 
68 // A CheckedLoad needs a MachineType.
69 typedef MachineType CheckedLoadRepresentation;
70 
71 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const*);
72 
73 
74 // A CheckedStore needs a MachineType.
75 typedef MachineRepresentation CheckedStoreRepresentation;
76 
77 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const*);
78 
79 MachineRepresentation StackSlotRepresentationOf(Operator const* op);
80 
81 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op);
82 
83 // Interface for building machine-level operators. These operators are
84 // machine-level but machine-independent and thus define a language suitable
85 // for generating code to run on architectures such as ia32, x64, arm, etc.
86 class MachineOperatorBuilder final : public ZoneObject {
87  public:
88   // Flags that specify which operations are available. This is useful
89   // for operations that are unsupported by some back-ends.
90   enum Flag {
91     kNoFlags = 0u,
92     // Note that Float*Max behaves like `(b < a) ? a : b`, not like Math.max().
93     // Note that Float*Min behaves like `(a < b) ? a : b`, not like Math.min().
94     kFloat32Max = 1u << 0,
95     kFloat32Min = 1u << 1,
96     kFloat64Max = 1u << 2,
97     kFloat64Min = 1u << 3,
98     kFloat32RoundDown = 1u << 4,
99     kFloat64RoundDown = 1u << 5,
100     kFloat32RoundUp = 1u << 6,
101     kFloat64RoundUp = 1u << 7,
102     kFloat32RoundTruncate = 1u << 8,
103     kFloat64RoundTruncate = 1u << 9,
104     kFloat32RoundTiesEven = 1u << 10,
105     kFloat64RoundTiesEven = 1u << 11,
106     kFloat64RoundTiesAway = 1u << 12,
107     kInt32DivIsSafe = 1u << 13,
108     kUint32DivIsSafe = 1u << 14,
109     kWord32ShiftIsSafe = 1u << 15,
110     kWord32Ctz = 1u << 16,
111     kWord64Ctz = 1u << 17,
112     kWord32Popcnt = 1u << 18,
113     kWord64Popcnt = 1u << 19,
114     kWord32ReverseBits = 1u << 20,
115     kWord64ReverseBits = 1u << 21,
116     kFloat32Neg = 1u << 22,
117     kFloat64Neg = 1u << 23,
118     kAllOptionalOps =
119         kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min |
120         kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp |
121         kFloat64RoundUp | kFloat32RoundTruncate | kFloat64RoundTruncate |
122         kFloat64RoundTiesAway | kFloat32RoundTiesEven | kFloat64RoundTiesEven |
123         kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt |
124         kWord32ReverseBits | kWord64ReverseBits | kFloat32Neg | kFloat64Neg
125   };
126   typedef base::Flags<Flag, unsigned> Flags;
127 
128   class AlignmentRequirements {
129    public:
130     enum UnalignedAccessSupport { kNoSupport, kSomeSupport, kFullSupport };
131 
IsUnalignedLoadSupported(const MachineType & machineType,uint8_t alignment)132     bool IsUnalignedLoadSupported(const MachineType& machineType,
133                                   uint8_t alignment) const {
134       return IsUnalignedSupported(unalignedLoadSupportedTypes_, machineType,
135                                   alignment);
136     }
137 
IsUnalignedStoreSupported(const MachineType & machineType,uint8_t alignment)138     bool IsUnalignedStoreSupported(const MachineType& machineType,
139                                    uint8_t alignment) const {
140       return IsUnalignedSupported(unalignedStoreSupportedTypes_, machineType,
141                                   alignment);
142     }
143 
FullUnalignedAccessSupport()144     static AlignmentRequirements FullUnalignedAccessSupport() {
145       return AlignmentRequirements(kFullSupport);
146     }
NoUnalignedAccessSupport()147     static AlignmentRequirements NoUnalignedAccessSupport() {
148       return AlignmentRequirements(kNoSupport);
149     }
SomeUnalignedAccessSupport(const Vector<MachineType> & unalignedLoadSupportedTypes,const Vector<MachineType> & unalignedStoreSupportedTypes)150     static AlignmentRequirements SomeUnalignedAccessSupport(
151         const Vector<MachineType>& unalignedLoadSupportedTypes,
152         const Vector<MachineType>& unalignedStoreSupportedTypes) {
153       return AlignmentRequirements(kSomeSupport, unalignedLoadSupportedTypes,
154                                    unalignedStoreSupportedTypes);
155     }
156 
157    private:
158     explicit AlignmentRequirements(
159         AlignmentRequirements::UnalignedAccessSupport unalignedAccessSupport,
160         Vector<MachineType> unalignedLoadSupportedTypes =
161             Vector<MachineType>(NULL, 0),
162         Vector<MachineType> unalignedStoreSupportedTypes =
163             Vector<MachineType>(NULL, 0))
unalignedSupport_(unalignedAccessSupport)164         : unalignedSupport_(unalignedAccessSupport),
165           unalignedLoadSupportedTypes_(unalignedLoadSupportedTypes),
166           unalignedStoreSupportedTypes_(unalignedStoreSupportedTypes) {}
167 
IsUnalignedSupported(const Vector<MachineType> & supported,const MachineType & machineType,uint8_t alignment)168     bool IsUnalignedSupported(const Vector<MachineType>& supported,
169                               const MachineType& machineType,
170                               uint8_t alignment) const {
171       if (unalignedSupport_ == kFullSupport) {
172         return true;
173       } else if (unalignedSupport_ == kNoSupport) {
174         return false;
175       } else {
176         for (MachineType m : supported) {
177           if (m == machineType) {
178             return true;
179           }
180         }
181         return false;
182       }
183     }
184 
185     const AlignmentRequirements::UnalignedAccessSupport unalignedSupport_;
186     const Vector<MachineType> unalignedLoadSupportedTypes_;
187     const Vector<MachineType> unalignedStoreSupportedTypes_;
188   };
189 
190   explicit MachineOperatorBuilder(
191       Zone* zone,
192       MachineRepresentation word = MachineType::PointerRepresentation(),
193       Flags supportedOperators = kNoFlags,
194       AlignmentRequirements alignmentRequirements =
195           AlignmentRequirements::NoUnalignedAccessSupport());
196 
197   const Operator* Comment(const char* msg);
198   const Operator* DebugBreak();
199 
200   const Operator* Word32And();
201   const Operator* Word32Or();
202   const Operator* Word32Xor();
203   const Operator* Word32Shl();
204   const Operator* Word32Shr();
205   const Operator* Word32Sar();
206   const Operator* Word32Ror();
207   const Operator* Word32Equal();
208   const Operator* Word32Clz();
209   const OptionalOperator Word32Ctz();
210   const OptionalOperator Word32Popcnt();
211   const OptionalOperator Word64Popcnt();
212   const Operator* Word64PopcntPlaceholder();
213   const OptionalOperator Word32ReverseBits();
214   const OptionalOperator Word64ReverseBits();
Word32ShiftIsSafe()215   bool Word32ShiftIsSafe() const { return flags_ & kWord32ShiftIsSafe; }
216 
217   const Operator* Word64And();
218   const Operator* Word64Or();
219   const Operator* Word64Xor();
220   const Operator* Word64Shl();
221   const Operator* Word64Shr();
222   const Operator* Word64Sar();
223   const Operator* Word64Ror();
224   const Operator* Word64Clz();
225   const OptionalOperator Word64Ctz();
226   const Operator* Word64CtzPlaceholder();
227   const Operator* Word64Equal();
228 
229   const Operator* Int32PairAdd();
230   const Operator* Int32PairSub();
231   const Operator* Int32PairMul();
232   const Operator* Word32PairShl();
233   const Operator* Word32PairShr();
234   const Operator* Word32PairSar();
235 
236   const Operator* Int32Add();
237   const Operator* Int32AddWithOverflow();
238   const Operator* Int32Sub();
239   const Operator* Int32SubWithOverflow();
240   const Operator* Int32Mul();
241   const Operator* Int32MulHigh();
242   const Operator* Int32Div();
243   const Operator* Int32Mod();
244   const Operator* Int32LessThan();
245   const Operator* Int32LessThanOrEqual();
246   const Operator* Uint32Div();
247   const Operator* Uint32LessThan();
248   const Operator* Uint32LessThanOrEqual();
249   const Operator* Uint32Mod();
250   const Operator* Uint32MulHigh();
Int32DivIsSafe()251   bool Int32DivIsSafe() const { return flags_ & kInt32DivIsSafe; }
Uint32DivIsSafe()252   bool Uint32DivIsSafe() const { return flags_ & kUint32DivIsSafe; }
253 
254   const Operator* Int64Add();
255   const Operator* Int64AddWithOverflow();
256   const Operator* Int64Sub();
257   const Operator* Int64SubWithOverflow();
258   const Operator* Int64Mul();
259   const Operator* Int64Div();
260   const Operator* Int64Mod();
261   const Operator* Int64LessThan();
262   const Operator* Int64LessThanOrEqual();
263   const Operator* Uint64Div();
264   const Operator* Uint64LessThan();
265   const Operator* Uint64LessThanOrEqual();
266   const Operator* Uint64Mod();
267 
268   // This operator reinterprets the bits of a word as tagged pointer.
269   const Operator* BitcastWordToTagged();
270 
271   // JavaScript float64 to int32/uint32 truncation.
272   const Operator* TruncateFloat64ToWord32();
273 
274   // These operators change the representation of numbers while preserving the
275   // value of the number. Narrowing operators assume the input is representable
276   // in the target type and are *not* defined for other inputs.
277   // Use narrowing change operators only when there is a static guarantee that
278   // the input value is representable in the target value.
279   const Operator* ChangeFloat32ToFloat64();
280   const Operator* ChangeFloat64ToInt32();   // narrowing
281   const Operator* ChangeFloat64ToUint32();  // narrowing
282   const Operator* TruncateFloat64ToUint32();
283   const Operator* TruncateFloat32ToInt32();
284   const Operator* TruncateFloat32ToUint32();
285   const Operator* TryTruncateFloat32ToInt64();
286   const Operator* TryTruncateFloat64ToInt64();
287   const Operator* TryTruncateFloat32ToUint64();
288   const Operator* TryTruncateFloat64ToUint64();
289   const Operator* ChangeInt32ToFloat64();
290   const Operator* ChangeInt32ToInt64();
291   const Operator* ChangeUint32ToFloat64();
292   const Operator* ChangeUint32ToUint64();
293 
294   // These operators truncate or round numbers, both changing the representation
295   // of the number and mapping multiple input values onto the same output value.
296   const Operator* TruncateFloat64ToFloat32();
297   const Operator* TruncateInt64ToInt32();
298   const Operator* RoundFloat64ToInt32();
299   const Operator* RoundInt32ToFloat32();
300   const Operator* RoundInt64ToFloat32();
301   const Operator* RoundInt64ToFloat64();
302   const Operator* RoundUint32ToFloat32();
303   const Operator* RoundUint64ToFloat32();
304   const Operator* RoundUint64ToFloat64();
305 
306   // These operators reinterpret the bits of a floating point number as an
307   // integer and vice versa.
308   const Operator* BitcastFloat32ToInt32();
309   const Operator* BitcastFloat64ToInt64();
310   const Operator* BitcastInt32ToFloat32();
311   const Operator* BitcastInt64ToFloat64();
312 
313   // Floating point operators always operate with IEEE 754 round-to-nearest
314   // (single-precision).
315   const Operator* Float32Add();
316   const Operator* Float32Sub();
317   const Operator* Float32SubPreserveNan();
318   const Operator* Float32Mul();
319   const Operator* Float32Div();
320   const Operator* Float32Sqrt();
321 
322   // Floating point operators always operate with IEEE 754 round-to-nearest
323   // (double-precision).
324   const Operator* Float64Add();
325   const Operator* Float64Sub();
326   const Operator* Float64SubPreserveNan();
327   const Operator* Float64Mul();
328   const Operator* Float64Div();
329   const Operator* Float64Mod();
330   const Operator* Float64Sqrt();
331 
332   // Floating point comparisons complying to IEEE 754 (single-precision).
333   const Operator* Float32Equal();
334   const Operator* Float32LessThan();
335   const Operator* Float32LessThanOrEqual();
336 
337   // Floating point comparisons complying to IEEE 754 (double-precision).
338   const Operator* Float64Equal();
339   const Operator* Float64LessThan();
340   const Operator* Float64LessThanOrEqual();
341 
342   // Floating point min/max complying to IEEE 754 (single-precision).
343   const OptionalOperator Float32Max();
344   const OptionalOperator Float32Min();
345 
346   // Floating point min/max complying to IEEE 754 (double-precision).
347   const OptionalOperator Float64Max();
348   const OptionalOperator Float64Min();
349 
350   // Floating point abs complying to IEEE 754 (single-precision).
351   const Operator* Float32Abs();
352 
353   // Floating point abs complying to IEEE 754 (double-precision).
354   const Operator* Float64Abs();
355 
356   // Floating point rounding.
357   const OptionalOperator Float32RoundDown();
358   const OptionalOperator Float64RoundDown();
359   const OptionalOperator Float32RoundUp();
360   const OptionalOperator Float64RoundUp();
361   const OptionalOperator Float32RoundTruncate();
362   const OptionalOperator Float64RoundTruncate();
363   const OptionalOperator Float64RoundTiesAway();
364   const OptionalOperator Float32RoundTiesEven();
365   const OptionalOperator Float64RoundTiesEven();
366 
367   // Floating point neg.
368   const OptionalOperator Float32Neg();
369   const OptionalOperator Float64Neg();
370 
371   // Floating point trigonometric functions (double-precision).
372   const Operator* Float64Atan();
373   const Operator* Float64Atan2();
374   const Operator* Float64Atanh();
375 
376   // Floating point trigonometric functions (double-precision).
377   const Operator* Float64Cos();
378   const Operator* Float64Sin();
379   const Operator* Float64Tan();
380 
381   // Floating point exponential functions (double-precision).
382   const Operator* Float64Exp();
383 
384   // Floating point logarithm (double-precision).
385   const Operator* Float64Log();
386   const Operator* Float64Log1p();
387   const Operator* Float64Log2();
388   const Operator* Float64Log10();
389 
390   const Operator* Float64Cbrt();
391   const Operator* Float64Expm1();
392 
393   // Floating point bit representation.
394   const Operator* Float64ExtractLowWord32();
395   const Operator* Float64ExtractHighWord32();
396   const Operator* Float64InsertLowWord32();
397   const Operator* Float64InsertHighWord32();
398 
399   // Change signalling NaN to quiet NaN.
400   // Identity for any input that is not signalling NaN.
401   const Operator* Float64SilenceNaN();
402 
403   // SIMD operators.
404   const Operator* CreateFloat32x4();
405   const Operator* Float32x4ExtractLane();
406   const Operator* Float32x4ReplaceLane();
407   const Operator* Float32x4Abs();
408   const Operator* Float32x4Neg();
409   const Operator* Float32x4Sqrt();
410   const Operator* Float32x4RecipApprox();
411   const Operator* Float32x4RecipSqrtApprox();
412   const Operator* Float32x4Add();
413   const Operator* Float32x4Sub();
414   const Operator* Float32x4Mul();
415   const Operator* Float32x4Div();
416   const Operator* Float32x4Min();
417   const Operator* Float32x4Max();
418   const Operator* Float32x4MinNum();
419   const Operator* Float32x4MaxNum();
420   const Operator* Float32x4Equal();
421   const Operator* Float32x4NotEqual();
422   const Operator* Float32x4LessThan();
423   const Operator* Float32x4LessThanOrEqual();
424   const Operator* Float32x4GreaterThan();
425   const Operator* Float32x4GreaterThanOrEqual();
426   const Operator* Float32x4Select();
427   const Operator* Float32x4Swizzle();
428   const Operator* Float32x4Shuffle();
429   const Operator* Float32x4FromInt32x4();
430   const Operator* Float32x4FromUint32x4();
431 
432   const Operator* CreateInt32x4();
433   const Operator* Int32x4ExtractLane();
434   const Operator* Int32x4ReplaceLane();
435   const Operator* Int32x4Neg();
436   const Operator* Int32x4Add();
437   const Operator* Int32x4Sub();
438   const Operator* Int32x4Mul();
439   const Operator* Int32x4Min();
440   const Operator* Int32x4Max();
441   const Operator* Int32x4ShiftLeftByScalar();
442   const Operator* Int32x4ShiftRightByScalar();
443   const Operator* Int32x4Equal();
444   const Operator* Int32x4NotEqual();
445   const Operator* Int32x4LessThan();
446   const Operator* Int32x4LessThanOrEqual();
447   const Operator* Int32x4GreaterThan();
448   const Operator* Int32x4GreaterThanOrEqual();
449   const Operator* Int32x4Select();
450   const Operator* Int32x4Swizzle();
451   const Operator* Int32x4Shuffle();
452   const Operator* Int32x4FromFloat32x4();
453 
454   const Operator* Uint32x4Min();
455   const Operator* Uint32x4Max();
456   const Operator* Uint32x4ShiftLeftByScalar();
457   const Operator* Uint32x4ShiftRightByScalar();
458   const Operator* Uint32x4LessThan();
459   const Operator* Uint32x4LessThanOrEqual();
460   const Operator* Uint32x4GreaterThan();
461   const Operator* Uint32x4GreaterThanOrEqual();
462   const Operator* Uint32x4FromFloat32x4();
463 
464   const Operator* CreateBool32x4();
465   const Operator* Bool32x4ExtractLane();
466   const Operator* Bool32x4ReplaceLane();
467   const Operator* Bool32x4And();
468   const Operator* Bool32x4Or();
469   const Operator* Bool32x4Xor();
470   const Operator* Bool32x4Not();
471   const Operator* Bool32x4AnyTrue();
472   const Operator* Bool32x4AllTrue();
473   const Operator* Bool32x4Swizzle();
474   const Operator* Bool32x4Shuffle();
475   const Operator* Bool32x4Equal();
476   const Operator* Bool32x4NotEqual();
477 
478   const Operator* CreateInt16x8();
479   const Operator* Int16x8ExtractLane();
480   const Operator* Int16x8ReplaceLane();
481   const Operator* Int16x8Neg();
482   const Operator* Int16x8Add();
483   const Operator* Int16x8AddSaturate();
484   const Operator* Int16x8Sub();
485   const Operator* Int16x8SubSaturate();
486   const Operator* Int16x8Mul();
487   const Operator* Int16x8Min();
488   const Operator* Int16x8Max();
489   const Operator* Int16x8ShiftLeftByScalar();
490   const Operator* Int16x8ShiftRightByScalar();
491   const Operator* Int16x8Equal();
492   const Operator* Int16x8NotEqual();
493   const Operator* Int16x8LessThan();
494   const Operator* Int16x8LessThanOrEqual();
495   const Operator* Int16x8GreaterThan();
496   const Operator* Int16x8GreaterThanOrEqual();
497   const Operator* Int16x8Select();
498   const Operator* Int16x8Swizzle();
499   const Operator* Int16x8Shuffle();
500 
501   const Operator* Uint16x8AddSaturate();
502   const Operator* Uint16x8SubSaturate();
503   const Operator* Uint16x8Min();
504   const Operator* Uint16x8Max();
505   const Operator* Uint16x8ShiftLeftByScalar();
506   const Operator* Uint16x8ShiftRightByScalar();
507   const Operator* Uint16x8LessThan();
508   const Operator* Uint16x8LessThanOrEqual();
509   const Operator* Uint16x8GreaterThan();
510   const Operator* Uint16x8GreaterThanOrEqual();
511 
512   const Operator* CreateBool16x8();
513   const Operator* Bool16x8ExtractLane();
514   const Operator* Bool16x8ReplaceLane();
515   const Operator* Bool16x8And();
516   const Operator* Bool16x8Or();
517   const Operator* Bool16x8Xor();
518   const Operator* Bool16x8Not();
519   const Operator* Bool16x8AnyTrue();
520   const Operator* Bool16x8AllTrue();
521   const Operator* Bool16x8Swizzle();
522   const Operator* Bool16x8Shuffle();
523   const Operator* Bool16x8Equal();
524   const Operator* Bool16x8NotEqual();
525 
526   const Operator* CreateInt8x16();
527   const Operator* Int8x16ExtractLane();
528   const Operator* Int8x16ReplaceLane();
529   const Operator* Int8x16Neg();
530   const Operator* Int8x16Add();
531   const Operator* Int8x16AddSaturate();
532   const Operator* Int8x16Sub();
533   const Operator* Int8x16SubSaturate();
534   const Operator* Int8x16Mul();
535   const Operator* Int8x16Min();
536   const Operator* Int8x16Max();
537   const Operator* Int8x16ShiftLeftByScalar();
538   const Operator* Int8x16ShiftRightByScalar();
539   const Operator* Int8x16Equal();
540   const Operator* Int8x16NotEqual();
541   const Operator* Int8x16LessThan();
542   const Operator* Int8x16LessThanOrEqual();
543   const Operator* Int8x16GreaterThan();
544   const Operator* Int8x16GreaterThanOrEqual();
545   const Operator* Int8x16Select();
546   const Operator* Int8x16Swizzle();
547   const Operator* Int8x16Shuffle();
548 
549   const Operator* Uint8x16AddSaturate();
550   const Operator* Uint8x16SubSaturate();
551   const Operator* Uint8x16Min();
552   const Operator* Uint8x16Max();
553   const Operator* Uint8x16ShiftLeftByScalar();
554   const Operator* Uint8x16ShiftRightByScalar();
555   const Operator* Uint8x16LessThan();
556   const Operator* Uint8x16LessThanOrEqual();
557   const Operator* Uint8x16GreaterThan();
558   const Operator* Uint8x16GreaterThanOrEqual();
559 
560   const Operator* CreateBool8x16();
561   const Operator* Bool8x16ExtractLane();
562   const Operator* Bool8x16ReplaceLane();
563   const Operator* Bool8x16And();
564   const Operator* Bool8x16Or();
565   const Operator* Bool8x16Xor();
566   const Operator* Bool8x16Not();
567   const Operator* Bool8x16AnyTrue();
568   const Operator* Bool8x16AllTrue();
569   const Operator* Bool8x16Swizzle();
570   const Operator* Bool8x16Shuffle();
571   const Operator* Bool8x16Equal();
572   const Operator* Bool8x16NotEqual();
573 
574   const Operator* Simd128Load();
575   const Operator* Simd128Load1();
576   const Operator* Simd128Load2();
577   const Operator* Simd128Load3();
578   const Operator* Simd128Store();
579   const Operator* Simd128Store1();
580   const Operator* Simd128Store2();
581   const Operator* Simd128Store3();
582   const Operator* Simd128And();
583   const Operator* Simd128Or();
584   const Operator* Simd128Xor();
585   const Operator* Simd128Not();
586 
587   // load [base + index]
588   const Operator* Load(LoadRepresentation rep);
589 
590   // store [base + index], value
591   const Operator* Store(StoreRepresentation rep);
592 
593   const Operator* StackSlot(MachineRepresentation rep);
594 
595   // Access to the machine stack.
596   const Operator* LoadStackPointer();
597   const Operator* LoadFramePointer();
598   const Operator* LoadParentFramePointer();
599 
600   // checked-load heap, index, length
601   const Operator* CheckedLoad(CheckedLoadRepresentation);
602   // checked-store heap, index, length, value
603   const Operator* CheckedStore(CheckedStoreRepresentation);
604 
605   // atomic-load [base + index]
606   const Operator* AtomicLoad(LoadRepresentation rep);
607   // atomic-store [base + index], value
608   const Operator* AtomicStore(MachineRepresentation rep);
609 
610   // Target machine word-size assumed by this builder.
Is32()611   bool Is32() const { return word() == MachineRepresentation::kWord32; }
Is64()612   bool Is64() const { return word() == MachineRepresentation::kWord64; }
word()613   MachineRepresentation word() const { return word_; }
614 
UnalignedLoadSupported(const MachineType & machineType,uint8_t alignment)615   bool UnalignedLoadSupported(const MachineType& machineType,
616                               uint8_t alignment) {
617     return alignment_requirements_.IsUnalignedLoadSupported(machineType,
618                                                             alignment);
619   }
620 
UnalignedStoreSupported(const MachineType & machineType,uint8_t alignment)621   bool UnalignedStoreSupported(const MachineType& machineType,
622                                uint8_t alignment) {
623     return alignment_requirements_.IsUnalignedStoreSupported(machineType,
624                                                              alignment);
625   }
626 
627 // Pseudo operators that translate to 32/64-bit operators depending on the
628 // word-size of the target machine assumed by this builder.
629 #define PSEUDO_OP_LIST(V) \
630   V(Word, And)            \
631   V(Word, Or)             \
632   V(Word, Xor)            \
633   V(Word, Shl)            \
634   V(Word, Shr)            \
635   V(Word, Sar)            \
636   V(Word, Ror)            \
637   V(Word, Clz)            \
638   V(Word, Equal)          \
639   V(Int, Add)             \
640   V(Int, Sub)             \
641   V(Int, Mul)             \
642   V(Int, Div)             \
643   V(Int, Mod)             \
644   V(Int, LessThan)        \
645   V(Int, LessThanOrEqual) \
646   V(Uint, Div)            \
647   V(Uint, LessThan)       \
648   V(Uint, Mod)
649 #define PSEUDO_OP(Prefix, Suffix)                                \
650   const Operator* Prefix##Suffix() {                             \
651     return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \
652   }
653   PSEUDO_OP_LIST(PSEUDO_OP)
654 #undef PSEUDO_OP
655 #undef PSEUDO_OP_LIST
656 
657  private:
658   Zone* zone_;
659   MachineOperatorGlobalCache const& cache_;
660   MachineRepresentation const word_;
661   Flags const flags_;
662   AlignmentRequirements const alignment_requirements_;
663 
664   DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder);
665 };
666 
667 
668 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags)
669 
670 }  // namespace compiler
671 }  // namespace internal
672 }  // namespace v8
673 
674 #endif  // V8_COMPILER_MACHINE_OPERATOR_H_
675