]> gcc.gnu.org Git - gcc.git/commit
Add _c forms of atomic functions
authorRichard Sandiford <richard.sandiford@arm.com>
Mon, 25 Apr 2022 18:48:37 +0000 (19:48 +0100)
committerMatthew Malcomson <matthew.malcomson@arm.com>
Fri, 6 May 2022 14:40:22 +0000 (15:40 +0100)
commit834e941352d3620251ba7920f289f6b75598ed2d
tree1bbb371e8d4b33246249acd83072aa4da11b27ec
parente8fe664ab427c2bd31233467f92462c6a46a41b8
Add _c forms of atomic functions

This patch adds atomic functions that take __capability pointers
as arguments.  Following clang's example (and the convention
for memcpy, etc.), these functions are distinguished from
non-__capability versions by having a ā€œ_cā€ suffix.

The two obvious options were:

(1) Put these _c functions in a group after the non-_c functions.
(2) Put each _c function after the corresponding non-_c function.

The patch goes for (2), since it makes it easier to handle
the difference between functions that have intcap forms
and functions that don't.

The vast majority of backend atomics patterns can only handle
the non-_c form, so the generic aarch64_sync_memory_operand
requires normal-base addresses.  However, we can support
alternative-base forms of some atomic loads and stores.

The atomic_load and atomic_store expanders filter out which
forms of load and store can handle alternative base addresses
and FAIL those that can't.  Target-independent code then uses
fallback paths for those cases.

Doing this exposed a couple of bugs in the fallback paths
of expand_compare_and_swap_loop (which didn't clean up
after a failed sequence) and expand_atomic_fetch_op
(which was missing a null check).

The existing behaviour of __ATOMIC_CONSUME is different from
(more relaxed than) __ATOMIC_ACQUIRE, which is inconsistent
with the documentation:

@item __ATOMIC_CONSUME
This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
memory order because of a deficiency in C++11's semantics for
@code{memory_order_consume}.

But that isn't really relevant to this patch.  All that matters
is that the tests are in sync.

The atomic_load insn checks for is_mm_release (model) and
the atomic_store insn checks for is_mm_acquire (model),
but those conditions would never be triggered by valid uses of
the associated __atomic_load_* and __atomic_store_* functions.
26 files changed:
gcc/builtin-types.def
gcc/builtins.c
gcc/config/aarch64/aarch64-protos.h
gcc/config/aarch64/aarch64.c
gcc/config/aarch64/atomics.md
gcc/config/aarch64/predicates.md
gcc/fortran/types.def
gcc/optabs.c
gcc/sync-builtins.def
gcc/testsuite/gcc.target/aarch64/morello/alt-base-atomic-compare-exchange-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-atomic-compare-exchange-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-atomic-exchange-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-atomic-exchange-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-atomic-load-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-atomic-operation-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-atomic-operation-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-atomic-store-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-sync-compare-swap-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-sync-compare-swap-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-sync-lock-release-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-sync-lock-test-and-set-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-sync-lock-test-and-set-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-sync-operation-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/morello/alt-base-sync-operation-2.c [new file with mode: 0644]
gcc/tree.c
gcc/tree.h
This page took 0.05715 seconds and 6 git commands to generate.