OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/compiler/machine-operator.h" | 5 #include "src/compiler/machine-operator.h" |
6 | 6 |
7 #include "src/base/lazy-instance.h" | 7 #include "src/base/lazy-instance.h" |
8 #include "src/compiler/opcodes.h" | 8 #include "src/compiler/opcodes.h" |
9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode()); | 63 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode()); |
64 return OpParameter<CheckedLoadRepresentation>(op); | 64 return OpParameter<CheckedLoadRepresentation>(op); |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { | 68 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { |
69 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); | 69 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode()); |
70 return OpParameter<CheckedStoreRepresentation>(op); | 70 return OpParameter<CheckedStoreRepresentation>(op); |
71 } | 71 } |
72 | 72 |
73 int StackSlotSizeOf(Operator const* op) { | 73 bool operator==(StackSlotRepresentation lhs, StackSlotRepresentation rhs) { |
| 74 return lhs.size() == rhs.size() && lhs.alignment() == rhs.alignment(); |
| 75 } |
| 76 |
| 77 bool operator!=(StackSlotRepresentation lhs, StackSlotRepresentation rhs) { |
| 78 return !(lhs == rhs); |
| 79 } |
| 80 |
| 81 size_t hash_value(StackSlotRepresentation rep) { |
| 82 return base::hash_combine(rep.size(), rep.alignment()); |
| 83 } |
| 84 |
| 85 std::ostream& operator<<(std::ostream& os, StackSlotRepresentation rep) { |
| 86 return os << "(" << rep.size() << " : " << rep.alignment() << ")"; |
| 87 } |
| 88 |
| 89 StackSlotRepresentation const& StackSlotRepresentationOf(Operator const* op) { |
74 DCHECK_EQ(IrOpcode::kStackSlot, op->opcode()); | 90 DCHECK_EQ(IrOpcode::kStackSlot, op->opcode()); |
75 return OpParameter<int>(op); | 91 return OpParameter<StackSlotRepresentation>(op); |
76 } | 92 } |
77 | 93 |
78 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) { | 94 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) { |
79 DCHECK_EQ(IrOpcode::kAtomicStore, op->opcode()); | 95 DCHECK_EQ(IrOpcode::kAtomicStore, op->opcode()); |
80 return OpParameter<MachineRepresentation>(op); | 96 return OpParameter<MachineRepresentation>(op); |
81 } | 97 } |
82 | 98 |
83 MachineType AtomicOpRepresentationOf(Operator const* op) { | 99 MachineType AtomicOpRepresentationOf(Operator const* op) { |
84 return OpParameter<MachineType>(op); | 100 return OpParameter<MachineType>(op); |
85 } | 101 } |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 V(F32x4, 4) \ | 435 V(F32x4, 4) \ |
420 V(I32x4, 4) \ | 436 V(I32x4, 4) \ |
421 V(I16x8, 8) \ | 437 V(I16x8, 8) \ |
422 V(I8x16, 16) | 438 V(I8x16, 16) |
423 | 439 |
424 #define SIMD_FORMAT_LIST(V) \ | 440 #define SIMD_FORMAT_LIST(V) \ |
425 V(32x4, 32) \ | 441 V(32x4, 32) \ |
426 V(16x8, 16) \ | 442 V(16x8, 16) \ |
427 V(8x16, 8) | 443 V(8x16, 8) |
428 | 444 |
429 #define STACK_SLOT_CACHED_SIZES_LIST(V) V(4) V(8) V(16) | 445 #define STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(V) \ |
| 446 V(4, 0) V(8, 0) V(16, 0) V(4, 4) V(8, 8) V(16, 16) |
430 | 447 |
431 struct StackSlotOperator : public Operator1<int> { | 448 struct StackSlotOperator : public Operator1<StackSlotRepresentation> { |
432 explicit StackSlotOperator(int size) | 449 explicit StackSlotOperator(int size, int alignment) |
433 : Operator1<int>(IrOpcode::kStackSlot, | 450 : Operator1<StackSlotRepresentation>( |
434 Operator::kNoDeopt | Operator::kNoThrow, "StackSlot", 0, | 451 IrOpcode::kStackSlot, Operator::kNoDeopt | Operator::kNoThrow, |
435 0, 0, 1, 0, 0, size) {} | 452 "StackSlot", 0, 0, 0, 1, 0, 0, |
| 453 StackSlotRepresentation(size, alignment)) {} |
436 }; | 454 }; |
437 | 455 |
438 struct MachineOperatorGlobalCache { | 456 struct MachineOperatorGlobalCache { |
439 #define PURE(Name, properties, value_input_count, control_input_count, \ | 457 #define PURE(Name, properties, value_input_count, control_input_count, \ |
440 output_count) \ | 458 output_count) \ |
441 struct Name##Operator final : public Operator { \ | 459 struct Name##Operator final : public Operator { \ |
442 Name##Operator() \ | 460 Name##Operator() \ |
443 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 461 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
444 value_input_count, 0, control_input_count, output_count, 0, \ | 462 value_input_count, 0, control_input_count, output_count, 0, \ |
445 0) {} \ | 463 0) {} \ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 Operator::kNoDeopt | Operator::kNoThrow, "ProtectedLoad", 3, 1, \ | 510 Operator::kNoDeopt | Operator::kNoThrow, "ProtectedLoad", 3, 1, \ |
493 1, 1, 1, 0, MachineType::Type()) {} \ | 511 1, 1, 1, 0, MachineType::Type()) {} \ |
494 }; \ | 512 }; \ |
495 Load##Type##Operator kLoad##Type; \ | 513 Load##Type##Operator kLoad##Type; \ |
496 UnalignedLoad##Type##Operator kUnalignedLoad##Type; \ | 514 UnalignedLoad##Type##Operator kUnalignedLoad##Type; \ |
497 CheckedLoad##Type##Operator kCheckedLoad##Type; \ | 515 CheckedLoad##Type##Operator kCheckedLoad##Type; \ |
498 ProtectedLoad##Type##Operator kProtectedLoad##Type; | 516 ProtectedLoad##Type##Operator kProtectedLoad##Type; |
499 MACHINE_TYPE_LIST(LOAD) | 517 MACHINE_TYPE_LIST(LOAD) |
500 #undef LOAD | 518 #undef LOAD |
501 | 519 |
502 #define STACKSLOT(Size) \ | 520 #define STACKSLOT(Size, Alignment) \ |
503 struct StackSlotOfSize##Size##Operator final : public StackSlotOperator { \ | 521 struct StackSlotOfSize##Size##OfAlignment##Alignment##Operator final \ |
504 StackSlotOfSize##Size##Operator() : StackSlotOperator(Size) {} \ | 522 : public StackSlotOperator { \ |
505 }; \ | 523 StackSlotOfSize##Size##OfAlignment##Alignment##Operator() \ |
506 StackSlotOfSize##Size##Operator kStackSlotSize##Size; | 524 : StackSlotOperator(Size, Alignment) {} \ |
507 STACK_SLOT_CACHED_SIZES_LIST(STACKSLOT) | 525 }; \ |
| 526 StackSlotOfSize##Size##OfAlignment##Alignment##Operator \ |
| 527 kStackSlotOfSize##Size##OfAlignment##Alignment; |
| 528 STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(STACKSLOT) |
508 #undef STACKSLOT | 529 #undef STACKSLOT |
509 | 530 |
510 #define STORE(Type) \ | 531 #define STORE(Type) \ |
511 struct Store##Type##Operator : public Operator1<StoreRepresentation> { \ | 532 struct Store##Type##Operator : public Operator1<StoreRepresentation> { \ |
512 explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \ | 533 explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \ |
513 : Operator1<StoreRepresentation>( \ | 534 : Operator1<StoreRepresentation>( \ |
514 IrOpcode::kStore, \ | 535 IrOpcode::kStore, \ |
515 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ | 536 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ |
516 "Store", 3, 1, 1, 0, 1, 0, \ | 537 "Store", 3, 1, 1, 0, 1, 0, \ |
517 StoreRepresentation(MachineRepresentation::Type, \ | 538 StoreRepresentation(MachineRepresentation::Type, \ |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 #define LOAD(Type) \ | 769 #define LOAD(Type) \ |
749 if (rep == MachineType::Type()) { \ | 770 if (rep == MachineType::Type()) { \ |
750 return &cache_.kProtectedLoad##Type; \ | 771 return &cache_.kProtectedLoad##Type; \ |
751 } | 772 } |
752 MACHINE_TYPE_LIST(LOAD) | 773 MACHINE_TYPE_LIST(LOAD) |
753 #undef LOAD | 774 #undef LOAD |
754 UNREACHABLE(); | 775 UNREACHABLE(); |
755 return nullptr; | 776 return nullptr; |
756 } | 777 } |
757 | 778 |
758 const Operator* MachineOperatorBuilder::StackSlot(int size) { | 779 const Operator* MachineOperatorBuilder::StackSlot(int size, int alignment) { |
759 DCHECK_LE(0, size); | 780 DCHECK_LE(0, size); |
760 #define CASE_CACHED_SIZE(Size) \ | 781 #define CASE_CACHED_SIZE(Size, Alignment) \ |
761 case Size: \ | 782 if (size == Size && alignment == Alignment) { \ |
762 return &cache_.kStackSlotSize##Size; | 783 return &cache_.kStackSlotOfSize##Size##OfAlignment##Alignment; \ |
763 switch (size) { | |
764 STACK_SLOT_CACHED_SIZES_LIST(CASE_CACHED_SIZE); | |
765 default: | |
766 return new (zone_) StackSlotOperator(size); | |
767 } | 784 } |
| 785 |
| 786 STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(CASE_CACHED_SIZE) |
| 787 |
768 #undef CASE_CACHED_SIZE | 788 #undef CASE_CACHED_SIZE |
| 789 return new (zone_) StackSlotOperator(size, alignment); |
769 } | 790 } |
770 | 791 |
771 const Operator* MachineOperatorBuilder::StackSlot(MachineRepresentation rep) { | 792 const Operator* MachineOperatorBuilder::StackSlot(MachineRepresentation rep, |
| 793 int alignment) { |
772 return StackSlot(1 << ElementSizeLog2Of(rep)); | 794 return StackSlot(1 << ElementSizeLog2Of(rep)); |
773 } | 795 } |
774 | 796 |
775 const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) { | 797 const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) { |
776 switch (store_rep.representation()) { | 798 switch (store_rep.representation()) { |
777 #define STORE(kRep) \ | 799 #define STORE(kRep) \ |
778 case MachineRepresentation::kRep: \ | 800 case MachineRepresentation::kRep: \ |
779 switch (store_rep.write_barrier_kind()) { \ | 801 switch (store_rep.write_barrier_kind()) { \ |
780 case kNoWriteBarrier: \ | 802 case kNoWriteBarrier: \ |
781 return &cache_.k##Store##kRep##NoWriteBarrier; \ | 803 return &cache_.k##Store##kRep##NoWriteBarrier; \ |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 return new (zone_) \ | 1036 return new (zone_) \ |
1015 Operator1<uint32_t>(IrOpcode::kS##format##Swizzle, Operator::kPure, \ | 1037 Operator1<uint32_t>(IrOpcode::kS##format##Swizzle, Operator::kPure, \ |
1016 "Swizzle", 2, 0, 0, 1, 0, 0, swizzle); \ | 1038 "Swizzle", 2, 0, 0, 1, 0, 0, swizzle); \ |
1017 } | 1039 } |
1018 SIMD_FORMAT_LIST(SIMD_PERMUTE_OPS) | 1040 SIMD_FORMAT_LIST(SIMD_PERMUTE_OPS) |
1019 #undef SIMD_PERMUTE_OPS | 1041 #undef SIMD_PERMUTE_OPS |
1020 | 1042 |
1021 } // namespace compiler | 1043 } // namespace compiler |
1022 } // namespace internal | 1044 } // namespace internal |
1023 } // namespace v8 | 1045 } // namespace v8 |
OLD | NEW |