diff options
author | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2024-11-14 16:15:08 +0000 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2024-11-14 16:15:08 +0000 |
commit | bca0fc1410bc6759365ef974974dc40915333734 (patch) | |
tree | 7677f89dabe1cad3a96cb1420e53153c04d0ad1d /gcc | |
parent | a2bb4588f653148ea61913102965337c366cc79b (diff) | |
download | gcc-bca0fc1410bc6759365ef974974dc40915333734.zip gcc-bca0fc1410bc6759365ef974974dc40915333734.tar.gz gcc-bca0fc1410bc6759365ef974974dc40915333734.tar.bz2 |
aarch64: Add __builtin_aarch64_gcs* and __gcs* tests
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/acle/gcs-1.c: New test.
* gcc.target/aarch64/gcspopm-1.c: New test.
* gcc.target/aarch64/gcspr-1.c: New test.
* gcc.target/aarch64/gcsss-1.c: New test.
Co-authored-by: Yury Khrustalev <yury.khrustalev@arm.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/acle/gcs-1.c | 42 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/gcspopm-1.c | 63 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/gcspr-1.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/gcsss-1.c | 48 |
4 files changed, 184 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/aarch64/acle/gcs-1.c b/gcc/testsuite/gcc.target/aarch64/acle/gcs-1.c new file mode 100644 index 0000000..d97f2e5 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/acle/gcs-1.c @@ -0,0 +1,42 @@ +/* Test the __gsc* ACLE intrinsics. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -march=armv8.9-a -mbranch-protection=none" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include <arm_acle.h> + +/* +**test_gcspr: +** mrs x0, s3_3_c2_c5_1 // gcspr_el0 +** ret +*/ +void * +test_gcspr () +{ + return __gcspr (); +} + +/* +**test_gcspopm: +** mov x0, 0 +** sysl x0, #3, c7, c7, #1 // gcspopm +** ret +*/ +uint64_t +test_gcspopm () +{ + return __gcspopm (); +} + +/* +**test_gcsss: +** sys #3, c7, c7, #2, x0 // gcsss1 +** mov x0, 0 +** sysl x0, #3, c7, c7, #3 // gcsss2 +** ret +*/ +void * +test_gcsss (void *stack) +{ + return __gcsss (stack); +} 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 0000000..5bb1c6e --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/gcspopm-1.c @@ -0,0 +1,63 @@ +/* { 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 +** hint 40 // chkfeat x16 +** cbz x16, .* +** ret +** mov x0, (0|x16) +** sysl x0, #3, c7, c7, #1 // gcspopm +** ret +*/ +unsigned long long +foo3 (unsigned long long x) +{ + if (__builtin_aarch64_chkfeat (1) == 0) + return __builtin_aarch64_gcspopm (); + return x; +} + +/* +**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 0000000..0e65197 --- /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 0000000..9b222e9 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/gcsss-1.c @@ -0,0 +1,48 @@ +/* { 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 \1, #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 +** cbz x16, .* +** ret +** sys #3, c7, c7, #2, x0 // gcsss1 +** mov x0, (0|x16) +** sysl x0, #3, c7, c7, #3 // gcsss2 +** ret +*/ +void * +foo3 (void *p) +{ + if (__builtin_aarch64_chkfeat (1) == 0) + return __builtin_aarch64_gcsss (p); + return p; +} |