Line data Source code
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/compiler-specific.h"
9 : #include "src/base/flags.h"
10 : #include "src/globals.h"
11 : #include "src/machine-type.h"
12 : #include "src/utils.h"
13 :
14 : namespace v8 {
15 : namespace internal {
16 : namespace compiler {
17 :
18 : // Forward declarations.
19 : struct MachineOperatorGlobalCache;
20 : class Operator;
21 :
22 :
23 : // For operators that are not supported on all platforms.
24 : class OptionalOperator final {
25 : public:
26 : OptionalOperator(bool supported, const Operator* op)
27 48601 : : supported_(supported), op_(op) {}
28 :
29 : bool IsSupported() const { return supported_; }
30 : // Gets the operator only if it is supported.
31 : const Operator* op() const {
32 : DCHECK(supported_);
33 : return op_;
34 : }
35 : // Always gets the operator, even for unsupported operators. This is useful to
36 : // use the operator as a placeholder in a graph, for instance.
37 : const Operator* placeholder() const { return op_; }
38 :
39 : private:
40 : bool supported_;
41 : const Operator* const op_;
42 : };
43 :
44 :
45 : // A Load needs a MachineType.
46 : typedef MachineType LoadRepresentation;
47 :
48 : LoadRepresentation LoadRepresentationOf(Operator const*);
49 :
50 : // A Store needs a MachineType and a WriteBarrierKind in order to emit the
51 : // correct write barrier.
52 : class StoreRepresentation final {
53 : public:
54 : StoreRepresentation(MachineRepresentation representation,
55 : WriteBarrierKind write_barrier_kind)
56 : : representation_(representation),
57 1915609 : write_barrier_kind_(write_barrier_kind) {}
58 :
59 : MachineRepresentation representation() const { return representation_; }
60 : WriteBarrierKind write_barrier_kind() const { return write_barrier_kind_; }
61 :
62 : private:
63 : MachineRepresentation representation_;
64 : WriteBarrierKind write_barrier_kind_;
65 : };
66 :
67 : V8_EXPORT_PRIVATE bool operator==(StoreRepresentation, StoreRepresentation);
68 : bool operator!=(StoreRepresentation, StoreRepresentation);
69 :
70 : size_t hash_value(StoreRepresentation);
71 :
72 : V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, StoreRepresentation);
73 :
74 : StoreRepresentation const& StoreRepresentationOf(Operator const*);
75 :
76 : typedef MachineType UnalignedLoadRepresentation;
77 :
78 : UnalignedLoadRepresentation UnalignedLoadRepresentationOf(Operator const*);
79 :
80 : // An UnalignedStore needs a MachineType.
81 : typedef MachineRepresentation UnalignedStoreRepresentation;
82 :
83 : UnalignedStoreRepresentation const& UnalignedStoreRepresentationOf(
84 : Operator const*);
85 :
86 : // A CheckedLoad needs a MachineType.
87 : typedef MachineType CheckedLoadRepresentation;
88 :
89 : CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const*);
90 :
91 :
92 : // A CheckedStore needs a MachineType.
93 : typedef MachineRepresentation CheckedStoreRepresentation;
94 :
95 : CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const*);
96 :
97 : class StackSlotRepresentation final {
98 : public:
99 : StackSlotRepresentation(int size, int alignment)
100 2 : : size_(size), alignment_(alignment) {}
101 :
102 : int size() const { return size_; }
103 : int alignment() const { return alignment_; }
104 :
105 : private:
106 : int size_;
107 : int alignment_;
108 : };
109 :
110 : V8_EXPORT_PRIVATE bool operator==(StackSlotRepresentation,
111 : StackSlotRepresentation);
112 : bool operator!=(StackSlotRepresentation, StackSlotRepresentation);
113 :
114 : size_t hash_value(StackSlotRepresentation);
115 :
116 : V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
117 : StackSlotRepresentation);
118 :
119 : StackSlotRepresentation const& StackSlotRepresentationOf(Operator const* op);
120 :
121 : MachineRepresentation AtomicStoreRepresentationOf(Operator const* op);
122 :
123 : MachineType AtomicOpRepresentationOf(Operator const* op);
124 :
125 : // Interface for building machine-level operators. These operators are
126 : // machine-level but machine-independent and thus define a language suitable
127 : // for generating code to run on architectures such as ia32, x64, arm, etc.
128 : class V8_EXPORT_PRIVATE MachineOperatorBuilder final
129 : : public NON_EXPORTED_BASE(ZoneObject) {
130 : public:
131 : // Flags that specify which operations are available. This is useful
132 : // for operations that are unsupported by some back-ends.
133 : enum Flag : unsigned {
134 : kNoFlags = 0u,
135 : kFloat32RoundDown = 1u << 0,
136 : kFloat64RoundDown = 1u << 1,
137 : kFloat32RoundUp = 1u << 2,
138 : kFloat64RoundUp = 1u << 3,
139 : kFloat32RoundTruncate = 1u << 4,
140 : kFloat64RoundTruncate = 1u << 5,
141 : kFloat32RoundTiesEven = 1u << 6,
142 : kFloat64RoundTiesEven = 1u << 7,
143 : kFloat64RoundTiesAway = 1u << 8,
144 : kInt32DivIsSafe = 1u << 9,
145 : kUint32DivIsSafe = 1u << 10,
146 : kWord32ShiftIsSafe = 1u << 11,
147 : kWord32Ctz = 1u << 12,
148 : kWord64Ctz = 1u << 13,
149 : kWord32Popcnt = 1u << 14,
150 : kWord64Popcnt = 1u << 15,
151 : kWord32ReverseBits = 1u << 16,
152 : kWord64ReverseBits = 1u << 17,
153 : kWord32ReverseBytes = 1u << 18,
154 : kWord64ReverseBytes = 1u << 19,
155 : kInt32AbsWithOverflow = 1u << 20,
156 : kInt64AbsWithOverflow = 1u << 21,
157 : kAllOptionalOps =
158 : kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp |
159 : kFloat64RoundUp | kFloat32RoundTruncate | kFloat64RoundTruncate |
160 : kFloat64RoundTiesAway | kFloat32RoundTiesEven | kFloat64RoundTiesEven |
161 : kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt |
162 : kWord32ReverseBits | kWord64ReverseBits | kWord32ReverseBytes |
163 : kWord64ReverseBytes | kInt32AbsWithOverflow | kInt64AbsWithOverflow
164 : };
165 : typedef base::Flags<Flag, unsigned> Flags;
166 :
167 : class AlignmentRequirements {
168 : public:
169 : enum UnalignedAccessSupport { kNoSupport, kSomeSupport, kFullSupport };
170 :
171 31712 : bool IsUnalignedLoadSupported(MachineRepresentation rep) const {
172 31712 : return IsUnalignedSupported(unalignedLoadUnsupportedTypes_, rep);
173 : }
174 :
175 15147 : bool IsUnalignedStoreSupported(MachineRepresentation rep) const {
176 15147 : return IsUnalignedSupported(unalignedStoreUnsupportedTypes_, rep);
177 : }
178 :
179 : static AlignmentRequirements FullUnalignedAccessSupport() {
180 : return AlignmentRequirements(kFullSupport);
181 : }
182 : static AlignmentRequirements NoUnalignedAccessSupport() {
183 : return AlignmentRequirements(kNoSupport);
184 : }
185 : static AlignmentRequirements SomeUnalignedAccessUnsupported(
186 : EnumSet<MachineRepresentation> unalignedLoadUnsupportedTypes,
187 : EnumSet<MachineRepresentation> unalignedStoreUnsupportedTypes) {
188 : return AlignmentRequirements(kSomeSupport, unalignedLoadUnsupportedTypes,
189 : unalignedStoreUnsupportedTypes);
190 : }
191 :
192 : private:
193 : explicit AlignmentRequirements(
194 : AlignmentRequirements::UnalignedAccessSupport unalignedAccessSupport,
195 : EnumSet<MachineRepresentation> unalignedLoadUnsupportedTypes =
196 : EnumSet<MachineRepresentation>(),
197 : EnumSet<MachineRepresentation> unalignedStoreUnsupportedTypes =
198 : EnumSet<MachineRepresentation>())
199 : : unalignedSupport_(unalignedAccessSupport),
200 : unalignedLoadUnsupportedTypes_(unalignedLoadUnsupportedTypes),
201 : unalignedStoreUnsupportedTypes_(unalignedStoreUnsupportedTypes) {}
202 :
203 46848 : bool IsUnalignedSupported(EnumSet<MachineRepresentation> unsupported,
204 : MachineRepresentation rep) const {
205 : // All accesses of bytes in memory are aligned.
206 : DCHECK_NE(MachineRepresentation::kWord8, rep);
207 46848 : switch (unalignedSupport_) {
208 : case kFullSupport:
209 : return true;
210 : case kNoSupport:
211 : return false;
212 : case kSomeSupport:
213 0 : return !unsupported.Contains(rep);
214 : }
215 0 : UNREACHABLE();
216 : }
217 :
218 : const AlignmentRequirements::UnalignedAccessSupport unalignedSupport_;
219 : const EnumSet<MachineRepresentation> unalignedLoadUnsupportedTypes_;
220 : const EnumSet<MachineRepresentation> unalignedStoreUnsupportedTypes_;
221 : };
222 :
223 : explicit MachineOperatorBuilder(
224 : Zone* zone,
225 : MachineRepresentation word = MachineType::PointerRepresentation(),
226 : Flags supportedOperators = kNoFlags,
227 : AlignmentRequirements alignmentRequirements =
228 : AlignmentRequirements::FullUnalignedAccessSupport());
229 :
230 : const Operator* Comment(const char* msg);
231 : const Operator* DebugAbort();
232 : const Operator* DebugBreak();
233 : const Operator* UnsafePointerAdd();
234 :
235 : const Operator* Word32And();
236 : const Operator* Word32Or();
237 : const Operator* Word32Xor();
238 : const Operator* Word32Shl();
239 : const Operator* Word32Shr();
240 : const Operator* Word32Sar();
241 : const Operator* Word32Ror();
242 : const Operator* Word32Equal();
243 : const Operator* Word32Clz();
244 : const OptionalOperator Word32Ctz();
245 : const OptionalOperator Word32Popcnt();
246 : const OptionalOperator Word64Popcnt();
247 : const OptionalOperator Word32ReverseBits();
248 : const OptionalOperator Word64ReverseBits();
249 : const OptionalOperator Word32ReverseBytes();
250 : const OptionalOperator Word64ReverseBytes();
251 : const OptionalOperator Int32AbsWithOverflow();
252 : const OptionalOperator Int64AbsWithOverflow();
253 : bool Word32ShiftIsSafe() const { return flags_ & kWord32ShiftIsSafe; }
254 :
255 : const Operator* Word64And();
256 : const Operator* Word64Or();
257 : const Operator* Word64Xor();
258 : const Operator* Word64Shl();
259 : const Operator* Word64Shr();
260 : const Operator* Word64Sar();
261 : const Operator* Word64Ror();
262 : const Operator* Word64Clz();
263 : const OptionalOperator Word64Ctz();
264 : const Operator* Word64Equal();
265 :
266 : const Operator* Int32PairAdd();
267 : const Operator* Int32PairSub();
268 : const Operator* Int32PairMul();
269 : const Operator* Word32PairShl();
270 : const Operator* Word32PairShr();
271 : const Operator* Word32PairSar();
272 :
273 : const Operator* Int32Add();
274 : const Operator* Int32AddWithOverflow();
275 : const Operator* Int32Sub();
276 : const Operator* Int32SubWithOverflow();
277 : const Operator* Int32Mul();
278 : const Operator* Int32MulWithOverflow();
279 : const Operator* Int32MulHigh();
280 : const Operator* Int32Div();
281 : const Operator* Int32Mod();
282 : const Operator* Int32LessThan();
283 : const Operator* Int32LessThanOrEqual();
284 : const Operator* Uint32Div();
285 : const Operator* Uint32LessThan();
286 : const Operator* Uint32LessThanOrEqual();
287 : const Operator* Uint32Mod();
288 : const Operator* Uint32MulHigh();
289 : bool Int32DivIsSafe() const { return flags_ & kInt32DivIsSafe; }
290 : bool Uint32DivIsSafe() const { return flags_ & kUint32DivIsSafe; }
291 :
292 : const Operator* Int64Add();
293 : const Operator* Int64AddWithOverflow();
294 : const Operator* Int64Sub();
295 : const Operator* Int64SubWithOverflow();
296 : const Operator* Int64Mul();
297 : const Operator* Int64Div();
298 : const Operator* Int64Mod();
299 : const Operator* Int64LessThan();
300 : const Operator* Int64LessThanOrEqual();
301 : const Operator* Uint64Div();
302 : const Operator* Uint64LessThan();
303 : const Operator* Uint64LessThanOrEqual();
304 : const Operator* Uint64Mod();
305 :
306 : // This operator reinterprets the bits of a tagged pointer as word.
307 : const Operator* BitcastTaggedToWord();
308 :
309 : // This operator reinterprets the bits of a word as tagged pointer.
310 : const Operator* BitcastWordToTagged();
311 :
312 : // This operator reinterprets the bits of a word as a Smi.
313 : const Operator* BitcastWordToTaggedSigned();
314 :
315 : // JavaScript float64 to int32/uint32 truncation.
316 : const Operator* TruncateFloat64ToWord32();
317 :
318 : // These operators change the representation of numbers while preserving the
319 : // value of the number. Narrowing operators assume the input is representable
320 : // in the target type and are *not* defined for other inputs.
321 : // Use narrowing change operators only when there is a static guarantee that
322 : // the input value is representable in the target value.
323 : const Operator* ChangeFloat32ToFloat64();
324 : const Operator* ChangeFloat64ToInt32(); // narrowing
325 : const Operator* ChangeFloat64ToUint32(); // narrowing
326 : const Operator* ChangeFloat64ToUint64();
327 : const Operator* TruncateFloat64ToUint32();
328 : const Operator* TruncateFloat32ToInt32();
329 : const Operator* TruncateFloat32ToUint32();
330 : const Operator* TryTruncateFloat32ToInt64();
331 : const Operator* TryTruncateFloat64ToInt64();
332 : const Operator* TryTruncateFloat32ToUint64();
333 : const Operator* TryTruncateFloat64ToUint64();
334 : const Operator* ChangeInt32ToFloat64();
335 : const Operator* ChangeInt32ToInt64();
336 : const Operator* ChangeUint32ToFloat64();
337 : const Operator* ChangeUint32ToUint64();
338 :
339 : // These operators truncate or round numbers, both changing the representation
340 : // of the number and mapping multiple input values onto the same output value.
341 : const Operator* TruncateFloat64ToFloat32();
342 : const Operator* TruncateInt64ToInt32();
343 : const Operator* RoundFloat64ToInt32();
344 : const Operator* RoundInt32ToFloat32();
345 : const Operator* RoundInt64ToFloat32();
346 : const Operator* RoundInt64ToFloat64();
347 : const Operator* RoundUint32ToFloat32();
348 : const Operator* RoundUint64ToFloat32();
349 : const Operator* RoundUint64ToFloat64();
350 :
351 : // These operators reinterpret the bits of a floating point number as an
352 : // integer and vice versa.
353 : const Operator* BitcastFloat32ToInt32();
354 : const Operator* BitcastFloat64ToInt64();
355 : const Operator* BitcastInt32ToFloat32();
356 : const Operator* BitcastInt64ToFloat64();
357 :
358 : // Floating point operators always operate with IEEE 754 round-to-nearest
359 : // (single-precision).
360 : const Operator* Float32Add();
361 : const Operator* Float32Sub();
362 : const Operator* Float32Mul();
363 : const Operator* Float32Div();
364 : const Operator* Float32Sqrt();
365 :
366 : // Floating point operators always operate with IEEE 754 round-to-nearest
367 : // (double-precision).
368 : const Operator* Float64Add();
369 : const Operator* Float64Sub();
370 : const Operator* Float64Mul();
371 : const Operator* Float64Div();
372 : const Operator* Float64Mod();
373 : const Operator* Float64Sqrt();
374 :
375 : // Floating point comparisons complying to IEEE 754 (single-precision).
376 : const Operator* Float32Equal();
377 : const Operator* Float32LessThan();
378 : const Operator* Float32LessThanOrEqual();
379 :
380 : // Floating point comparisons complying to IEEE 754 (double-precision).
381 : const Operator* Float64Equal();
382 : const Operator* Float64LessThan();
383 : const Operator* Float64LessThanOrEqual();
384 :
385 : // Floating point min/max complying to EcmaScript 6 (double-precision).
386 : const Operator* Float64Max();
387 : const Operator* Float64Min();
388 : // Floating point min/max complying to WebAssembly (single-precision).
389 : const Operator* Float32Max();
390 : const Operator* Float32Min();
391 :
392 : // Floating point abs complying to IEEE 754 (single-precision).
393 : const Operator* Float32Abs();
394 :
395 : // Floating point abs complying to IEEE 754 (double-precision).
396 : const Operator* Float64Abs();
397 :
398 : // Floating point rounding.
399 : const OptionalOperator Float32RoundDown();
400 : const OptionalOperator Float64RoundDown();
401 : const OptionalOperator Float32RoundUp();
402 : const OptionalOperator Float64RoundUp();
403 : const OptionalOperator Float32RoundTruncate();
404 : const OptionalOperator Float64RoundTruncate();
405 : const OptionalOperator Float64RoundTiesAway();
406 : const OptionalOperator Float32RoundTiesEven();
407 : const OptionalOperator Float64RoundTiesEven();
408 :
409 : // Floating point neg.
410 : const Operator* Float32Neg();
411 : const Operator* Float64Neg();
412 :
413 : // Floating point trigonometric functions (double-precision).
414 : const Operator* Float64Acos();
415 : const Operator* Float64Acosh();
416 : const Operator* Float64Asin();
417 : const Operator* Float64Asinh();
418 : const Operator* Float64Atan();
419 : const Operator* Float64Atan2();
420 : const Operator* Float64Atanh();
421 : const Operator* Float64Cos();
422 : const Operator* Float64Cosh();
423 : const Operator* Float64Sin();
424 : const Operator* Float64Sinh();
425 : const Operator* Float64Tan();
426 : const Operator* Float64Tanh();
427 :
428 : // Floating point exponential functions (double-precision).
429 : const Operator* Float64Exp();
430 : const Operator* Float64Expm1();
431 : const Operator* Float64Pow();
432 :
433 : // Floating point logarithm (double-precision).
434 : const Operator* Float64Log();
435 : const Operator* Float64Log1p();
436 : const Operator* Float64Log2();
437 : const Operator* Float64Log10();
438 :
439 : // Floating point cube root (double-precision).
440 : const Operator* Float64Cbrt();
441 :
442 : // Floating point bit representation.
443 : const Operator* Float64ExtractLowWord32();
444 : const Operator* Float64ExtractHighWord32();
445 : const Operator* Float64InsertLowWord32();
446 : const Operator* Float64InsertHighWord32();
447 :
448 : // Change signalling NaN to quiet NaN.
449 : // Identity for any input that is not signalling NaN.
450 : const Operator* Float64SilenceNaN();
451 :
452 : // SIMD operators.
453 : const Operator* F32x4Splat();
454 : const Operator* F32x4ExtractLane(int32_t);
455 : const Operator* F32x4ReplaceLane(int32_t);
456 : const Operator* F32x4SConvertI32x4();
457 : const Operator* F32x4UConvertI32x4();
458 : const Operator* F32x4Abs();
459 : const Operator* F32x4Neg();
460 : const Operator* F32x4RecipApprox();
461 : const Operator* F32x4RecipSqrtApprox();
462 : const Operator* F32x4Add();
463 : const Operator* F32x4AddHoriz();
464 : const Operator* F32x4Sub();
465 : const Operator* F32x4Mul();
466 : const Operator* F32x4Div();
467 : const Operator* F32x4Min();
468 : const Operator* F32x4Max();
469 : const Operator* F32x4Eq();
470 : const Operator* F32x4Ne();
471 : const Operator* F32x4Lt();
472 : const Operator* F32x4Le();
473 :
474 : const Operator* I32x4Splat();
475 : const Operator* I32x4ExtractLane(int32_t);
476 : const Operator* I32x4ReplaceLane(int32_t);
477 : const Operator* I32x4SConvertF32x4();
478 : const Operator* I32x4SConvertI16x8Low();
479 : const Operator* I32x4SConvertI16x8High();
480 : const Operator* I32x4Neg();
481 : const Operator* I32x4Shl(int32_t);
482 : const Operator* I32x4ShrS(int32_t);
483 : const Operator* I32x4Add();
484 : const Operator* I32x4AddHoriz();
485 : const Operator* I32x4Sub();
486 : const Operator* I32x4Mul();
487 : const Operator* I32x4MinS();
488 : const Operator* I32x4MaxS();
489 : const Operator* I32x4Eq();
490 : const Operator* I32x4Ne();
491 : const Operator* I32x4GtS();
492 : const Operator* I32x4GeS();
493 :
494 : const Operator* I32x4UConvertF32x4();
495 : const Operator* I32x4UConvertI16x8Low();
496 : const Operator* I32x4UConvertI16x8High();
497 : const Operator* I32x4ShrU(int32_t);
498 : const Operator* I32x4MinU();
499 : const Operator* I32x4MaxU();
500 : const Operator* I32x4GtU();
501 : const Operator* I32x4GeU();
502 :
503 : const Operator* I16x8Splat();
504 : const Operator* I16x8ExtractLane(int32_t);
505 : const Operator* I16x8ReplaceLane(int32_t);
506 : const Operator* I16x8SConvertI8x16Low();
507 : const Operator* I16x8SConvertI8x16High();
508 : const Operator* I16x8Neg();
509 : const Operator* I16x8Shl(int32_t);
510 : const Operator* I16x8ShrS(int32_t);
511 : const Operator* I16x8SConvertI32x4();
512 : const Operator* I16x8Add();
513 : const Operator* I16x8AddSaturateS();
514 : const Operator* I16x8AddHoriz();
515 : const Operator* I16x8Sub();
516 : const Operator* I16x8SubSaturateS();
517 : const Operator* I16x8Mul();
518 : const Operator* I16x8MinS();
519 : const Operator* I16x8MaxS();
520 : const Operator* I16x8Eq();
521 : const Operator* I16x8Ne();
522 : const Operator* I16x8GtS();
523 : const Operator* I16x8GeS();
524 :
525 : const Operator* I16x8UConvertI8x16Low();
526 : const Operator* I16x8UConvertI8x16High();
527 : const Operator* I16x8ShrU(int32_t);
528 : const Operator* I16x8UConvertI32x4();
529 : const Operator* I16x8AddSaturateU();
530 : const Operator* I16x8SubSaturateU();
531 : const Operator* I16x8MinU();
532 : const Operator* I16x8MaxU();
533 : const Operator* I16x8GtU();
534 : const Operator* I16x8GeU();
535 :
536 : const Operator* I8x16Splat();
537 : const Operator* I8x16ExtractLane(int32_t);
538 : const Operator* I8x16ReplaceLane(int32_t);
539 : const Operator* I8x16Neg();
540 : const Operator* I8x16Shl(int32_t);
541 : const Operator* I8x16ShrS(int32_t);
542 : const Operator* I8x16SConvertI16x8();
543 : const Operator* I8x16Add();
544 : const Operator* I8x16AddSaturateS();
545 : const Operator* I8x16Sub();
546 : const Operator* I8x16SubSaturateS();
547 : const Operator* I8x16Mul();
548 : const Operator* I8x16MinS();
549 : const Operator* I8x16MaxS();
550 : const Operator* I8x16Eq();
551 : const Operator* I8x16Ne();
552 : const Operator* I8x16GtS();
553 : const Operator* I8x16GeS();
554 :
555 : const Operator* I8x16ShrU(int32_t);
556 : const Operator* I8x16UConvertI16x8();
557 : const Operator* I8x16AddSaturateU();
558 : const Operator* I8x16SubSaturateU();
559 : const Operator* I8x16MinU();
560 : const Operator* I8x16MaxU();
561 : const Operator* I8x16GtU();
562 : const Operator* I8x16GeU();
563 :
564 : const Operator* S128Load();
565 : const Operator* S128Store();
566 :
567 : const Operator* S128Zero();
568 : const Operator* S128And();
569 : const Operator* S128Or();
570 : const Operator* S128Xor();
571 : const Operator* S128Not();
572 : const Operator* S128Select();
573 :
574 : const Operator* S8x16Shuffle(const uint8_t shuffle[16]);
575 :
576 : const Operator* S1x4AnyTrue();
577 : const Operator* S1x4AllTrue();
578 : const Operator* S1x8AnyTrue();
579 : const Operator* S1x8AllTrue();
580 : const Operator* S1x16AnyTrue();
581 : const Operator* S1x16AllTrue();
582 :
583 : // load [base + index]
584 : const Operator* Load(LoadRepresentation rep);
585 : const Operator* ProtectedLoad(LoadRepresentation rep);
586 :
587 : // store [base + index], value
588 : const Operator* Store(StoreRepresentation rep);
589 : const Operator* ProtectedStore(MachineRepresentation rep);
590 :
591 : // unaligned load [base + index]
592 : const Operator* UnalignedLoad(UnalignedLoadRepresentation rep);
593 :
594 : // unaligned store [base + index], value
595 : const Operator* UnalignedStore(UnalignedStoreRepresentation rep);
596 :
597 : const Operator* StackSlot(int size, int alignment = 0);
598 : const Operator* StackSlot(MachineRepresentation rep, int alignment = 0);
599 :
600 : // Access to the machine stack.
601 : const Operator* LoadStackPointer();
602 : const Operator* LoadFramePointer();
603 : const Operator* LoadParentFramePointer();
604 :
605 : // checked-load heap, index, length
606 : const Operator* CheckedLoad(CheckedLoadRepresentation);
607 : // checked-store heap, index, length, value
608 : const Operator* CheckedStore(CheckedStoreRepresentation);
609 :
610 : // atomic-load [base + index]
611 : const Operator* AtomicLoad(LoadRepresentation rep);
612 : // atomic-store [base + index], value
613 : const Operator* AtomicStore(MachineRepresentation rep);
614 : // atomic-exchange [base + index], value
615 : const Operator* AtomicExchange(MachineType rep);
616 : // atomic-compare-exchange [base + index], old_value, new_value
617 : const Operator* AtomicCompareExchange(MachineType rep);
618 : // atomic-add [base + index], value
619 : const Operator* AtomicAdd(MachineType rep);
620 : // atomic-sub [base + index], value
621 : const Operator* AtomicSub(MachineType rep);
622 : // atomic-and [base + index], value
623 : const Operator* AtomicAnd(MachineType rep);
624 : // atomic-or [base + index], value
625 : const Operator* AtomicOr(MachineType rep);
626 : // atomic-xor [base + index], value
627 : const Operator* AtomicXor(MachineType rep);
628 :
629 : // Target machine word-size assumed by this builder.
630 10631421 : bool Is32() const { return word() == MachineRepresentation::kWord32; }
631 1809916 : bool Is64() const { return word() == MachineRepresentation::kWord64; }
632 : MachineRepresentation word() const { return word_; }
633 :
634 : bool UnalignedLoadSupported(MachineRepresentation rep) {
635 31712 : return alignment_requirements_.IsUnalignedLoadSupported(rep);
636 : }
637 :
638 : bool UnalignedStoreSupported(MachineRepresentation rep) {
639 15147 : return alignment_requirements_.IsUnalignedStoreSupported(rep);
640 : }
641 :
642 : // Pseudo operators that translate to 32/64-bit operators depending on the
643 : // word-size of the target machine assumed by this builder.
644 : #define PSEUDO_OP_LIST(V) \
645 : V(Word, And) \
646 : V(Word, Or) \
647 : V(Word, Xor) \
648 : V(Word, Shl) \
649 : V(Word, Shr) \
650 : V(Word, Sar) \
651 : V(Word, Ror) \
652 : V(Word, Clz) \
653 : V(Word, Equal) \
654 : V(Int, Add) \
655 : V(Int, Sub) \
656 : V(Int, Mul) \
657 : V(Int, Div) \
658 : V(Int, Mod) \
659 : V(Int, LessThan) \
660 : V(Int, LessThanOrEqual) \
661 : V(Uint, Div) \
662 : V(Uint, LessThan) \
663 : V(Uint, Mod)
664 : #define PSEUDO_OP(Prefix, Suffix) \
665 : const Operator* Prefix##Suffix() { \
666 : return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \
667 : }
668 8118872 : PSEUDO_OP_LIST(PSEUDO_OP)
669 : #undef PSEUDO_OP
670 : #undef PSEUDO_OP_LIST
671 :
672 : private:
673 : Zone* zone_;
674 : MachineOperatorGlobalCache const& cache_;
675 : MachineRepresentation const word_;
676 : Flags const flags_;
677 : AlignmentRequirements const alignment_requirements_;
678 :
679 : DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder);
680 : };
681 :
682 :
683 : DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags)
684 :
685 : } // namespace compiler
686 : } // namespace internal
687 : } // namespace v8
688 :
689 : #endif // V8_COMPILER_MACHINE_OPERATOR_H_
|