public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Change atomics flags for Morello
@ 2022-10-13 10:46 Matthew Malcomson
  0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-10-13 10:46 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:060debf7a790bc9369d3323edd4a016cf40e886e

commit 060debf7a790bc9369d3323edd4a016cf40e886e
Author: Matthew Malcomson <matthew.malcomson@arm.com>
Date:   Thu Oct 13 11:40:14 2022 +0100

    Change atomics flags for Morello
    
    Before this patch we had disabled both `-moutline-atomics` and
    `-fno-inline-atomics` for purecap Morello.  There is no reason to
    disable `-moutline-atomics` for Morello.  The purpose of
    `-moutline-atomics` is to create a binary which will run correctly on
    Armv8-a but take advantage of the LSE atomics when running on an
    architecture which has those.
    
    Since the Morello architecture has the LSE atomic instructions for
    non-capability data types, we naturally fall into the same clauses as
    non-capability architectures which have the LSE instructions -- avoiding
    the outline atomics implementations all together.
    We do have to add a clause which avoids using the outline-atomic stubs
    for capability data types.  For -mfake-capability it's worth using these
    since the actual data type at runtime is still a long unsigned integer.
    For Morello there is no point using the outline stubs since there is no
    existing "faster" version to choose at runtime.
    
    In other words, the point of these outline stubs is to allow using a
    faster version of an atomic operation when running on an architecture
    which provides such a faster version, while still producing a binary
    which can run on architectures which do not have this faster version.
    As yet there is no different architecture which would be concerned with
    atomic operations on capabilities, hence there is no point in worrying
    about the out-of-line stubs.
    
    W.r.t. `-fno-inline-atomics`: Morello has inline implementations of all
    the atomic operations that libatomic handles (and in fact also has an
    inline implementation of the capability operations which libatomic does
    not handle).  Because of that, libatomic is compiled just fine and
    the only thing we need to do in order to support `-fno-inline-atomics`
    on everything except capability data is to remove the error on receiving
    the command line flag.
    Doing so means that all the existing libatomic testcases pass.
    
    This does mean that we're in a situation where when compiling with
    `-fno-inline-atomics` and trying to perform atomic operations on
    capability data we get a linker error rather than a nice compile-time
    error.
    However, as Richard S pointed out, `-fno-inline-atomics` is not a
    documented flag and it hence seems reasonable to claim that it is not
    supported.
    
    One alternate route would be to keep the current compile-time error
    message when attempting to use `-fno-inline-atomics` with Morello.
    I feel that it is worth allowing for those data types that it
    automatically works on.
    
    Another alternate route would be to add capability data type operations
    into libatomic so that the feature is fully supported.
    This is the eventual goal, but is left for the moment in order to focus
    on higher priority things.

Diff:
---
 gcc/config/aarch64/aarch64.c                             | 16 ----------------
 gcc/config/aarch64/atomics.md                            | 15 ++++++++++-----
 .../aarch64/morello/atomics/morello-atomics.exp          |  7 +------
 3 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 2011a062610..456a2b10710 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -15400,28 +15400,12 @@ aarch64_override_options_internal (struct gcc_options *opts)
     error ("MORELLO TODO OpenMP has not been implemented for Morello");
   if (opts->x_flag_openacc && TARGET_CAPABILITY_ANY)
     error ("MORELLO TODO OpenACC has not been implemented for Morello");
-  if (!flag_inline_atomics && TARGET_CAPABILITY_ANY)
-    error ("MORELLO TODO -fno-inline-atomics has not been implemented for Morello");
   if (flag_fake_hybrid >= flag_fake_hybrid_init)
     srand (get_random_seed (false));
 
   if (TARGET_CAPABILITY_ANY && TARGET_SVE)
     error ("SVE is not supported with capabilities");
 
-  if ((aarch64_cap == AARCH64_CAPABILITY_PURE
-       || aarch64_cap == AARCH64_CAPABILITY_HYBRID)
-      && TARGET_OUTLINE_ATOMICS)
-    {
-      if (aarch64_flag_outline_atomics == 2)
-	/* If outline atomics was just set by default, unset it.
-	  Complain if it was explicitly requested on the command line.
-	  MORELLO TODO Maybe should think a bit harder about the user interface
-	  here, but it's not that important.  */
-	aarch64_flag_outline_atomics = 0;
-      else
-	error ("Outlined Atomics are not supported with capabilities");
-    }
-
   if (opts->x_aarch64_override_tune_string)
     aarch64_parse_override_string (opts->x_aarch64_override_tune_string,
 				  &aarch64_tune_params);
diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md
index 0c5d427915c..bd78580ea3c 100644
--- a/gcc/config/aarch64/atomics.md
+++ b/gcc/config/aarch64/atomics.md
@@ -350,10 +350,16 @@
   {
     rtx (*gen) (rtx, rtx, rtx);
 
-    /* Use an atomic load-operate instruction when possible.  */
-    if (TARGET_OUTLINE_ATOMICS)
+    /* Use an atomic load-operate instruction when possible.
+       Note that there is no point using outline atomics when actually
+       targetting Morello since we know the architecture that we're targetting,
+       and anyway there aren't the LSE instructions to act on capability data.
+
+       (OOL atomics was introduced so we could generate a program which would
+       work on ARMv8-a targets but also efficiently use the LSE instructions
+       when running on a system that supports it).  */
+    if (TARGET_OUTLINE_ATOMICS && TARGET_CAPABILITY_FAKE)
       {
-	gcc_assert (TARGET_CAPABILITY_FAKE);
 	const atomic_ool_names *names;
 
 	switch (<CODE>)
@@ -608,9 +614,8 @@
   rtx (*gen) (rtx, rtx, rtx, rtx);
 
   /* Use an atomic load-operate instruction when possible.  */
-  if (TARGET_OUTLINE_ATOMICS)
+  if (TARGET_OUTLINE_ATOMICS && TARGET_CAPABILITY_FAKE)
     {
-      gcc_assert (TARGET_CAPABILITY_FAKE);
       const atomic_ool_names *names;
       switch (<CODE>)
 	{
diff --git a/gcc/testsuite/gcc.target/aarch64/morello/atomics/morello-atomics.exp b/gcc/testsuite/gcc.target/aarch64/morello/atomics/morello-atomics.exp
index e114fec30ed..b07192b43cc 100644
--- a/gcc/testsuite/gcc.target/aarch64/morello/atomics/morello-atomics.exp
+++ b/gcc/testsuite/gcc.target/aarch64/morello/atomics/morello-atomics.exp
@@ -36,12 +36,7 @@ if { [check_effective_target_aarch64_capability_any] } {
 }
 
 torture-init
-
-if { [check_effective_target_cheri_capability_pure] } {
-  set-torture-options "$C_TORTURE_OPTIONS" [list { } { -mno-outline-atomics } ]
-} else {
-  set-torture-options "$C_TORTURE_OPTIONS" [list { } { -mno-outline-atomics } { -moutline-atomics } ]
-}
+set-torture-options "$C_TORTURE_OPTIONS" [list { } { -mno-outline-atomics } { -moutline-atomics } ]
 
 # Main loop.
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-13 10:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-13 10:46 [gcc(refs/vendors/ARM/heads/morello)] Change atomics flags for Morello Matthew Malcomson

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).