public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][committed] aarch64: Add test for LDAR generation from __atomic_load_n
@ 2022-10-06 11:11 Kyrylo Tkachov
  0 siblings, 0 replies; only message in thread
From: Kyrylo Tkachov @ 2022-10-06 11:11 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 217 bytes --]

Hi all,

I'd like a test to check the generation of LDAR for atomic_load_n.
No new functionality added.
Pushing to trunk.
Thanks,
Kyrill

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/ldar_1.c: New test.

[-- Attachment #2: ldar-test.patch --]
[-- Type: application/octet-stream, Size: 1374 bytes --]

diff --git a/gcc/testsuite/gcc.target/aarch64/ldar_1.c b/gcc/testsuite/gcc.target/aarch64/ldar_1.c
new file mode 100644
index 0000000000000000000000000000000000000000..d968a72b30f7c84a7822baef7ea28d1f31b7195a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/ldar_1.c
@@ -0,0 +1,66 @@
+/* Test the LDAR instruction generation from atomic acquire loads.  */
+/* { dg-do assemble } */
+/* { dg-additional-options "--save-temps -O1" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+#include <stdint.h>
+
+#pragma GCC target "+norcpc"
+
+uint8_t v_uint8_t;
+uint16_t v_uint16_t;
+uint32_t v_uint32_t;
+uint64_t v_uint64_t;
+
+/*
+** load_uint8_t:
+**      ...
+**      ldarb	w0, \[x[0-9]+\]
+**      ret
+*/
+
+uint8_t
+load_uint8_t (void)
+{
+  return __atomic_load_n (&v_uint8_t, __ATOMIC_ACQUIRE);
+}
+
+/*
+** load_uint16_t:
+**      ...
+**      ldarh	w0, \[x[0-9]+\]
+**      ret
+*/
+
+uint16_t
+load_uint16_t (void)
+{
+  return __atomic_load_n (&v_uint16_t, __ATOMIC_ACQUIRE);
+}
+
+/*
+** load_uint32_t:
+**      ...
+**      ldar	w0, \[x[0-9]+\]
+**      ret
+*/
+
+uint32_t
+load_uint32_t (void)
+{
+  return __atomic_load_n (&v_uint32_t, __ATOMIC_ACQUIRE);
+}
+
+/*
+** load_uint64_t:
+**      ...
+**      ldar	x0, \[x[0-9]+\]
+**      ret
+*/
+
+uint64_t
+load_uint64_t (void)
+{
+  return __atomic_load_n (&v_uint64_t, __ATOMIC_ACQUIRE);
+}
+

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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06 11:11 [PATCH][committed] aarch64: Add test for LDAR generation from __atomic_load_n Kyrylo Tkachov

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