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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 V(F32x4, 4) \ | 456 V(F32x4, 4) \ |
441 V(I32x4, 4) \ | 457 V(I32x4, 4) \ |
442 V(I16x8, 8) \ | 458 V(I16x8, 8) \ |
443 V(I8x16, 16) | 459 V(I8x16, 16) |
444 | 460 |
445 #define SIMD_FORMAT_LIST(V) \ | 461 #define SIMD_FORMAT_LIST(V) \ |
446 V(32x4, 32) \ | 462 V(32x4, 32) \ |
447 V(16x8, 16) \ | 463 V(16x8, 16) \ |
448 V(8x16, 8) | 464 V(8x16, 8) |
449 | 465 |
450 #define STACK_SLOT_CACHED_SIZES_LIST(V) V(4) V(8) V(16) | 466 #define STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(V) \ |
| 467 V(4, 0) V(8, 0) V(16, 0) V(4, 4) V(8, 8) V(16, 16) |
451 | 468 |
452 struct StackSlotOperator : public Operator1<int> { | 469 struct StackSlotOperator : public Operator1<StackSlotRepresentation> { |
453 explicit StackSlotOperator(int size) | 470 explicit StackSlotOperator(int size, int alignment) |
454 : Operator1<int>(IrOpcode::kStackSlot, | 471 : Operator1<StackSlotRepresentation>( |
455 Operator::kNoDeopt | Operator::kNoThrow, "StackSlot", 0, | 472 IrOpcode::kStackSlot, Operator::kNoDeopt | Operator::kNoThrow, |
456 0, 0, 1, 0, 0, size) {} | 473 "StackSlot", 0, 0, 0, 1, 0, 0, |
| 474 StackSlotRepresentation(size, alignment)) {} |
457 }; | 475 }; |
458 | 476 |
459 struct MachineOperatorGlobalCache { | 477 struct MachineOperatorGlobalCache { |
460 #define PURE(Name, properties, value_input_count, control_input_count, \ | 478 #define PURE(Name, properties, value_input_count, control_input_count, \ |
461 output_count) \ | 479 output_count) \ |
462 struct Name##Operator final : public Operator { \ | 480 struct Name##Operator final : public Operator { \ |
463 Name##Operator() \ | 481 Name##Operator() \ |
464 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 482 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
465 value_input_count, 0, control_input_count, output_count, 0, \ | 483 value_input_count, 0, control_input_count, output_count, 0, \ |
466 0) {} \ | 484 0) {} \ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 Operator::kNoDeopt | Operator::kNoThrow, "ProtectedLoad", 3, 1, \ | 531 Operator::kNoDeopt | Operator::kNoThrow, "ProtectedLoad", 3, 1, \ |
514 1, 1, 1, 0, MachineType::Type()) {} \ | 532 1, 1, 1, 0, MachineType::Type()) {} \ |
515 }; \ | 533 }; \ |
516 Load##Type##Operator kLoad##Type; \ | 534 Load##Type##Operator kLoad##Type; \ |
517 UnalignedLoad##Type##Operator kUnalignedLoad##Type; \ | 535 UnalignedLoad##Type##Operator kUnalignedLoad##Type; \ |
518 CheckedLoad##Type##Operator kCheckedLoad##Type; \ | 536 CheckedLoad##Type##Operator kCheckedLoad##Type; \ |
519 ProtectedLoad##Type##Operator kProtectedLoad##Type; | 537 ProtectedLoad##Type##Operator kProtectedLoad##Type; |
520 MACHINE_TYPE_LIST(LOAD) | 538 MACHINE_TYPE_LIST(LOAD) |
521 #undef LOAD | 539 #undef LOAD |
522 | 540 |
523 #define STACKSLOT(Size) \ | 541 #define STACKSLOT(Size, Alignment) \ |
524 struct StackSlotOfSize##Size##Operator final : public StackSlotOperator { \ | 542 struct StackSlotOfSize##Size##OfAlignment##Alignment##Operator final \ |
525 StackSlotOfSize##Size##Operator() : StackSlotOperator(Size) {} \ | 543 : public StackSlotOperator { \ |
526 }; \ | 544 StackSlotOfSize##Size##OfAlignment##Alignment##Operator() \ |
527 StackSlotOfSize##Size##Operator kStackSlotSize##Size; | 545 : StackSlotOperator(Size, Alignment) {} \ |
528 STACK_SLOT_CACHED_SIZES_LIST(STACKSLOT) | 546 }; \ |
| 547 StackSlotOfSize##Size##OfAlignment##Alignment##Operator \ |
| 548 kStackSlotOfSize##Size##OfAlignment##Alignment; |
| 549 STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(STACKSLOT) |
529 #undef STACKSLOT | 550 #undef STACKSLOT |
530 | 551 |
531 #define STORE(Type) \ | 552 #define STORE(Type) \ |
532 struct Store##Type##Operator : public Operator1<StoreRepresentation> { \ | 553 struct Store##Type##Operator : public Operator1<StoreRepresentation> { \ |
533 explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \ | 554 explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \ |
534 : Operator1<StoreRepresentation>( \ | 555 : Operator1<StoreRepresentation>( \ |
535 IrOpcode::kStore, \ | 556 IrOpcode::kStore, \ |
536 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ | 557 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ |
537 "Store", 3, 1, 1, 0, 1, 0, \ | 558 "Store", 3, 1, 1, 0, 1, 0, \ |
538 StoreRepresentation(MachineRepresentation::Type, \ | 559 StoreRepresentation(MachineRepresentation::Type, \ |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 #define LOAD(Type) \ | 790 #define LOAD(Type) \ |
770 if (rep == MachineType::Type()) { \ | 791 if (rep == MachineType::Type()) { \ |
771 return &cache_.kProtectedLoad##Type; \ | 792 return &cache_.kProtectedLoad##Type; \ |
772 } | 793 } |
773 MACHINE_TYPE_LIST(LOAD) | 794 MACHINE_TYPE_LIST(LOAD) |
774 #undef LOAD | 795 #undef LOAD |
775 UNREACHABLE(); | 796 UNREACHABLE(); |
776 return nullptr; | 797 return nullptr; |
777 } | 798 } |
778 | 799 |
779 const Operator* MachineOperatorBuilder::StackSlot(int size) { | 800 const Operator* MachineOperatorBuilder::StackSlot(int size, int alignment) { |
780 DCHECK_LE(0, size); | 801 DCHECK_LE(0, size); |
781 #define CASE_CACHED_SIZE(Size) \ | 802 DCHECK(alignment == 0 || alignment == 4 || alignment == 8 || alignment == 16); |
782 case Size: \ | 803 #define CASE_CACHED_SIZE(Size, Alignment) \ |
783 return &cache_.kStackSlotSize##Size; | 804 if (size == Size && alignment == Alignment) { \ |
784 switch (size) { | 805 return &cache_.kStackSlotOfSize##Size##OfAlignment##Alignment; \ |
785 STACK_SLOT_CACHED_SIZES_LIST(CASE_CACHED_SIZE); | |
786 default: | |
787 return new (zone_) StackSlotOperator(size); | |
788 } | 806 } |
| 807 |
| 808 STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(CASE_CACHED_SIZE) |
| 809 |
789 #undef CASE_CACHED_SIZE | 810 #undef CASE_CACHED_SIZE |
| 811 return new (zone_) StackSlotOperator(size, alignment); |
790 } | 812 } |
791 | 813 |
792 const Operator* MachineOperatorBuilder::StackSlot(MachineRepresentation rep) { | 814 const Operator* MachineOperatorBuilder::StackSlot(MachineRepresentation rep, |
793 return StackSlot(1 << ElementSizeLog2Of(rep)); | 815 int alignment) { |
| 816 return StackSlot(1 << ElementSizeLog2Of(rep), alignment); |
794 } | 817 } |
795 | 818 |
796 const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) { | 819 const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) { |
797 switch (store_rep.representation()) { | 820 switch (store_rep.representation()) { |
798 #define STORE(kRep) \ | 821 #define STORE(kRep) \ |
799 case MachineRepresentation::kRep: \ | 822 case MachineRepresentation::kRep: \ |
800 switch (store_rep.write_barrier_kind()) { \ | 823 switch (store_rep.write_barrier_kind()) { \ |
801 case kNoWriteBarrier: \ | 824 case kNoWriteBarrier: \ |
802 return &cache_.k##Store##kRep##NoWriteBarrier; \ | 825 return &cache_.k##Store##kRep##NoWriteBarrier; \ |
803 case kMapWriteBarrier: \ | 826 case kMapWriteBarrier: \ |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 | 1053 |
1031 const Operator* MachineOperatorBuilder::S8x16Concat(int32_t bytes) { | 1054 const Operator* MachineOperatorBuilder::S8x16Concat(int32_t bytes) { |
1032 DCHECK(0 <= bytes && bytes < kSimd128Size); | 1055 DCHECK(0 <= bytes && bytes < kSimd128Size); |
1033 return new (zone_) Operator1<int32_t>(IrOpcode::kS8x16Concat, Operator::kPure, | 1056 return new (zone_) Operator1<int32_t>(IrOpcode::kS8x16Concat, Operator::kPure, |
1034 "Concat", 2, 0, 0, 1, 0, 0, bytes); | 1057 "Concat", 2, 0, 0, 1, 0, 0, bytes); |
1035 } | 1058 } |
1036 | 1059 |
1037 } // namespace compiler | 1060 } // namespace compiler |
1038 } // namespace internal | 1061 } // namespace internal |
1039 } // namespace v8 | 1062 } // namespace v8 |
OLD | NEW |