Commit 30ae0d76 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[csa][cleanup] TNodify Atomic binary ops.

Splits the 64bit operations to a seperate function since there are different
return types depending upon whether the architecture is 64-bit or 32-bit.

BUG=v8:6949,v8:11074

Change-Id: I13cc576a26f60288281c42df3326ba902fd36dbb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2529910
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71120}
parent b13cb747
......@@ -815,15 +815,26 @@ Node* CodeAssembler::AtomicStore(MachineRepresentation rep, Node* base,
return raw_assembler()->AtomicStore(rep, base, offset, value, value_high);
}
#define ATOMIC_FUNCTION(name) \
Node* CodeAssembler::Atomic##name( \
MachineType type, TNode<RawPtrT> base, TNode<UintPtrT> offset, \
Node* value, base::Optional<TNode<UintPtrT>> value_high) { \
Node* value_high_node = nullptr; \
if (value_high) value_high_node = *value_high; \
return raw_assembler()->Atomic##name(type, base, offset, value, \
value_high_node); \
}
#define ATOMIC_FUNCTION(name) \
TNode<Word32T> CodeAssembler::Atomic##name( \
MachineType type, TNode<RawPtrT> base, TNode<UintPtrT> offset, \
TNode<Word32T> value) { \
return UncheckedCast<Word32T>( \
raw_assembler()->Atomic##name(type, base, offset, value)); \
} \
template <class Type> \
TNode<Type> CodeAssembler::Atomic##name##64( \
TNode<RawPtrT> base, TNode<UintPtrT> offset, TNode<UintPtrT> value, \
TNode<UintPtrT> value_high) { \
return UncheckedCast<Type>( \
raw_assembler()->Atomic##name##64(base, offset, value, value_high)); \
} \
template TNode<AtomicInt64> CodeAssembler::Atomic##name##64 < AtomicInt64 > \
(TNode<RawPtrT> base, TNode<UintPtrT> offset, TNode<UintPtrT> value, \
TNode<UintPtrT> value_high); \
template TNode<AtomicUint64> CodeAssembler::Atomic##name##64 < \
AtomicUint64 > (TNode<RawPtrT> base, TNode<UintPtrT> offset, \
TNode<UintPtrT> value, TNode<UintPtrT> value_high);
ATOMIC_FUNCTION(Add)
ATOMIC_FUNCTION(Sub)
ATOMIC_FUNCTION(And)
......
......@@ -805,25 +805,43 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* AtomicStore(MachineRepresentation rep, Node* base, Node* offset,
Node* value, Node* value_high = nullptr);
Node* AtomicAdd(MachineType type, TNode<RawPtrT> base, TNode<UintPtrT> offset,
Node* value, base::Optional<TNode<UintPtrT>> value_high);
TNode<Word32T> AtomicAdd(MachineType type, TNode<RawPtrT> base,
TNode<UintPtrT> offset, TNode<Word32T> value);
template <class Type>
TNode<Type> AtomicAdd64(TNode<RawPtrT> base, TNode<UintPtrT> offset,
TNode<UintPtrT> value, TNode<UintPtrT> value_high);
Node* AtomicSub(MachineType type, TNode<RawPtrT> base, TNode<UintPtrT> offset,
Node* value, base::Optional<TNode<UintPtrT>> value_high);
TNode<Word32T> AtomicSub(MachineType type, TNode<RawPtrT> base,
TNode<UintPtrT> offset, TNode<Word32T> value);
template <class Type>
TNode<Type> AtomicSub64(TNode<RawPtrT> base, TNode<UintPtrT> offset,
TNode<UintPtrT> value, TNode<UintPtrT> value_high);
Node* AtomicAnd(MachineType type, TNode<RawPtrT> base, TNode<UintPtrT> offset,
Node* value, base::Optional<TNode<UintPtrT>> value_high);
TNode<Word32T> AtomicAnd(MachineType type, TNode<RawPtrT> base,
TNode<UintPtrT> offset, TNode<Word32T> value);
template <class Type>
TNode<Type> AtomicAnd64(TNode<RawPtrT> base, TNode<UintPtrT> offset,
TNode<UintPtrT> value, TNode<UintPtrT> value_high);
Node* AtomicOr(MachineType type, TNode<RawPtrT> base, TNode<UintPtrT> offset,
Node* value, base::Optional<TNode<UintPtrT>> value_high);
TNode<Word32T> AtomicOr(MachineType type, TNode<RawPtrT> base,
TNode<UintPtrT> offset, TNode<Word32T> value);
template <class Type>
TNode<Type> AtomicOr64(TNode<RawPtrT> base, TNode<UintPtrT> offset,
TNode<UintPtrT> value, TNode<UintPtrT> value_high);
Node* AtomicXor(MachineType type, TNode<RawPtrT> base, TNode<UintPtrT> offset,
Node* value, base::Optional<TNode<UintPtrT>> value_high);
TNode<Word32T> AtomicXor(MachineType type, TNode<RawPtrT> base,
TNode<UintPtrT> offset, TNode<Word32T> value);
template <class Type>
TNode<Type> AtomicXor64(TNode<RawPtrT> base, TNode<UintPtrT> offset,
TNode<UintPtrT> value, TNode<UintPtrT> value_high);
// Exchange value at raw memory location
Node* AtomicExchange(MachineType type, TNode<RawPtrT> base,
TNode<UintPtrT> offset, Node* value,
base::Optional<TNode<UintPtrT>> value_high);
TNode<Word32T> AtomicExchange(MachineType type, TNode<RawPtrT> base,
TNode<UintPtrT> offset, TNode<Word32T> value);
template <class Type>
TNode<Type> AtomicExchange64(TNode<RawPtrT> base, TNode<UintPtrT> offset,
TNode<UintPtrT> value,
TNode<UintPtrT> value_high);
// Compare and Exchange value at raw memory location
Node* AtomicCompareExchange(MachineType type, Node* base, Node* offset,
......
......@@ -257,21 +257,24 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
DCHECK_NULL(value_high);
return AddNode(machine()->Word32AtomicStore(rep), base, index, value);
}
#define ATOMIC_FUNCTION(name) \
Node* Atomic##name(MachineType type, Node* base, Node* index, Node* value, \
Node* value_high) { \
if (type.representation() == MachineRepresentation::kWord64) { \
if (machine()->Is64()) { \
DCHECK_NULL(value_high); \
return AddNode(machine()->Word64Atomic##name(type), base, index, \
value); \
} else { \
return AddNode(machine()->Word32AtomicPair##name(), base, index, \
VALUE_HALVES); \
} \
} \
DCHECK_NULL(value_high); \
return AddNode(machine()->Word32Atomic##name(type), base, index, value); \
#define ATOMIC_FUNCTION(name) \
Node* Atomic##name(MachineType type, Node* base, Node* index, Node* value) { \
DCHECK_NE(type.representation(), MachineRepresentation::kWord64); \
return AddNode(machine()->Word32Atomic##name(type), base, index, value); \
} \
Node* Atomic##name##64(Node * base, Node * index, Node * value, \
Node * value_high) { \
if (machine()->Is64()) { \
DCHECK_NULL(value_high); \
/* This uses Uint64() intentionally: Atomic operations are not */ \
/* implemented for Int64(), which is fine because the machine */ \
/* instruction only cares about words. */ \
return AddNode(machine()->Word64Atomic##name(MachineType::Uint64()), \
base, index, value); \
} else { \
return AddNode(machine()->Word32AtomicPair##name(), base, index, \
VALUE_HALVES); \
} \
}
ATOMIC_FUNCTION(Exchange)
ATOMIC_FUNCTION(Add)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment