5 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_ 6 #define V8_COMPILER_MACHINE_OPERATOR_H_ 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 #include "src/zone/zone.h" 20 struct MachineOperatorGlobalCache;
28 : supported_(supported), op_(op) {}
30 bool IsSupported()
const {
return supported_; }
38 const Operator* placeholder()
const {
return op_; }
50 V8_WARN_UNUSED_RESULT;
57 WriteBarrierKind write_barrier_kind)
58 : representation_(representation),
59 write_barrier_kind_(write_barrier_kind) {}
61 MachineRepresentation representation()
const {
return representation_; }
62 WriteBarrierKind write_barrier_kind()
const {
return write_barrier_kind_; }
65 MachineRepresentation representation_;
66 WriteBarrierKind write_barrier_kind_;
77 Operator const*) V8_WARN_UNUSED_RESULT;
80 typedef MachineRepresentation UnalignedStoreRepresentation;
82 UnalignedStoreRepresentation
const& UnalignedStoreRepresentationOf(
83 Operator const*) V8_WARN_UNUSED_RESULT;
88 : size_(size), alignment_(alignment) {}
90 int size()
const {
return size_; }
91 int alignment()
const {
return alignment_; }
104 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
108 Operator const* op) V8_WARN_UNUSED_RESULT;
110 MachineRepresentation AtomicStoreRepresentationOf(
Operator const* op)
111 V8_WARN_UNUSED_RESULT;
119 :
public NON_EXPORTED_BASE(ZoneObject) {
123 enum Flag :
unsigned {
125 kFloat32RoundDown = 1u << 0,
126 kFloat64RoundDown = 1u << 1,
127 kFloat32RoundUp = 1u << 2,
128 kFloat64RoundUp = 1u << 3,
129 kFloat32RoundTruncate = 1u << 4,
130 kFloat64RoundTruncate = 1u << 5,
131 kFloat32RoundTiesEven = 1u << 6,
132 kFloat64RoundTiesEven = 1u << 7,
133 kFloat64RoundTiesAway = 1u << 8,
134 kInt32DivIsSafe = 1u << 9,
135 kUint32DivIsSafe = 1u << 10,
136 kWord32ShiftIsSafe = 1u << 11,
137 kWord32Ctz = 1u << 12,
138 kWord64Ctz = 1u << 13,
139 kWord32Popcnt = 1u << 14,
140 kWord64Popcnt = 1u << 15,
141 kWord32ReverseBits = 1u << 16,
142 kWord64ReverseBits = 1u << 17,
143 kInt32AbsWithOverflow = 1u << 20,
144 kInt64AbsWithOverflow = 1u << 21,
145 kSpeculationFence = 1u << 22,
147 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp |
148 kFloat64RoundUp | kFloat32RoundTruncate | kFloat64RoundTruncate |
149 kFloat64RoundTiesAway | kFloat32RoundTiesEven | kFloat64RoundTiesEven |
150 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt |
151 kWord32ReverseBits | kWord64ReverseBits | kInt32AbsWithOverflow |
152 kInt64AbsWithOverflow | kSpeculationFence
158 enum UnalignedAccessSupport { kNoSupport, kSomeSupport, kFullSupport };
160 bool IsUnalignedLoadSupported(MachineRepresentation rep)
const {
161 return IsUnalignedSupported(unalignedLoadUnsupportedTypes_, rep);
164 bool IsUnalignedStoreSupported(MachineRepresentation rep)
const {
165 return IsUnalignedSupported(unalignedStoreUnsupportedTypes_, rep);
178 unalignedStoreUnsupportedTypes);
183 AlignmentRequirements::UnalignedAccessSupport unalignedAccessSupport,
188 : unalignedSupport_(unalignedAccessSupport),
189 unalignedLoadUnsupportedTypes_(unalignedLoadUnsupportedTypes),
190 unalignedStoreUnsupportedTypes_(unalignedStoreUnsupportedTypes) {}
193 MachineRepresentation rep)
const {
195 DCHECK_NE(MachineRepresentation::kWord8, rep);
196 switch (unalignedSupport_) {
202 return !unsupported.Contains(rep);
207 const AlignmentRequirements::UnalignedAccessSupport unalignedSupport_;
214 MachineRepresentation word = MachineType::PointerRepresentation(),
215 Flags supportedOperators = kNoFlags,
217 AlignmentRequirements::FullUnalignedAccessSupport());
219 const Operator* Comment(
const char* msg);
238 const Operator* Word32ReverseBytes();
239 const Operator* Word64ReverseBytes();
246 bool Word32ShiftIsSafe()
const {
return flags_ & kWord32ShiftIsSafe; }
267 const Operator* Int32AddWithOverflow();
269 const Operator* Int32SubWithOverflow();
271 const Operator* Int32MulWithOverflow();
276 const Operator* Int32LessThanOrEqual();
279 const Operator* Uint32LessThanOrEqual();
282 bool Int32DivIsSafe()
const {
return flags_ & kInt32DivIsSafe; }
283 bool Uint32DivIsSafe()
const {
return flags_ & kUint32DivIsSafe; }
285 const Operator* Int64Add();
286 const Operator* Int64AddWithOverflow();
287 const Operator* Int64Sub();
288 const Operator* Int64SubWithOverflow();
289 const Operator* Int64Mul();
290 const Operator* Int64Div();
291 const Operator* Int64Mod();
292 const Operator* Int64LessThan();
293 const Operator* Int64LessThanOrEqual();
294 const Operator* Uint64Div();
295 const Operator* Uint64LessThan();
296 const Operator* Uint64LessThanOrEqual();
297 const Operator* Uint64Mod();
300 const Operator* BitcastTaggedToWord();
304 const Operator* BitcastMaybeObjectToWord();
307 const Operator* BitcastWordToTagged();
310 const Operator* BitcastWordToTaggedSigned();
313 const Operator* TruncateFloat64ToWord32();
320 const Operator* ChangeFloat32ToFloat64();
321 const Operator* ChangeFloat64ToInt32();
322 const Operator* ChangeFloat64ToInt64();
323 const Operator* ChangeFloat64ToUint32();
324 const Operator* ChangeFloat64ToUint64();
325 const Operator* TruncateFloat64ToInt64();
326 const Operator* TruncateFloat64ToUint32();
327 const Operator* TruncateFloat32ToInt32();
328 const Operator* TruncateFloat32ToUint32();
329 const Operator* TryTruncateFloat32ToInt64();
330 const Operator* TryTruncateFloat64ToInt64();
331 const Operator* TryTruncateFloat32ToUint64();
332 const Operator* TryTruncateFloat64ToUint64();
333 const Operator* ChangeInt32ToFloat64();
334 const Operator* ChangeInt32ToInt64();
335 const Operator* ChangeInt64ToFloat64();
336 const Operator* ChangeUint32ToFloat64();
337 const Operator* ChangeUint32ToUint64();
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();
353 const Operator* BitcastFloat32ToInt32();
354 const Operator* BitcastFloat64ToInt64();
355 const Operator* BitcastInt32ToFloat32();
356 const Operator* BitcastInt64ToFloat64();
359 const Operator* SignExtendWord8ToInt32();
360 const Operator* SignExtendWord16ToInt32();
361 const Operator* SignExtendWord8ToInt64();
362 const Operator* SignExtendWord16ToInt64();
363 const Operator* SignExtendWord32ToInt64();
367 const Operator* Float32Add();
368 const Operator* Float32Sub();
369 const Operator* Float32Mul();
370 const Operator* Float32Div();
371 const Operator* Float32Sqrt();
375 const Operator* Float64Add();
376 const Operator* Float64Sub();
377 const Operator* Float64Mul();
378 const Operator* Float64Div();
379 const Operator* Float64Mod();
380 const Operator* Float64Sqrt();
383 const Operator* Float32Equal();
384 const Operator* Float32LessThan();
385 const Operator* Float32LessThanOrEqual();
388 const Operator* Float64Equal();
389 const Operator* Float64LessThan();
390 const Operator* Float64LessThanOrEqual();
393 const Operator* Float64Max();
394 const Operator* Float64Min();
396 const Operator* Float32Max();
397 const Operator* Float32Min();
400 const Operator* Float32Abs();
403 const Operator* Float64Abs();
406 const OptionalOperator Float32RoundDown();
407 const OptionalOperator Float64RoundDown();
408 const OptionalOperator Float32RoundUp();
409 const OptionalOperator Float64RoundUp();
410 const OptionalOperator Float32RoundTruncate();
411 const OptionalOperator Float64RoundTruncate();
412 const OptionalOperator Float64RoundTiesAway();
413 const OptionalOperator Float32RoundTiesEven();
414 const OptionalOperator Float64RoundTiesEven();
417 const Operator* Float32Neg();
418 const Operator* Float64Neg();
421 const Operator* Float64Acos();
422 const Operator* Float64Acosh();
423 const Operator* Float64Asin();
424 const Operator* Float64Asinh();
425 const Operator* Float64Atan();
426 const Operator* Float64Atan2();
427 const Operator* Float64Atanh();
428 const Operator* Float64Cos();
429 const Operator* Float64Cosh();
430 const Operator* Float64Sin();
431 const Operator* Float64Sinh();
432 const Operator* Float64Tan();
433 const Operator* Float64Tanh();
436 const Operator* Float64Exp();
437 const Operator* Float64Expm1();
438 const Operator* Float64Pow();
441 const Operator* Float64Log();
442 const Operator* Float64Log1p();
443 const Operator* Float64Log2();
444 const Operator* Float64Log10();
447 const Operator* Float64Cbrt();
450 const Operator* Float64ExtractLowWord32();
451 const Operator* Float64ExtractHighWord32();
452 const Operator* Float64InsertLowWord32();
453 const Operator* Float64InsertHighWord32();
457 const Operator* Float64SilenceNaN();
460 const Operator* F32x4Splat();
461 const Operator* F32x4ExtractLane(int32_t);
462 const Operator* F32x4ReplaceLane(int32_t);
463 const Operator* F32x4SConvertI32x4();
464 const Operator* F32x4UConvertI32x4();
465 const Operator* F32x4Abs();
466 const Operator* F32x4Neg();
467 const Operator* F32x4RecipApprox();
468 const Operator* F32x4RecipSqrtApprox();
469 const Operator* F32x4Add();
470 const Operator* F32x4AddHoriz();
471 const Operator* F32x4Sub();
472 const Operator* F32x4Mul();
473 const Operator* F32x4Div();
474 const Operator* F32x4Min();
475 const Operator* F32x4Max();
476 const Operator* F32x4Eq();
477 const Operator* F32x4Ne();
478 const Operator* F32x4Lt();
479 const Operator* F32x4Le();
481 const Operator* I32x4Splat();
482 const Operator* I32x4ExtractLane(int32_t);
483 const Operator* I32x4ReplaceLane(int32_t);
484 const Operator* I32x4SConvertF32x4();
485 const Operator* I32x4SConvertI16x8Low();
486 const Operator* I32x4SConvertI16x8High();
487 const Operator* I32x4Neg();
488 const Operator* I32x4Shl(int32_t);
489 const Operator* I32x4ShrS(int32_t);
490 const Operator* I32x4Add();
491 const Operator* I32x4AddHoriz();
492 const Operator* I32x4Sub();
493 const Operator* I32x4Mul();
494 const Operator* I32x4MinS();
495 const Operator* I32x4MaxS();
496 const Operator* I32x4Eq();
497 const Operator* I32x4Ne();
498 const Operator* I32x4GtS();
499 const Operator* I32x4GeS();
501 const Operator* I32x4UConvertF32x4();
502 const Operator* I32x4UConvertI16x8Low();
503 const Operator* I32x4UConvertI16x8High();
504 const Operator* I32x4ShrU(int32_t);
505 const Operator* I32x4MinU();
506 const Operator* I32x4MaxU();
507 const Operator* I32x4GtU();
508 const Operator* I32x4GeU();
510 const Operator* I16x8Splat();
511 const Operator* I16x8ExtractLane(int32_t);
512 const Operator* I16x8ReplaceLane(int32_t);
513 const Operator* I16x8SConvertI8x16Low();
514 const Operator* I16x8SConvertI8x16High();
515 const Operator* I16x8Neg();
516 const Operator* I16x8Shl(int32_t);
517 const Operator* I16x8ShrS(int32_t);
518 const Operator* I16x8SConvertI32x4();
519 const Operator* I16x8Add();
520 const Operator* I16x8AddSaturateS();
521 const Operator* I16x8AddHoriz();
522 const Operator* I16x8Sub();
523 const Operator* I16x8SubSaturateS();
524 const Operator* I16x8Mul();
525 const Operator* I16x8MinS();
526 const Operator* I16x8MaxS();
527 const Operator* I16x8Eq();
528 const Operator* I16x8Ne();
529 const Operator* I16x8GtS();
530 const Operator* I16x8GeS();
532 const Operator* I16x8UConvertI8x16Low();
533 const Operator* I16x8UConvertI8x16High();
534 const Operator* I16x8ShrU(int32_t);
535 const Operator* I16x8UConvertI32x4();
536 const Operator* I16x8AddSaturateU();
537 const Operator* I16x8SubSaturateU();
538 const Operator* I16x8MinU();
539 const Operator* I16x8MaxU();
540 const Operator* I16x8GtU();
541 const Operator* I16x8GeU();
543 const Operator* I8x16Splat();
544 const Operator* I8x16ExtractLane(int32_t);
545 const Operator* I8x16ReplaceLane(int32_t);
546 const Operator* I8x16Neg();
547 const Operator* I8x16Shl(int32_t);
548 const Operator* I8x16ShrS(int32_t);
549 const Operator* I8x16SConvertI16x8();
550 const Operator* I8x16Add();
551 const Operator* I8x16AddSaturateS();
552 const Operator* I8x16Sub();
553 const Operator* I8x16SubSaturateS();
554 const Operator* I8x16Mul();
555 const Operator* I8x16MinS();
556 const Operator* I8x16MaxS();
557 const Operator* I8x16Eq();
558 const Operator* I8x16Ne();
559 const Operator* I8x16GtS();
560 const Operator* I8x16GeS();
562 const Operator* I8x16ShrU(int32_t);
563 const Operator* I8x16UConvertI16x8();
564 const Operator* I8x16AddSaturateU();
565 const Operator* I8x16SubSaturateU();
566 const Operator* I8x16MinU();
567 const Operator* I8x16MaxU();
568 const Operator* I8x16GtU();
569 const Operator* I8x16GeU();
571 const Operator* S128Load();
572 const Operator* S128Store();
574 const Operator* S128Zero();
575 const Operator* S128And();
576 const Operator* S128Or();
577 const Operator* S128Xor();
578 const Operator* S128Not();
579 const Operator* S128Select();
581 const Operator* S8x16Shuffle(
const uint8_t shuffle[16]);
583 const Operator* S1x4AnyTrue();
584 const Operator* S1x4AllTrue();
585 const Operator* S1x8AnyTrue();
586 const Operator* S1x8AllTrue();
587 const Operator* S1x16AnyTrue();
588 const Operator* S1x16AllTrue();
591 const Operator* Load(LoadRepresentation rep);
592 const Operator* PoisonedLoad(LoadRepresentation rep);
593 const Operator* ProtectedLoad(LoadRepresentation rep);
596 const Operator* Store(StoreRepresentation rep);
597 const Operator* ProtectedStore(MachineRepresentation rep);
600 const Operator* UnalignedLoad(LoadRepresentation rep);
603 const Operator* UnalignedStore(UnalignedStoreRepresentation rep);
605 const Operator* StackSlot(
int size,
int alignment = 0);
606 const Operator* StackSlot(MachineRepresentation rep,
int alignment = 0);
609 const Operator* TaggedPoisonOnSpeculation();
610 const Operator* Word32PoisonOnSpeculation();
611 const Operator* Word64PoisonOnSpeculation();
614 const Operator* LoadStackPointer();
615 const Operator* LoadFramePointer();
616 const Operator* LoadParentFramePointer();
619 const Operator* Word32AtomicLoad(LoadRepresentation rep);
621 const Operator* Word64AtomicLoad(LoadRepresentation rep);
623 const Operator* Word32AtomicStore(MachineRepresentation rep);
625 const Operator* Word64AtomicStore(MachineRepresentation rep);
627 const Operator* Word32AtomicExchange(MachineType
type);
629 const Operator* Word64AtomicExchange(MachineType
type);
631 const Operator* Word32AtomicCompareExchange(MachineType
type);
633 const Operator* Word64AtomicCompareExchange(MachineType
type);
635 const Operator* Word32AtomicAdd(MachineType
type);
637 const Operator* Word32AtomicSub(MachineType
type);
639 const Operator* Word32AtomicAnd(MachineType
type);
641 const Operator* Word32AtomicOr(MachineType
type);
643 const Operator* Word32AtomicXor(MachineType rep);
645 const Operator* Word64AtomicAdd(MachineType rep);
647 const Operator* Word64AtomicSub(MachineType
type);
649 const Operator* Word64AtomicAnd(MachineType
type);
651 const Operator* Word64AtomicOr(MachineType
type);
653 const Operator* Word64AtomicXor(MachineType rep);
655 const Operator* Word32AtomicPairLoad();
657 const Operator* Word32AtomicPairStore();
659 const Operator* Word32AtomicPairAdd();
661 const Operator* Word32AtomicPairSub();
663 const Operator* Word32AtomicPairAnd();
665 const Operator* Word32AtomicPairOr();
667 const Operator* Word32AtomicPairXor();
669 const Operator* Word32AtomicPairExchange();
672 const Operator* Word32AtomicPairCompareExchange();
674 const OptionalOperator SpeculationFence();
677 bool Is32()
const {
return word() == MachineRepresentation::kWord32; }
678 bool Is64()
const {
return word() == MachineRepresentation::kWord64; }
679 MachineRepresentation word()
const {
return word_; }
681 bool UnalignedLoadSupported(MachineRepresentation rep) {
682 return alignment_requirements_.IsUnalignedLoadSupported(rep);
685 bool UnalignedStoreSupported(MachineRepresentation rep) {
686 return alignment_requirements_.IsUnalignedStoreSupported(rep);
691 #define PSEUDO_OP_LIST(V) \ 701 V(Word, PoisonOnSpeculation) \ 708 V(Int, LessThanOrEqual) \ 712 #define PSEUDO_OP(Prefix, Suffix) \ 713 const Operator* Prefix##Suffix() { \ 714 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ 716 PSEUDO_OP_LIST(PSEUDO_OP)
718 #undef PSEUDO_OP_LIST 722 MachineOperatorGlobalCache
const& cache_;
723 MachineRepresentation
const word_;
725 AlignmentRequirements
const alignment_requirements_;
727 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder);
731 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags)
737 #endif // V8_COMPILER_MACHINE_OPERATOR_H_