Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: src/compiler/machine-operator.cc

Issue 2799863002: [Atomics] use TFJ builtins for atomic add, sub, and, or, and xor (Closed)
Patch Set: [Atomics] use TFJ builtins for atomic add, sub, and, or, and xor Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 int StackSlotSizeOf(Operator const* op) { 73 int StackSlotSizeOf(Operator const* op) {
74 DCHECK_EQ(IrOpcode::kStackSlot, op->opcode()); 74 DCHECK_EQ(IrOpcode::kStackSlot, op->opcode());
75 return OpParameter<int>(op); 75 return OpParameter<int>(op);
76 } 76 }
77 77
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 AtomicOpRepresentationOf(Operator const* op) {
84 DCHECK_EQ(IrOpcode::kAtomicExchange, op->opcode());
85 return OpParameter<MachineType>(op); 84 return OpParameter<MachineType>(op);
86 } 85 }
87 86
88 MachineType AtomicCompareExchangeRepresentationOf(Operator const* op) {
89 DCHECK_EQ(IrOpcode::kAtomicCompareExchange, op->opcode());
90 return OpParameter<MachineType>(op);
91 }
92
93 #define PURE_BINARY_OP_LIST_32(V) \ 87 #define PURE_BINARY_OP_LIST_32(V) \
94 V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ 88 V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
95 V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ 89 V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
96 V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ 90 V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
97 V(Word32Shl, Operator::kNoProperties, 2, 0, 1) \ 91 V(Word32Shl, Operator::kNoProperties, 2, 0, 1) \
98 V(Word32Shr, Operator::kNoProperties, 2, 0, 1) \ 92 V(Word32Shr, Operator::kNoProperties, 2, 0, 1) \
99 V(Word32Sar, Operator::kNoProperties, 2, 0, 1) \ 93 V(Word32Sar, Operator::kNoProperties, 2, 0, 1) \
100 V(Word32Ror, Operator::kNoProperties, 2, 0, 1) \ 94 V(Word32Ror, Operator::kNoProperties, 2, 0, 1) \
101 V(Word32Equal, Operator::kCommutative, 2, 0, 1) \ 95 V(Word32Equal, Operator::kCommutative, 2, 0, 1) \
102 V(Int32Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ 96 V(Int32Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 AtomicStore##Type##Operator() \ 583 AtomicStore##Type##Operator() \
590 : Operator1<MachineRepresentation>( \ 584 : Operator1<MachineRepresentation>( \
591 IrOpcode::kAtomicStore, \ 585 IrOpcode::kAtomicStore, \
592 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \ 586 Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
593 "AtomicStore", 3, 1, 1, 0, 1, 0, MachineRepresentation::Type) {} \ 587 "AtomicStore", 3, 1, 1, 0, 1, 0, MachineRepresentation::Type) {} \
594 }; \ 588 }; \
595 AtomicStore##Type##Operator kAtomicStore##Type; 589 AtomicStore##Type##Operator kAtomicStore##Type;
596 ATOMIC_REPRESENTATION_LIST(ATOMIC_STORE) 590 ATOMIC_REPRESENTATION_LIST(ATOMIC_STORE)
597 #undef STORE 591 #undef STORE
598 592
599 #define ATOMIC_EXCHANGE(Type) \ 593 #define ATOMIC_OP(op, type) \
600 struct AtomicExchange##Type##Operator : public Operator1<MachineType> { \ 594 struct op##type##Operator : public Operator1<MachineType> { \
601 AtomicExchange##Type##Operator() \ 595 op##type##Operator() \
602 : Operator1<MachineType>(IrOpcode::kAtomicExchange, \ 596 : Operator1<MachineType>(IrOpcode::k##op, \
603 Operator::kNoDeopt | Operator::kNoThrow, \ 597 Operator::kNoDeopt | Operator::kNoThrow, #op, \
604 "AtomicExchange", 3, 1, 1, 1, 1, 0, \ 598 3, 1, 1, 1, 1, 0, MachineType::type()) {} \
605 MachineType::Type()) {} \ 599 }; \
606 }; \ 600 op##type##Operator k##op##type;
607 AtomicExchange##Type##Operator kAtomicExchange##Type; 601 #define ATOMIC_OP_LIST(type) \
608 ATOMIC_TYPE_LIST(ATOMIC_EXCHANGE) 602 ATOMIC_OP(AtomicExchange, type) \
609 #undef ATOMIC_EXCHANGE 603 ATOMIC_OP(AtomicAdd, type) \
604 ATOMIC_OP(AtomicSub, type) \
605 ATOMIC_OP(AtomicAnd, type) \
606 ATOMIC_OP(AtomicOr, type) \
607 ATOMIC_OP(AtomicXor, type)
608 ATOMIC_TYPE_LIST(ATOMIC_OP_LIST)
609 #undef ATOMIC_OP_LIST
610 #undef ATOMIC_OP
610 611
611 #define ATOMIC_COMPARE_EXCHANGE(Type) \ 612 #define ATOMIC_COMPARE_EXCHANGE(Type) \
612 struct AtomicCompareExchange##Type##Operator \ 613 struct AtomicCompareExchange##Type##Operator \
613 : public Operator1<MachineType> { \ 614 : public Operator1<MachineType> { \
614 AtomicCompareExchange##Type##Operator() \ 615 AtomicCompareExchange##Type##Operator() \
615 : Operator1<MachineType>(IrOpcode::kAtomicCompareExchange, \ 616 : Operator1<MachineType>(IrOpcode::kAtomicCompareExchange, \
616 Operator::kNoDeopt | Operator::kNoThrow, \ 617 Operator::kNoDeopt | Operator::kNoThrow, \
617 "AtomicCompareExchange", 4, 1, 1, 1, 1, 0, \ 618 "AtomicCompareExchange", 4, 1, 1, 1, 1, 0, \
618 MachineType::Type()) {} \ 619 MachineType::Type()) {} \
619 }; \ 620 }; \
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 #define COMPARE_EXCHANGE(kRep) \ 893 #define COMPARE_EXCHANGE(kRep) \
893 if (rep == MachineType::kRep()) { \ 894 if (rep == MachineType::kRep()) { \
894 return &cache_.kAtomicCompareExchange##kRep; \ 895 return &cache_.kAtomicCompareExchange##kRep; \
895 } 896 }
896 ATOMIC_TYPE_LIST(COMPARE_EXCHANGE) 897 ATOMIC_TYPE_LIST(COMPARE_EXCHANGE)
897 #undef COMPARE_EXCHANGE 898 #undef COMPARE_EXCHANGE
898 UNREACHABLE(); 899 UNREACHABLE();
899 return nullptr; 900 return nullptr;
900 } 901 }
901 902
903 const Operator* MachineOperatorBuilder::AtomicAdd(MachineType rep) {
904 #define ADD(kRep) \
905 if (rep == MachineType::kRep()) { \
906 return &cache_.kAtomicAdd##kRep; \
907 }
908 ATOMIC_TYPE_LIST(ADD)
909 #undef ADD
910 UNREACHABLE();
911 return nullptr;
912 }
913
914 const Operator* MachineOperatorBuilder::AtomicSub(MachineType rep) {
915 #define SUB(kRep) \
916 if (rep == MachineType::kRep()) { \
917 return &cache_.kAtomicSub##kRep; \
918 }
919 ATOMIC_TYPE_LIST(SUB)
920 #undef SUB
921 UNREACHABLE();
922 return nullptr;
923 }
924
925 const Operator* MachineOperatorBuilder::AtomicAnd(MachineType rep) {
926 #define AND(kRep) \
927 if (rep == MachineType::kRep()) { \
928 return &cache_.kAtomicAnd##kRep; \
929 }
930 ATOMIC_TYPE_LIST(AND)
931 #undef AND
932 UNREACHABLE();
933 return nullptr;
934 }
935
936 const Operator* MachineOperatorBuilder::AtomicOr(MachineType rep) {
937 #define OR(kRep) \
938 if (rep == MachineType::kRep()) { \
939 return &cache_.kAtomicOr##kRep; \
940 }
941 ATOMIC_TYPE_LIST(OR)
942 #undef OR
943 UNREACHABLE();
944 return nullptr;
945 }
946
947 const Operator* MachineOperatorBuilder::AtomicXor(MachineType rep) {
948 #define XOR(kRep) \
949 if (rep == MachineType::kRep()) { \
950 return &cache_.kAtomicXor##kRep; \
951 }
952 ATOMIC_TYPE_LIST(XOR)
953 #undef XOR
954 UNREACHABLE();
955 return nullptr;
956 }
957
902 #define SIMD_LANE_OPS(Type, lane_count) \ 958 #define SIMD_LANE_OPS(Type, lane_count) \
903 const Operator* MachineOperatorBuilder::Type##ExtractLane( \ 959 const Operator* MachineOperatorBuilder::Type##ExtractLane( \
904 int32_t lane_index) { \ 960 int32_t lane_index) { \
905 DCHECK(0 <= lane_index && lane_index < lane_count); \ 961 DCHECK(0 <= lane_index && lane_index < lane_count); \
906 return new (zone_) \ 962 return new (zone_) \
907 Operator1<int32_t>(IrOpcode::k##Type##ExtractLane, Operator::kPure, \ 963 Operator1<int32_t>(IrOpcode::k##Type##ExtractLane, Operator::kPure, \
908 "Extract lane", 1, 0, 0, 1, 0, 0, lane_index); \ 964 "Extract lane", 1, 0, 0, 1, 0, 0, lane_index); \
909 } \ 965 } \
910 const Operator* MachineOperatorBuilder::Type##ReplaceLane( \ 966 const Operator* MachineOperatorBuilder::Type##ReplaceLane( \
911 int32_t lane_index) { \ 967 int32_t lane_index) { \
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 return new (zone_) \ 1002 return new (zone_) \
947 Operator1<uint32_t>(IrOpcode::kS##format##Swizzle, Operator::kPure, \ 1003 Operator1<uint32_t>(IrOpcode::kS##format##Swizzle, Operator::kPure, \
948 "Swizzle", 2, 0, 0, 1, 0, 0, swizzle); \ 1004 "Swizzle", 2, 0, 0, 1, 0, 0, swizzle); \
949 } 1005 }
950 SIMD_FORMAT_LIST(SIMD_PERMUTE_OPS) 1006 SIMD_FORMAT_LIST(SIMD_PERMUTE_OPS)
951 #undef SIMD_PERMUTE_OPS 1007 #undef SIMD_PERMUTE_OPS
952 1008
953 } // namespace compiler 1009 } // namespace compiler
954 } // namespace internal 1010 } // namespace internal
955 } // namespace v8 1011 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698