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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/machine-operator.cc
diff --git a/src/compiler/machine-operator.cc b/src/compiler/machine-operator.cc
index 35774c693414c9ac573f8eb4cf052d283958271c..04a590b91d81a7f00ef40c84c63cf81006d1e6ca 100644
--- a/src/compiler/machine-operator.cc
+++ b/src/compiler/machine-operator.cc
@@ -80,13 +80,7 @@ MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) {
return OpParameter<MachineRepresentation>(op);
}
-MachineType AtomicExchangeRepresentationOf(Operator const* op) {
- DCHECK_EQ(IrOpcode::kAtomicExchange, op->opcode());
- return OpParameter<MachineType>(op);
-}
-
-MachineType AtomicCompareExchangeRepresentationOf(Operator const* op) {
- DCHECK_EQ(IrOpcode::kAtomicCompareExchange, op->opcode());
+MachineType AtomicOpRepresentationOf(Operator const* op) {
return OpParameter<MachineType>(op);
}
@@ -596,17 +590,24 @@ struct MachineOperatorGlobalCache {
ATOMIC_REPRESENTATION_LIST(ATOMIC_STORE)
#undef STORE
-#define ATOMIC_EXCHANGE(Type) \
- struct AtomicExchange##Type##Operator : public Operator1<MachineType> { \
- AtomicExchange##Type##Operator() \
- : Operator1<MachineType>(IrOpcode::kAtomicExchange, \
- Operator::kNoDeopt | Operator::kNoThrow, \
- "AtomicExchange", 3, 1, 1, 1, 1, 0, \
- MachineType::Type()) {} \
- }; \
- AtomicExchange##Type##Operator kAtomicExchange##Type;
- ATOMIC_TYPE_LIST(ATOMIC_EXCHANGE)
-#undef ATOMIC_EXCHANGE
+#define ATOMIC_OP(op, type) \
+ struct op##type##Operator : public Operator1<MachineType> { \
+ op##type##Operator() \
+ : Operator1<MachineType>(IrOpcode::k##op, \
+ Operator::kNoDeopt | Operator::kNoThrow, #op, \
+ 3, 1, 1, 1, 1, 0, MachineType::type()) {} \
+ }; \
+ op##type##Operator k##op##type;
+#define ATOMIC_OP_LIST(type) \
+ ATOMIC_OP(AtomicExchange, type) \
+ ATOMIC_OP(AtomicAdd, type) \
+ ATOMIC_OP(AtomicSub, type) \
+ ATOMIC_OP(AtomicAnd, type) \
+ ATOMIC_OP(AtomicOr, type) \
+ ATOMIC_OP(AtomicXor, type)
+ ATOMIC_TYPE_LIST(ATOMIC_OP_LIST)
+#undef ATOMIC_OP_LIST
+#undef ATOMIC_OP
#define ATOMIC_COMPARE_EXCHANGE(Type) \
struct AtomicCompareExchange##Type##Operator \
@@ -899,6 +900,61 @@ const Operator* MachineOperatorBuilder::AtomicCompareExchange(MachineType rep) {
return nullptr;
}
+const Operator* MachineOperatorBuilder::AtomicAdd(MachineType rep) {
+#define ADD(kRep) \
+ if (rep == MachineType::kRep()) { \
+ return &cache_.kAtomicAdd##kRep; \
+ }
+ ATOMIC_TYPE_LIST(ADD)
+#undef ADD
+ UNREACHABLE();
+ return nullptr;
+}
+
+const Operator* MachineOperatorBuilder::AtomicSub(MachineType rep) {
+#define SUB(kRep) \
+ if (rep == MachineType::kRep()) { \
+ return &cache_.kAtomicSub##kRep; \
+ }
+ ATOMIC_TYPE_LIST(SUB)
+#undef SUB
+ UNREACHABLE();
+ return nullptr;
+}
+
+const Operator* MachineOperatorBuilder::AtomicAnd(MachineType rep) {
+#define AND(kRep) \
+ if (rep == MachineType::kRep()) { \
+ return &cache_.kAtomicAnd##kRep; \
+ }
+ ATOMIC_TYPE_LIST(AND)
+#undef AND
+ UNREACHABLE();
+ return nullptr;
+}
+
+const Operator* MachineOperatorBuilder::AtomicOr(MachineType rep) {
+#define OR(kRep) \
+ if (rep == MachineType::kRep()) { \
+ return &cache_.kAtomicOr##kRep; \
+ }
+ ATOMIC_TYPE_LIST(OR)
+#undef OR
+ UNREACHABLE();
+ return nullptr;
+}
+
+const Operator* MachineOperatorBuilder::AtomicXor(MachineType rep) {
+#define XOR(kRep) \
+ if (rep == MachineType::kRep()) { \
+ return &cache_.kAtomicXor##kRep; \
+ }
+ ATOMIC_TYPE_LIST(XOR)
+#undef XOR
+ UNREACHABLE();
+ return nullptr;
+}
+
#define SIMD_LANE_OPS(Type, lane_count) \
const Operator* MachineOperatorBuilder::Type##ExtractLane( \
int32_t lane_index) { \

Powered by Google App Engine
This is Rietveld 408576698