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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) { | 78 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) { |
79 DCHECK_EQ(IrOpcode::kAtomicStore, op->opcode()); | 79 DCHECK_EQ(IrOpcode::kAtomicStore, op->opcode()); |
80 return OpParameter<MachineRepresentation>(op); | 80 return OpParameter<MachineRepresentation>(op); |
81 } | 81 } |
82 | 82 |
83 MachineType AtomicExchangeRepresentationOf(Operator const* op) { | 83 MachineType AtomicExchangeRepresentationOf(Operator const* op) { |
84 DCHECK_EQ(IrOpcode::kAtomicExchange, op->opcode()); | 84 DCHECK_EQ(IrOpcode::kAtomicExchange, op->opcode()); |
85 return OpParameter<MachineType>(op); | 85 return OpParameter<MachineType>(op); |
86 } | 86 } |
87 | 87 |
| 88 MachineType AtomicCompareExchangeRepresentationOf(Operator const* op) { |
| 89 DCHECK_EQ(IrOpcode::kAtomicCompareExchange, op->opcode()); |
| 90 return OpParameter<MachineType>(op); |
| 91 } |
| 92 |
88 #define PURE_BINARY_OP_LIST_32(V) \ | 93 #define PURE_BINARY_OP_LIST_32(V) \ |
89 V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ | 94 V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ |
90 V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ | 95 V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ |
91 V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ | 96 V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ |
92 V(Word32Shl, Operator::kNoProperties, 2, 0, 1) \ | 97 V(Word32Shl, Operator::kNoProperties, 2, 0, 1) \ |
93 V(Word32Shr, Operator::kNoProperties, 2, 0, 1) \ | 98 V(Word32Shr, Operator::kNoProperties, 2, 0, 1) \ |
94 V(Word32Sar, Operator::kNoProperties, 2, 0, 1) \ | 99 V(Word32Sar, Operator::kNoProperties, 2, 0, 1) \ |
95 V(Word32Ror, Operator::kNoProperties, 2, 0, 1) \ | 100 V(Word32Ror, Operator::kNoProperties, 2, 0, 1) \ |
96 V(Word32Equal, Operator::kCommutative, 2, 0, 1) \ | 101 V(Word32Equal, Operator::kCommutative, 2, 0, 1) \ |
97 V(Int32Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ | 102 V(Int32Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 AtomicExchange##Type##Operator() \ | 605 AtomicExchange##Type##Operator() \ |
601 : Operator1<MachineType>(IrOpcode::kAtomicExchange, \ | 606 : Operator1<MachineType>(IrOpcode::kAtomicExchange, \ |
602 Operator::kNoDeopt | Operator::kNoThrow, \ | 607 Operator::kNoDeopt | Operator::kNoThrow, \ |
603 "AtomicExchange", 3, 1, 1, 1, 1, 0, \ | 608 "AtomicExchange", 3, 1, 1, 1, 1, 0, \ |
604 MachineType::Type()) {} \ | 609 MachineType::Type()) {} \ |
605 }; \ | 610 }; \ |
606 AtomicExchange##Type##Operator kAtomicExchange##Type; | 611 AtomicExchange##Type##Operator kAtomicExchange##Type; |
607 ATOMIC_TYPE_LIST(ATOMIC_EXCHANGE) | 612 ATOMIC_TYPE_LIST(ATOMIC_EXCHANGE) |
608 #undef ATOMIC_EXCHANGE | 613 #undef ATOMIC_EXCHANGE |
609 | 614 |
| 615 #define ATOMIC_COMPARE_EXCHANGE(Type) \ |
| 616 struct AtomicCompareExchange##Type##Operator \ |
| 617 : public Operator1<MachineType> { \ |
| 618 AtomicCompareExchange##Type##Operator() \ |
| 619 : Operator1<MachineType>(IrOpcode::kAtomicCompareExchange, \ |
| 620 Operator::kNoDeopt | Operator::kNoThrow, \ |
| 621 "AtomicCompareExchange", 4, 1, 1, 1, 1, 0, \ |
| 622 MachineType::Type()) {} \ |
| 623 }; \ |
| 624 AtomicCompareExchange##Type##Operator kAtomicCompareExchange##Type; |
| 625 ATOMIC_TYPE_LIST(ATOMIC_COMPARE_EXCHANGE) |
| 626 #undef ATOMIC_COMPARE_EXCHANGE |
| 627 |
610 struct DebugBreakOperator : public Operator { | 628 struct DebugBreakOperator : public Operator { |
611 DebugBreakOperator() | 629 DebugBreakOperator() |
612 : Operator(IrOpcode::kDebugBreak, Operator::kNoThrow, "DebugBreak", 0, | 630 : Operator(IrOpcode::kDebugBreak, Operator::kNoThrow, "DebugBreak", 0, |
613 0, 0, 0, 0, 0) {} | 631 0, 0, 0, 0, 0) {} |
614 }; | 632 }; |
615 DebugBreakOperator kDebugBreak; | 633 DebugBreakOperator kDebugBreak; |
616 | 634 |
617 struct UnsafePointerAddOperator final : public Operator { | 635 struct UnsafePointerAddOperator final : public Operator { |
618 UnsafePointerAddOperator() | 636 UnsafePointerAddOperator() |
619 : Operator(IrOpcode::kUnsafePointerAdd, Operator::kKontrol, | 637 : Operator(IrOpcode::kUnsafePointerAdd, Operator::kKontrol, |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 #define EXCHANGE(kRep) \ | 868 #define EXCHANGE(kRep) \ |
851 if (rep == MachineType::kRep()) { \ | 869 if (rep == MachineType::kRep()) { \ |
852 return &cache_.kAtomicExchange##kRep; \ | 870 return &cache_.kAtomicExchange##kRep; \ |
853 } | 871 } |
854 ATOMIC_TYPE_LIST(EXCHANGE) | 872 ATOMIC_TYPE_LIST(EXCHANGE) |
855 #undef EXCHANGE | 873 #undef EXCHANGE |
856 UNREACHABLE(); | 874 UNREACHABLE(); |
857 return nullptr; | 875 return nullptr; |
858 } | 876 } |
859 | 877 |
| 878 const Operator* MachineOperatorBuilder::AtomicCompareExchange(MachineType rep) { |
| 879 #define COMPARE_EXCHANGE(kRep) \ |
| 880 if (rep == MachineType::kRep()) { \ |
| 881 return &cache_.kAtomicCompareExchange##kRep; \ |
| 882 } |
| 883 ATOMIC_TYPE_LIST(COMPARE_EXCHANGE) |
| 884 #undef COMPARE_EXCHANGE |
| 885 UNREACHABLE(); |
| 886 return nullptr; |
| 887 } |
| 888 |
860 #define SIMD_LANE_OPS(Type, lane_count) \ | 889 #define SIMD_LANE_OPS(Type, lane_count) \ |
861 const Operator* MachineOperatorBuilder::Type##ExtractLane( \ | 890 const Operator* MachineOperatorBuilder::Type##ExtractLane( \ |
862 int32_t lane_index) { \ | 891 int32_t lane_index) { \ |
863 DCHECK(0 <= lane_index && lane_index < lane_count); \ | 892 DCHECK(0 <= lane_index && lane_index < lane_count); \ |
864 return new (zone_) \ | 893 return new (zone_) \ |
865 Operator1<int32_t>(IrOpcode::k##Type##ExtractLane, Operator::kPure, \ | 894 Operator1<int32_t>(IrOpcode::k##Type##ExtractLane, Operator::kPure, \ |
866 "Extract lane", 1, 0, 0, 1, 0, 0, lane_index); \ | 895 "Extract lane", 1, 0, 0, 1, 0, 0, lane_index); \ |
867 } \ | 896 } \ |
868 const Operator* MachineOperatorBuilder::Type##ReplaceLane( \ | 897 const Operator* MachineOperatorBuilder::Type##ReplaceLane( \ |
869 int32_t lane_index) { \ | 898 int32_t lane_index) { \ |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 return new (zone_) \ | 936 return new (zone_) \ |
908 Operator1<uint32_t>(IrOpcode::kSimd##format##Swizzle, Operator::kPure, \ | 937 Operator1<uint32_t>(IrOpcode::kSimd##format##Swizzle, Operator::kPure, \ |
909 "Swizzle", 2, 0, 0, 1, 0, 0, swizzle); \ | 938 "Swizzle", 2, 0, 0, 1, 0, 0, swizzle); \ |
910 } | 939 } |
911 SIMD_FORMAT_LIST(SIMD_PERMUTE_OPS) | 940 SIMD_FORMAT_LIST(SIMD_PERMUTE_OPS) |
912 #undef SIMD_PERMUTE_OPS | 941 #undef SIMD_PERMUTE_OPS |
913 | 942 |
914 } // namespace compiler | 943 } // namespace compiler |
915 } // namespace internal | 944 } // namespace internal |
916 } // namespace v8 | 945 } // namespace v8 |
OLD | NEW |