]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add outline-atomics to target attribute.
authorMartin Liska <mliska@suse.cz>
Thu, 21 May 2020 10:45:47 +0000 (12:45 +0200)
committerMartin Liska <mliska@suse.cz>
Thu, 21 May 2020 15:02:07 +0000 (17:02 +0200)
* common/config/aarch64/aarch64-common.c (aarch64_handle_option):
Handle OPT_moutline_atomics.
* config/aarch64/aarch64.c: Add outline-atomics to
aarch64_attributes.

* doc/extend.texi: Document the newly added target attribute.

* gcc.target/aarch64/target_attr_20.c: New test.
* gcc.target/aarch64/target_attr_21.c: New test.

(cherry picked from commit 9e02b45ffc60e0078bde3c56a14f00c54b7f8039)

gcc/ChangeLog
gcc/common/config/aarch64/aarch64-common.c
gcc/config/aarch64/aarch64.c
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/target_attr_20.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/target_attr_21.c [new file with mode: 0644]

index 80a48f8341cac4f98cce0a52d7ec71ff898971cc..9bab03a9cff1a7da0f3f4c7ec491f565552e7e37 100644 (file)
@@ -1,3 +1,11 @@
+2020-05-21  Martin Liska  <mliska@suse.cz>
+
+       * common/config/aarch64/aarch64-common.c (aarch64_handle_option):
+       Handle OPT_moutline_atomics.
+       * config/aarch64/aarch64.c: Add outline-atomics to
+       aarch64_attributes.
+       * doc/extend.texi: Document the newly added target attribute.
+
 2020-05-14  Szabolcs Nagy  <szabolcs.nagy@arm.com>
 
        Backport from mainline.
index db9842b1ea6f0e3573c98beacd7d1dc237bed9f9..60121b19d8acbc0bd1eafb931ab06f07e20e0469 100644 (file)
@@ -161,6 +161,10 @@ aarch64_handle_option (struct gcc_options *opts,
       opts->x_flag_omit_leaf_frame_pointer = val;
       return true;
 
+    case OPT_moutline_atomics:
+      opts->x_aarch64_flag_outline_atomics = val;
+      return true;
+
     default:
       return true;
     }
index 78acd7ecfdb47cb6c75a3404817a94eddf9cdd20..e61c9bb00cb50aeaff51cdf0f58fb9a0617d41bb 100644 (file)
@@ -12545,6 +12545,8 @@ static const struct aarch64_attribute_info aarch64_attributes[] =
      aarch64_handle_attr_branch_protection, OPT_mbranch_protection_ },
   { "sign-return-address", aarch64_attr_enum, false, NULL,
      OPT_msign_return_address_ },
+  { "outline-atomics", aarch64_attr_bool, true, NULL,
+     OPT_moutline_atomics},
   { NULL, aarch64_attr_custom, false, NULL, OPT____ }
 };
 
index 51ebb90e32d7eb2e98dafd9f995e8120dd9c1579..e231add27fdd7d75ca3aad0b6b71b9e575463b37 100644 (file)
@@ -3957,6 +3957,12 @@ Select the function scope on which branch protection will be applied.  The
 behavior and permissible arguments are the same as for the command-line option
 @option{-mbranch-protection=}.  The default value is @code{none}.
 
+@item outline-atomics
+@cindex @code{outline-atomics} function attribute, AArch64
+Enable or disable calls to out-of-line helpers to implement atomic operations.
+This corresponds to the behavior of the command line options
+@option{-moutline-atomics} and @option{-mno-outline-atomics}.
+
 @end table
 
 The above target attributes can be specified as follows:
index 667a1edefeab5945fd79427c25a7a732fe74eb32..695ffa33298f86e77d2f4479a9ee1d7aeeb331f7 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-21  Martin Liska  <mliska@suse.cz>
+
+       * gcc.target/aarch64/target_attr_20.c: New test.
+       * gcc.target/aarch64/target_attr_21.c: New test.
+
 2020-05-20  Mark Eggleston  <markeggleston@gcc.gnu.org>
 
        PR fortran/39695
diff --git a/gcc/testsuite/gcc.target/aarch64/target_attr_20.c b/gcc/testsuite/gcc.target/aarch64/target_attr_20.c
new file mode 100644 (file)
index 0000000..509fb03
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-march=armv8-a+nolse -moutline-atomics" } */
+
+int b, c, d, e, f, h;
+short g;
+int foo (int) __attribute__ ((__const__));
+
+__attribute__ ((target ("no-outline-atomics")))
+void
+bar (void)
+{
+  while (1)
+    {
+      while (1)
+       {
+         __atomic_load_n (&e, 0);
+         if (foo (2))
+           __sync_val_compare_and_swap (&c, 0, f);
+         b = 1;
+         if (h == e)
+           break;
+       }
+      __sync_val_compare_and_swap (&g, -1, f);
+    }
+}
+
+/* { dg-final { scan-assembler-not "bl.*__aarch64_cas2_acq_rel" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/target_attr_21.c b/gcc/testsuite/gcc.target/aarch64/target_attr_21.c
new file mode 100644 (file)
index 0000000..acace4c
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-march=armv8-a+nolse -mno-outline-atomics" } */
+
+int b, c, d, e, f, h;
+short g;
+int foo (int) __attribute__ ((__const__));
+
+__attribute__ ((target ("outline-atomics")))
+void
+bar (void)
+{
+  while (1)
+    {
+      while (1)
+       {
+         __atomic_load_n (&e, 0);
+         if (foo (2))
+           __sync_val_compare_and_swap (&c, 0, f);
+         b = 1;
+         if (h == e)
+           break;
+       }
+      __sync_val_compare_and_swap (&g, -1, f);
+    }
+}
+
+/* { dg-final { scan-assembler-times "bl.*__aarch64_cas2_acq_rel" 1 } } */