From: Kyrill Tkachov <kyrylo.tkachov@foss.arm.com>
To: Richard Henderson <richard.henderson@linaro.org>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>,
"agraf@suse.de" <agraf@suse.de>,
Marcus Shawcroft <Marcus.Shawcroft@arm.com>,
James Greenhalgh <James.Greenhalgh@arm.com>
Subject: Re: [PATCH, AArch64, v3 5/6] aarch64: Implement -matomic-ool
Date: Thu, 05 Sep 2019 09:56:00 -0000 [thread overview]
Message-ID: <e90271db-ae0e-02dd-5d29-124d9e9d84da@foss.arm.com> (raw)
In-Reply-To: <20181101214648.29432-6-richard.henderson@linaro.org>
Hi Richard,
On 11/1/18 9:46 PM, Richard Henderson wrote:
> Â Â Â Â Â Â Â * config/aarch64/aarch64.opt (-matomic-ool): New.
> Â Â Â Â Â Â Â * config/aarch64/aarch64.c (aarch64_atomic_ool_func): New.
> Â Â Â Â Â Â Â (aarch64_ool_cas_names, aarch64_ool_swp_names): New.
> Â Â Â Â Â Â Â (aarch64_ool_ldadd_names, aarch64_ool_ldset_names): New.
> Â Â Â Â Â Â Â (aarch64_ool_ldclr_names, aarch64_ool_ldeor_names): New.
> Â Â Â Â Â Â Â (aarch64_expand_compare_and_swap): Honor TARGET_ATOMIC_OOL.
> Â Â Â Â Â Â Â * config/aarch64/atomics.md (atomic_exchange<ALLI>): Likewise.
> Â Â Â Â Â Â Â (atomic_<atomic_op><ALLI>): Likewise.
> Â Â Â Â Â Â Â (atomic_fetch_<atomic_op><ALLI>): Likewise.
> Â Â Â Â Â Â Â (atomic_<atomic_op>_fetch<ALLI>): Likewise.
> ---
>  gcc/config/aarch64/aarch64-protos.h          | 13 +++
>  gcc/config/aarch64/aarch64.c                 | 87 +++++++++++++++++
>  .../atomic-comp-swap-release-acquire.c       | 2 +-
>  .../gcc.target/aarch64/atomic-op-acq_rel.c   | 2 +-
>  .../gcc.target/aarch64/atomic-op-acquire.c   | 2 +-
>  .../gcc.target/aarch64/atomic-op-char.c      | 2 +-
>  .../gcc.target/aarch64/atomic-op-consume.c   | 2 +-
>  .../gcc.target/aarch64/atomic-op-imm.c       | 2 +-
>  .../gcc.target/aarch64/atomic-op-int.c       | 2 +-
>  .../gcc.target/aarch64/atomic-op-long.c      | 2 +-
>  .../gcc.target/aarch64/atomic-op-relaxed.c   | 2 +-
>  .../gcc.target/aarch64/atomic-op-release.c   | 2 +-
>  .../gcc.target/aarch64/atomic-op-seq_cst.c   | 2 +-
>  .../gcc.target/aarch64/atomic-op-short.c     | 2 +-
>  .../aarch64/atomic_cmp_exchange_zero_reg_1.c | 2 +-
>  .../atomic_cmp_exchange_zero_strong_1.c      | 2 +-
>  .../gcc.target/aarch64/sync-comp-swap.c      | 2 +-
>  .../gcc.target/aarch64/sync-op-acquire.c     | 2 +-
>  .../gcc.target/aarch64/sync-op-full.c        | 2 +-
>  gcc/config/aarch64/aarch64.opt               | 4 +
>  gcc/config/aarch64/atomics.md                | 94 +++++++++++++++++--
>  gcc/doc/invoke.texi                          | 14 ++-
> Â 22 files changed, 220 insertions(+), 26 deletions(-)
>
> diff --git a/gcc/config/aarch64/aarch64-protos.h
> b/gcc/config/aarch64/aarch64-protos.h
> index 1fe1a50d52a..1c1877cd200 100644
> --- a/gcc/config/aarch64/aarch64-protos.h
> +++ b/gcc/config/aarch64/aarch64-protos.h
> @@ -630,4 +630,17 @@ poly_uint64 aarch64_regmode_natural_size
> (machine_mode);
>
> Â bool aarch64_high_bits_all_ones_p (HOST_WIDE_INT);
>
> +struct atomic_ool_names
> +{
> +Â Â Â const char *str[5][4];
> +};
> +
> +rtx aarch64_atomic_ool_func(machine_mode mode, rtx model_rtx,
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â const atomic_ool_names *names);
> +extern const atomic_ool_names aarch64_ool_swp_names;
> +extern const atomic_ool_names aarch64_ool_ldadd_names;
> +extern const atomic_ool_names aarch64_ool_ldset_names;
> +extern const atomic_ool_names aarch64_ool_ldclr_names;
> +extern const atomic_ool_names aarch64_ool_ldeor_names;
> +
> Â #endif /* GCC_AARCH64_PROTOS_H */
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index b29f437aeaf..9ab8b95c344 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -14679,6 +14679,82 @@ aarch64_emit_unlikely_jump (rtx insn)
> Â Â add_reg_br_prob_note (jump, profile_probability::very_unlikely ());
> Â }
>
> +/* We store the names of the various atomic helpers in a 5x4 array.
> +  Return the libcall function given MODE, MODEL and NAMES. */
> +
> +rtx
> +aarch64_atomic_ool_func(machine_mode mode, rtx model_rtx,
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â const atomic_ool_names *names)
> +{
> +Â memmodel model = memmodel_base (INTVAL (model_rtx));
> +Â int mode_idx, model_idx;
> +
> +Â switch (mode)
> +Â Â Â {
> +Â Â Â case E_QImode:
> +Â Â Â Â Â mode_idx = 0;
> +Â Â Â Â Â break;
> +Â Â Â case E_HImode:
> +Â Â Â Â Â mode_idx = 1;
> +Â Â Â Â Â break;
> +Â Â Â case E_SImode:
> +Â Â Â Â Â mode_idx = 2;
> +Â Â Â Â Â break;
> +Â Â Â case E_DImode:
> +Â Â Â Â Â mode_idx = 3;
> +Â Â Â Â Â break;
> +Â Â Â case E_TImode:
> +Â Â Â Â Â mode_idx = 4;
> +Â Â Â Â Â break;
> +Â Â Â default:
> +Â Â Â Â Â gcc_unreachable ();
> +Â Â Â }
> +
> +Â switch (model)
> +Â Â Â {
> +Â Â Â case MEMMODEL_RELAXED:
> +Â Â Â Â Â model_idx = 0;
> +Â Â Â Â Â break;
> +Â Â Â case MEMMODEL_CONSUME:
> +Â Â Â case MEMMODEL_ACQUIRE:
> +Â Â Â Â Â model_idx = 1;
> +Â Â Â Â Â break;
> +Â Â Â case MEMMODEL_RELEASE:
> +Â Â Â Â Â model_idx = 2;
> +Â Â Â Â Â break;
> +Â Â Â case MEMMODEL_ACQ_REL:
> +Â Â Â case MEMMODEL_SEQ_CST:
> +Â Â Â Â Â model_idx = 3;
> +Â Â Â Â Â break;
> +Â Â Â default:
> +Â Â Â Â Â gcc_unreachable ();
> +Â Â Â }
> +
> +Â return init_one_libfunc_visibility (names->str[mode_idx][model_idx],
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â VISIBILITY_HIDDEN);
> +}
> +
> +#define DEF0(B, N) \
> +Â { "__aa64_" #B #N "_relax", \
> +Â Â Â "__aa64_" #B #N "_acq", \
> +Â Â Â "__aa64_" #B #N "_rel", \
> +Â Â Â "__aa64_" #B #N "_acq_rel" }
> +
> +#define DEF4(B)Â DEF0(B, 1), DEF0(B, 2), DEF0(B, 4), DEF0(B, 8), \
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { NULL, NULL, NULL, NULL }
> +#define DEF5(B)Â DEF0(B, 1), DEF0(B, 2), DEF0(B, 4), DEF0(B, 8),
> DEF0(B, 16)
> +
> +static const atomic_ool_names aarch64_ool_cas_names = { { DEF5(cas) } };
> +const atomic_ool_names aarch64_ool_swp_names = { { DEF4(swp) } };
> +const atomic_ool_names aarch64_ool_ldadd_names = { { DEF4(ldadd) } };
> +const atomic_ool_names aarch64_ool_ldset_names = { { DEF4(ldset) } };
> +const atomic_ool_names aarch64_ool_ldclr_names = { { DEF4(ldclr) } };
> +const atomic_ool_names aarch64_ool_ldeor_names = { { DEF4(ldeor) } };
> +
> +#undef DEF0
> +#undef DEF4
> +#undef DEF5
> +
>  /* Expand a compare and swap pattern. */
>
> Â void
> @@ -14725,6 +14801,17 @@ aarch64_expand_compare_and_swap (rtx operands[])
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newval, mod_s));
> Â Â Â Â Â Â cc_reg = aarch64_gen_compare_reg_maybe_ze (NE, rval, oldval, mode);
> Â Â Â Â }
> +Â else if (TARGET_ATOMIC_OOL)
> +Â Â Â {
> +     /* Oldval must satisfy compare afterward. */
> +Â Â Â Â Â if (!aarch64_plus_operand (oldval, mode))
> +Â Â Â Â Â Â oldval = force_reg (mode, oldval);
> +Â Â Â Â Â rtx func = aarch64_atomic_ool_func (mode, mod_s,
> &aarch64_ool_cas_names);
> +Â Â Â Â Â rval = emit_library_call_value (func, NULL_RTX, LCT_NORMAL, r_mode,
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â oldval, mode, newval, mode,
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â XEXP (mem, 0), ptr_mode);
As reported at https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00118.html
I've encountered ICEs here with -mabi=ilp32 due to the mode of the
address of MEM.
  rtx addr = XEXP (mem, 0);
     if (Pmode != ptr_mode)
   addr = convert_memory_address (ptr_mode, addr);
above the emit_library_call_value to force the address into ptr_mode and
use addr as the argument fixed that for me.
I needed to do similar additions to the other places in the patch that
call emit_library_call_value.
This allowed an aarch64-none-elf build to succeed (which builds an
-mabi=ilp32 multilib) but I'm not sure if it's papering over a problem?
Thanks,
Kyrill
> +Â Â Â Â Â cc_reg = aarch64_gen_compare_reg_maybe_ze (NE, rval, oldval, mode);
> +Â Â Â }
> Â Â else
> Â Â Â Â {
>       /* The oldval predicate varies by mode. Test it and force to
> reg. */
> diff --git
> a/gcc/testsuite/gcc.target/aarch64/atomic-comp-swap-release-acquire.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-comp-swap-release-acquire.c
> index 49ca5d0d09c..e92f205c3a8 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-comp-swap-release-acquire.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-comp-swap-release-acquire.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2 -fno-ipa-icf" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -fno-ipa-icf
> -mno-atomic-ool" } */
>
> Â #include "atomic-comp-swap-release-acquire.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-acq_rel.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-acq_rel.c
> index 74f26348e42..6965431f7d9 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-acq_rel.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-acq_rel.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "atomic-op-acq_rel.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-acquire.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-acquire.c
> index 66c1b1efe20..07dbca49d56 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-acquire.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-acquire.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "atomic-op-acquire.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-char.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-char.c
> index c09d0434ecf..73bfbb7afc9 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-char.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-char.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "atomic-op-char.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-consume.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-consume.c
> index 5783ab84f5c..c7945b3a22d 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-consume.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-consume.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "atomic-op-consume.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-imm.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-imm.c
> index 18b8f0b04e9..e46bb3de7c1 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-imm.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-imm.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â int v = 0;
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-int.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-int.c
> index 8520f0839ba..9b55deb5225 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-int.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-int.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "atomic-op-int.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-long.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-long.c
> index d011f8c5ce2..2622f75331f 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-long.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-long.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â long v = 0;
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-relaxed.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-relaxed.c
> index ed96bfdb978..f118a37a352 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-relaxed.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-relaxed.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "atomic-op-relaxed.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-release.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-release.c
> index fc4be17de89..579634b08e8 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-release.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-release.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "atomic-op-release.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-seq_cst.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-seq_cst.c
> index 613000fe490..016b0d6619f 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-seq_cst.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-seq_cst.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "atomic-op-seq_cst.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-short.c
> b/gcc/testsuite/gcc.target/aarch64/atomic-op-short.c
> index e82c8118ece..978bd1d8377 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic-op-short.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-short.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "atomic-op-short.x"
>
> diff --git
> a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c
> b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c
> index f2a21ddf2e1..77430ecdbce 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-O2 -march=armv8-a+nolse" } */
> +/* { dg-options "-O2 -march=armv8-a+nolse -mno-atomic-ool" } */
> Â /* { dg-skip-if "" { *-*-* } { "-mcpu=*" } { "" } } */
>
> Â int
> diff --git
> a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c
> b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c
> index 8d2ae67dfbe..7d58b2f6bd0 100644
> --- a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c
> +++ b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-O2 -march=armv8-a+nolse" } */
> +/* { dg-options "-O2 -march=armv8-a+nolse -mno-atomic-ool" } */
> Â /* { dg-skip-if "" { *-*-* } { "-mcpu=*" } { "" } } */
>
> Â int
> diff --git a/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c
> b/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c
> index e571b2f13b3..7fc5885d0fd 100644
> --- a/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c
> +++ b/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2 -fno-ipa-icf" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -fno-ipa-icf
> -mno-atomic-ool" } */
>
> Â #include "sync-comp-swap.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c
> b/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c
> index 357bf1be3b2..6ad0daa8998 100644
> --- a/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c
> +++ b/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "sync-op-acquire.x"
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-full.c
> b/gcc/testsuite/gcc.target/aarch64/sync-op-full.c
> index c6ba1629965..9a7afeb70d3 100644
> --- a/gcc/testsuite/gcc.target/aarch64/sync-op-full.c
> +++ b/gcc/testsuite/gcc.target/aarch64/sync-op-full.c
> @@ -1,5 +1,5 @@
> Â /* { dg-do compile } */
> -/* { dg-options "-march=armv8-a+nolse -O2" } */
> +/* { dg-options "-march=armv8-a+nolse -O2 -mno-atomic-ool" } */
>
> Â #include "sync-op-full.x"
>
> diff --git a/gcc/config/aarch64/aarch64.opt
> b/gcc/config/aarch64/aarch64.opt
> index b2e80cbf6f1..83166834165 100644
> --- a/gcc/config/aarch64/aarch64.opt
> +++ b/gcc/config/aarch64/aarch64.opt
> @@ -218,3 +218,7 @@ Enables verbose cost model dumping in the debug
> dump files.
> Â mtrack-speculation
> Â Target Var(aarch64_track_speculation)
> Â Generate code to track when the CPU might be speculating incorrectly.
> +
> +matomic-ool
> +Target Report Mask(ATOMIC_OOL) Save
> +Generate local calls to out-of-line atomic operations.
> diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md
> index 08a3a1ff955..24c1fabee59 100644
> --- a/gcc/config/aarch64/atomics.md
> +++ b/gcc/config/aarch64/atomics.md
> @@ -186,16 +186,27 @@
> Â Â (match_operand:SI 3 "const_int_operand" "")]
> Â Â ""
> Â Â {
> -Â Â Â rtx (*gen) (rtx, rtx, rtx, rtx);
> -
>     /* Use an atomic SWP when available. */
> Â Â Â Â if (TARGET_LSE)
> -Â Â Â Â Â gen = gen_aarch64_atomic_exchange<mode>_lse;
> +Â Â Â Â Â {
> +Â Â Â Â Â Â emit_insn (gen_aarch64_atomic_exchange<mode>_lse
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (operands[0], operands[1], operands[2], operands[3]));
> +Â Â Â Â Â }
> +Â Â Â else if (TARGET_ATOMIC_OOL)
> +Â Â Â Â Â {
> +Â Â Â Â Â Â machine_mode mode = <MODE>mode;
> +Â Â Â Â Â Â rtx func = aarch64_atomic_ool_func (mode, operands[3],
> + &aarch64_ool_swp_names);
> +Â Â Â Â Â Â rtx rval = emit_library_call_value (func, operands[0], LCT_NORMAL,
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â mode, operands[2], mode,
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â XEXP (operands[1], 0),
> ptr_mode);
> +Â Â Â Â Â Â Â emit_move_insn (operands[0], rval);
> +Â Â Â Â Â }
> Â Â Â Â else
> -Â Â Â Â Â gen = gen_aarch64_atomic_exchange<mode>;
> -
> -Â Â Â emit_insn (gen (operands[0], operands[1], operands[2], operands[3]));
> -
> +Â Â Â Â Â {
> +Â Â Â Â Â Â emit_insn (gen_aarch64_atomic_exchange<mode>
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (operands[0], operands[1], operands[2], operands[3]));
> +Â Â Â Â Â }
> Â Â Â Â DONE;
> Â Â }
> Â )
> @@ -280,6 +291,39 @@
> Â Â Â Â Â Â Â Â Â Â }
> Â Â Â Â Â Â Â Â operands[1] = force_reg (<MODE>mode, operands[1]);
> Â Â Â Â Â Â }
> +Â Â Â else if (TARGET_ATOMIC_OOL)
> +Â Â Â Â Â {
> +Â Â Â Â Â Â Â const atomic_ool_names *names;
> +Â Â Â Â Â Â switch (<CODE>)
> +Â Â Â Â Â Â Â Â {
> +Â Â Â Â Â Â Â Â case MINUS:
> +Â Â Â Â Â Â Â Â Â Â operands[1] = expand_simple_unop (<MODE>mode, NEG,
> operands[1],
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NULL, 1);
> +Â Â Â Â Â Â Â Â Â Â /* fallthru */
> +Â Â Â Â Â Â Â Â case PLUS:
> +Â Â Â Â Â Â Â Â Â Â names = &aarch64_ool_ldadd_names;
> +Â Â Â Â Â Â Â Â Â Â break;
> +Â Â Â Â Â Â Â Â case IOR:
> +Â Â Â Â Â Â Â Â Â Â names = &aarch64_ool_ldset_names;
> +Â Â Â Â Â Â Â Â Â Â break;
> +Â Â Â Â Â Â Â Â case XOR:
> +Â Â Â Â Â Â Â Â Â Â names = &aarch64_ool_ldeor_names;
> +Â Â Â Â Â Â Â Â Â Â break;
> +Â Â Â Â Â Â Â Â case AND:
> +Â Â Â Â Â Â Â Â Â Â operands[1] = expand_simple_unop (<MODE>mode, NOT,
> operands[1],
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NULL, 1);
> +Â Â Â Â Â Â Â Â Â Â names = &aarch64_ool_ldclr_names;
> +Â Â Â Â Â Â Â Â Â Â break;
> +Â Â Â Â Â Â Â Â default:
> +Â Â Â Â Â Â Â Â Â Â gcc_unreachable ();
> +Â Â Â Â Â Â Â Â }
> +Â Â Â Â Â Â Â machine_mode mode = <MODE>mode;
> +Â Â Â Â Â Â rtx func = aarch64_atomic_ool_func (mode, operands[2], names);
> +Â Â Â Â Â Â emit_library_call_value (func, NULL_RTX, LCT_NORMAL, mode,
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â operands[1], mode,
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â XEXP (operands[0], 0), ptr_mode);
> +Â Â Â Â Â Â Â DONE;
> +Â Â Â Â Â }
> Â Â Â Â else
> Â Â Â Â Â Â gen = gen_aarch64_atomic_<atomic_optab><mode>;
>
> @@ -405,6 +449,40 @@
> Â Â Â Â Â Â Â Â }
> Â Â Â Â Â Â operands[2] = force_reg (<MODE>mode, operands[2]);
> Â Â Â Â }
> +Â else if (TARGET_ATOMIC_OOL)
> +Â Â Â {
> +Â Â Â Â Â const atomic_ool_names *names;
> +Â Â Â Â Â switch (<CODE>)
> +Â Â Â Â Â Â {
> +Â Â Â Â Â Â case MINUS:
> +Â Â Â Â Â Â Â Â operands[2] = expand_simple_unop (<MODE>mode, NEG, operands[2],
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NULL, 1);
> +Â Â Â Â Â Â Â Â /* fallthru */
> +Â Â Â Â Â Â case PLUS:
> +Â Â Â Â Â Â Â Â names = &aarch64_ool_ldadd_names;
> +Â Â Â Â Â Â Â Â break;
> +Â Â Â Â Â Â case IOR:
> +Â Â Â Â Â Â Â Â names = &aarch64_ool_ldset_names;
> +Â Â Â Â Â Â Â Â break;
> +Â Â Â Â Â Â case XOR:
> +Â Â Â Â Â Â Â Â names = &aarch64_ool_ldeor_names;
> +Â Â Â Â Â Â Â Â break;
> +Â Â Â Â Â Â case AND:
> +Â Â Â Â Â Â Â Â operands[2] = expand_simple_unop (<MODE>mode, NOT, operands[2],
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NULL, 1);
> +Â Â Â Â Â Â Â Â names = &aarch64_ool_ldclr_names;
> +Â Â Â Â Â Â Â Â break;
> +Â Â Â Â Â Â default:
> +Â Â Â Â Â Â Â Â gcc_unreachable ();
> +Â Â Â Â Â Â }
> +Â Â Â Â Â machine_mode mode = <MODE>mode;
> +Â Â Â Â Â rtx func = aarch64_atomic_ool_func (mode, operands[3], names);
> +Â Â Â Â Â rtx rval = emit_library_call_value (func, operands[0],
> LCT_NORMAL, mode,
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â operands[2], mode,
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â XEXP (operands[1], 0),
> ptr_mode);
> +Â Â Â Â Â emit_move_insn (operands[0], rval);
> +Â Â Â Â Â DONE;
> +Â Â Â }
> Â Â else
> Â Â Â Â gen = gen_aarch64_atomic_fetch_<atomic_optab><mode>;
>
> @@ -494,7 +572,7 @@
> Â {
> Â Â /* Use an atomic load-operate instruction when possible. In this case
> Â Â Â Â Â we will re-compute the result from the original mem value. */
> -Â if (TARGET_LSE)
> +Â if (TARGET_LSE || TARGET_ATOMIC_OOL)
> Â Â Â Â {
> Â Â Â Â Â Â rtx tmp = gen_reg_rtx (<MODE>mode);
> Â Â Â Â Â Â operands[2] = force_reg (<MODE>mode, operands[2]);
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 284594df010..70bd0d0a0a1 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -623,7 +623,7 @@ Objective-C and Objective-C++ Dialects}.
> Â -mpc-relative-literal-loads @gol
> Â -msign-return-address=@var{scope} @gol
> Â -march=@var{name}Â -mcpu=@var{name}Â -mtune=@var{name} @gol
> --moverride=@var{string}Â -mverbose-cost-dump -mtrack-speculation}
> +-moverride=@var{string}Â -mverbose-cost-dump -mtrack-speculation
> -matomic-ool}
>
> Â @emph{Adapteva Epiphany Options}
>  @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs @gol
> @@ -15109,6 +15109,18 @@ be used by the compiler when expanding calls to
> Â @code{__builtin_speculation_safe_copy} to permit a more efficient code
> Â sequence to be generated.
>
> +@item -matomic-ool
> +@itemx -mno-atomic-ool
> +Enable or disable calls to out-of-line helpers to implement atomic
> operations.
> +These helpers will, at runtime, determine if ARMv8.1-Atomics instructions
> +should be used; if not, they will use the load/store-exclusive
> instructions
> +that are present in the base ARMv8.0 ISA.
> +
> +This option is only applicable when compiling for the base ARMv8.0
> +instruction set. If using a later revision, e.g.
> @option{-march=armv8.1-a}
> +or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
> +used directly.
> +
> Â @item -march=@var{name}
> Â @opindex march
> Â Specify the name of the target architecture and, optionally, one or
> --
> 2.17.2
>
next prev parent reply other threads:[~2019-09-05 9:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-01 21:47 [PATCH, AArch64, v3 0/6] LSE atomics out-of-line Richard Henderson
2018-11-01 21:46 ` [PATCH, AArch64, v3 1/6] aarch64: Extend %R for integer registers Richard Henderson
2018-11-01 21:46 ` [PATCH, AArch64, v3 2/6] aarch64: Implement TImode compare-and-swap Richard Henderson
2018-11-01 21:47 ` [PATCH, AArch64, v3 4/6] aarch64: Add out-of-line functions for LSE atomics Richard Henderson
2019-09-05 10:00 ` Kyrill Tkachov
2019-09-05 12:13 ` Richard Henderson
2019-09-05 12:53 ` Kyrill Tkachov
2018-11-01 21:47 ` [PATCH, AArch64, v3 5/6] aarch64: Implement -matomic-ool Richard Henderson
2019-09-05 9:56 ` Kyrill Tkachov [this message]
2019-09-05 12:17 ` Richard Henderson
2018-11-01 21:47 ` [PATCH, AArch64, v3 6/6] Enable -matomic-ool by default Richard Henderson
2018-11-01 21:47 ` [PATCH, AArch64, v3 3/6] aarch64: Tidy aarch64_split_compare_and_swap Richard Henderson
2018-11-11 12:30 ` [PATCH, AArch64, v3 0/6] LSE atomics out-of-line Richard Henderson
2019-09-05 9:51 ` Kyrill Tkachov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e90271db-ae0e-02dd-5d29-124d9e9d84da@foss.arm.com \
--to=kyrylo.tkachov@foss.arm.com \
--cc=James.Greenhalgh@arm.com \
--cc=Marcus.Shawcroft@arm.com \
--cc=Ramana.Radhakrishnan@arm.com \
--cc=agraf@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).