On Wed, Aug 12, 2015 at 11:15:25AM +0100, Matthew Wahab wrote:
> ARMv8.1 adds instructions for atomic compare-and-swap with optional memory
> ordering specifiers. This patch adds the compare-and-swap instructions and
> changes the atomic_compare_and_swap patterns to use them
> 
> The changes to the atomic_compare_and_swap pattern makes the new
> instructions available as an alternative for the existing expander, to
> be used when the target supports them. The existing expander is reused
> so that it can generate code needed to meet the requirements of the
> atomic_compare_and_swap name.
> 
> Using the atomic CAS instructions, the code generated for a call to
> __atomic_compare_exchange (ptr, expected, desired, weak, smodel, fmodel)
> becomes:
> 
>    mov r, r1
>    cas<smo><sz> r, r2, [r0]
>    cmp r, r1
>    cset r0, eq
>    cbnz r0, L
>    strb r, [r1]
> L:
>    ret
> 
> where
>    r0 = ptr, r1 = *expected, r2 = *desired,
>    r is some temporary.
>    mo is one of {'', 'a', 'l', 'al'}, depending on smodel
>    sz is one of {'', 'b', 'h'} depending on the data size.
> 
> Tested the series for aarch64-none-linux-gnu with native bootstrap and make
> check and for aarch64-none-elf with cross-compiled check-gcc. Also tested
> aarch64-none-elf with cross-compiled check-gcc on an emulator that supports
> ARMv8.1.
> 
> Ok for trunk?
> Matthew

OK, but please fix up the testcases Andrew mentioned for those configuring
their toolchains/test runs with a default -mcpu or -march which targets
these instructions. I would just hardwire them
(with dg-additional-options) to -march=armv8-a.

Thanks,
James

> 2015-08-12  Matthew Wahab  <matthew.wa...@arm.com>
> 
>       * config/aarch64/aarch64-protos.h
>       (aarch64_gen_atomic_cas): Declare.
>       * config/aarch64/aarch64.c (aarch64_expand_compare_and_swap):
>       Choose appropriate instruction pattern for the target.
>       (aarch64_gen_atomic_cas): New.
>       * config/aarch64/atomics.md (UNSPECV_ATOMIC_CAS): New.
>       (atomic_compare_and_swap<mode>_1): Rename to
>       aarch64_compare_and_swap<mode>.  Fix some indentation.
>       (aarch64_compare_and_swap<mode>_lse): New.
>       (aarch64_atomic_cas<mode>): New.
> 

Reply via email to