public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/gcs)] aarch64: Add __builtin_aarch64_gcs* tests
@ 2024-02-14 15:27 Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2024-02-14 15:27 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5011ae6000f05f20517cd79cc9b8fa600ab2d37f

commit 5011ae6000f05f20517cd79cc9b8fa600ab2d37f
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Tue Jun 6 17:35:51 2023 +0100

    aarch64: Add __builtin_aarch64_gcs* tests
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/aarch64/gcspopm-1.c: New test.
            * gcc.target/aarch64/gcspr-1.c: New test.
            * gcc.target/aarch64/gcsss-1.c: New test.

Diff:
---
 gcc/testsuite/gcc.target/aarch64/gcspopm-1.c | 69 ++++++++++++++++++++++++++++
 gcc/testsuite/gcc.target/aarch64/gcspr-1.c   | 31 +++++++++++++
 gcc/testsuite/gcc.target/aarch64/gcsss-1.c   | 49 ++++++++++++++++++++
 3 files changed, 149 insertions(+)

diff --git a/gcc/testsuite/gcc.target/aarch64/gcspopm-1.c b/gcc/testsuite/gcc.target/aarch64/gcspopm-1.c
new file mode 100644
index 000000000000..6e6add39cf75
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcspopm-1.c
@@ -0,0 +1,69 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=none" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+/*
+**foo1:
+**	sysl	xzr, #3, c7, c7, #1 // gcspopm
+**	ret
+*/
+void
+foo1 (void)
+{
+  __builtin_aarch64_gcspopm ();
+}
+
+/*
+**foo2:
+**	mov	x0, 0
+**	sysl	x0, #3, c7, c7, #1 // gcspopm
+**	ret
+*/
+unsigned long long
+foo2 (void)
+{
+  return __builtin_aarch64_gcspopm ();
+}
+
+/*
+**foo3:
+**	mov	x16, 1
+** (
+**	mov	x0, 0
+**	hint	40 // chkfeat x16
+** |
+**	hint	40 // chkfeat x16
+**	mov	x0, 0
+** )
+**	cbz	x16, .*
+**	ret
+**	mov	x0, 0
+**	sysl	x0, #3, c7, c7, #1 // gcspopm
+**	ret
+*/
+unsigned long long
+foo3 (void)
+{
+  if (__builtin_aarch64_chkfeat (1) == 0)
+    return __builtin_aarch64_gcspopm ();
+  return 0;
+}
+
+/*
+**foo4:
+**	sysl	xzr, #3, c7, c7, #1 // gcspopm
+**	mov	x0, 0
+**	sysl	x0, #3, c7, c7, #1 // gcspopm
+**	sysl	xzr, #3, c7, c7, #1 // gcspopm
+**	ret
+*/
+unsigned long long
+foo4 (void)
+{
+  unsigned long long a = __builtin_aarch64_gcspopm ();
+  unsigned long long b = __builtin_aarch64_gcspopm ();
+  unsigned long long c = __builtin_aarch64_gcspopm ();
+  (void) a;
+  (void) c;
+  return b;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/gcspr-1.c b/gcc/testsuite/gcc.target/aarch64/gcspr-1.c
new file mode 100644
index 000000000000..0e651979551d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcspr-1.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=none" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+/*
+**foo1:
+**	mrs	x0, s3_3_c2_c5_1 // gcspr_el0
+**	ret
+*/
+void *
+foo1 (void)
+{
+  return __builtin_aarch64_gcspr ();
+}
+
+/*
+**foo2:
+**	mrs	x[0-9]*, s3_3_c2_c5_1 // gcspr_el0
+**	sysl	xzr, #3, c7, c7, #1 // gcspopm
+**	mrs	x[0-9]*, s3_3_c2_c5_1 // gcspr_el0
+**	sub	x0, x[0-9]*, x[0-9]*
+**	ret
+*/
+long
+foo2 (void)
+{
+  const char *p = __builtin_aarch64_gcspr ();
+  __builtin_aarch64_gcspopm ();
+  const char *q = __builtin_aarch64_gcspr ();
+  return p - q;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/gcsss-1.c b/gcc/testsuite/gcc.target/aarch64/gcsss-1.c
new file mode 100644
index 000000000000..025c7fee647f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcsss-1.c
@@ -0,0 +1,49 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=none" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+/*
+**foo1:
+**	sys	#3, c7, c7, #2, x0 // gcsss1
+**	mov	x[0-9]*, 0
+**	sysl	x[0-9]*, #3, c7, c7, #3 // gcsss2
+**	ret
+*/
+void
+foo1 (void *p)
+{
+  __builtin_aarch64_gcsss (p);
+}
+
+/*
+**foo2:
+**	sys	#3, c7, c7, #2, x0 // gcsss1
+**	mov	x0, 0
+**	sysl	x0, #3, c7, c7, #3 // gcsss2
+**	ret
+*/
+void *
+foo2 (void *p)
+{
+  return __builtin_aarch64_gcsss (p);
+}
+
+/*
+**foo3:
+**	mov	x16, 1
+**	hint	40 // chkfeat x16
+**	cbnz	x16, .*
+**	sys	#3, c7, c7, #2, x0 // gcsss1
+**	mov	x0, 0
+**	sysl	x0, #3, c7, c7, #3 // gcsss2
+**	ret
+**	mov	x0, 0
+**	ret
+*/
+void *
+foo3 (void *p)
+{
+  if (__builtin_aarch64_chkfeat (1) == 0)
+    return __builtin_aarch64_gcsss (p);
+  return 0;
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/vendors/ARM/heads/gcs)] aarch64: Add __builtin_aarch64_gcs* tests
@ 2024-04-10 10:48 Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2024-04-10 10:48 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:90ff9175ede4f4671755f0296b5ce89d8d69f966

commit 90ff9175ede4f4671755f0296b5ce89d8d69f966
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Tue Jun 6 17:35:51 2023 +0100

    aarch64: Add __builtin_aarch64_gcs* tests
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/aarch64/gcspopm-1.c: New test.
            * gcc.target/aarch64/gcspr-1.c: New test.
            * gcc.target/aarch64/gcsss-1.c: New test.

Diff:
---
 gcc/testsuite/gcc.target/aarch64/gcspopm-1.c | 69 ++++++++++++++++++++++++++++
 gcc/testsuite/gcc.target/aarch64/gcspr-1.c   | 31 +++++++++++++
 gcc/testsuite/gcc.target/aarch64/gcsss-1.c   | 49 ++++++++++++++++++++
 3 files changed, 149 insertions(+)

diff --git a/gcc/testsuite/gcc.target/aarch64/gcspopm-1.c b/gcc/testsuite/gcc.target/aarch64/gcspopm-1.c
new file mode 100644
index 00000000000..6e6add39cf7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcspopm-1.c
@@ -0,0 +1,69 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=none" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+/*
+**foo1:
+**	sysl	xzr, #3, c7, c7, #1 // gcspopm
+**	ret
+*/
+void
+foo1 (void)
+{
+  __builtin_aarch64_gcspopm ();
+}
+
+/*
+**foo2:
+**	mov	x0, 0
+**	sysl	x0, #3, c7, c7, #1 // gcspopm
+**	ret
+*/
+unsigned long long
+foo2 (void)
+{
+  return __builtin_aarch64_gcspopm ();
+}
+
+/*
+**foo3:
+**	mov	x16, 1
+** (
+**	mov	x0, 0
+**	hint	40 // chkfeat x16
+** |
+**	hint	40 // chkfeat x16
+**	mov	x0, 0
+** )
+**	cbz	x16, .*
+**	ret
+**	mov	x0, 0
+**	sysl	x0, #3, c7, c7, #1 // gcspopm
+**	ret
+*/
+unsigned long long
+foo3 (void)
+{
+  if (__builtin_aarch64_chkfeat (1) == 0)
+    return __builtin_aarch64_gcspopm ();
+  return 0;
+}
+
+/*
+**foo4:
+**	sysl	xzr, #3, c7, c7, #1 // gcspopm
+**	mov	x0, 0
+**	sysl	x0, #3, c7, c7, #1 // gcspopm
+**	sysl	xzr, #3, c7, c7, #1 // gcspopm
+**	ret
+*/
+unsigned long long
+foo4 (void)
+{
+  unsigned long long a = __builtin_aarch64_gcspopm ();
+  unsigned long long b = __builtin_aarch64_gcspopm ();
+  unsigned long long c = __builtin_aarch64_gcspopm ();
+  (void) a;
+  (void) c;
+  return b;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/gcspr-1.c b/gcc/testsuite/gcc.target/aarch64/gcspr-1.c
new file mode 100644
index 00000000000..0e651979551
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcspr-1.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=none" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+/*
+**foo1:
+**	mrs	x0, s3_3_c2_c5_1 // gcspr_el0
+**	ret
+*/
+void *
+foo1 (void)
+{
+  return __builtin_aarch64_gcspr ();
+}
+
+/*
+**foo2:
+**	mrs	x[0-9]*, s3_3_c2_c5_1 // gcspr_el0
+**	sysl	xzr, #3, c7, c7, #1 // gcspopm
+**	mrs	x[0-9]*, s3_3_c2_c5_1 // gcspr_el0
+**	sub	x0, x[0-9]*, x[0-9]*
+**	ret
+*/
+long
+foo2 (void)
+{
+  const char *p = __builtin_aarch64_gcspr ();
+  __builtin_aarch64_gcspopm ();
+  const char *q = __builtin_aarch64_gcspr ();
+  return p - q;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/gcsss-1.c b/gcc/testsuite/gcc.target/aarch64/gcsss-1.c
new file mode 100644
index 00000000000..025c7fee647
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/gcsss-1.c
@@ -0,0 +1,49 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbranch-protection=none" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+/*
+**foo1:
+**	sys	#3, c7, c7, #2, x0 // gcsss1
+**	mov	x[0-9]*, 0
+**	sysl	x[0-9]*, #3, c7, c7, #3 // gcsss2
+**	ret
+*/
+void
+foo1 (void *p)
+{
+  __builtin_aarch64_gcsss (p);
+}
+
+/*
+**foo2:
+**	sys	#3, c7, c7, #2, x0 // gcsss1
+**	mov	x0, 0
+**	sysl	x0, #3, c7, c7, #3 // gcsss2
+**	ret
+*/
+void *
+foo2 (void *p)
+{
+  return __builtin_aarch64_gcsss (p);
+}
+
+/*
+**foo3:
+**	mov	x16, 1
+**	hint	40 // chkfeat x16
+**	cbnz	x16, .*
+**	sys	#3, c7, c7, #2, x0 // gcsss1
+**	mov	x0, 0
+**	sysl	x0, #3, c7, c7, #3 // gcsss2
+**	ret
+**	mov	x0, 0
+**	ret
+*/
+void *
+foo3 (void *p)
+{
+  if (__builtin_aarch64_chkfeat (1) == 0)
+    return __builtin_aarch64_gcsss (p);
+  return 0;
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-10 10:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14 15:27 [gcc(refs/vendors/ARM/heads/gcs)] aarch64: Add __builtin_aarch64_gcs* tests Szabolcs Nagy
2024-04-10 10:48 Szabolcs Nagy

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