This patch defines __ARM_FEATURE_ macros for the SVE2.2 and SME2.2
extensions, together with necessary new tests.  In the v1 of the series
(https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707393.html),
this was a part of the first patch, but now it's been moved to the tail
end of the series so that these definitions aren't visible before the
contents of the extensions are actually available.

gcc/ChangeLog:

        * config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
        Emit definitions for __ARM_FEATURE_{SVE,SME}2p2.

gcc/testsuite/ChangeLog:

        * gcc.target/aarch64/pragma_cpp_predefs_3.c: Add SVE2p2 tests.
        * gcc.target/aarch64/pragma_cpp_predefs_4.c: Add SME2p2 test.
---
 gcc/config/aarch64/aarch64-c.cc               |   2 +
 .../gcc.target/aarch64/pragma_cpp_predefs_3.c | 100 ++++++++++++++++++
 .../gcc.target/aarch64/pragma_cpp_predefs_4.c |  14 +++
 3 files changed, 116 insertions(+)

diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc
index d15a9d689fe..430aa67bb98 100644
--- a/gcc/config/aarch64/aarch64-c.cc
+++ b/gcc/config/aarch64/aarch64-c.cc
@@ -234,6 +234,7 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
   aarch64_def_or_undef (TARGET_SVE2_SHA3, "__ARM_FEATURE_SVE2_SHA3", pfile);
   aarch64_def_or_undef (TARGET_SVE2_SM4, "__ARM_FEATURE_SVE2_SM4", pfile);
   aarch64_def_or_undef (TARGET_SVE2p1, "__ARM_FEATURE_SVE2p1", pfile);
+  aarch64_def_or_undef (TARGET_SVE2p2, "__ARM_FEATURE_SVE2p2", pfile);
 
   aarch64_def_or_undef (TARGET_LSE, "__ARM_FEATURE_ATOMICS", pfile);
   aarch64_def_or_undef (TARGET_AES, "__ARM_FEATURE_AES", pfile);
@@ -314,6 +315,7 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
                        pfile);
   aarch64_def_or_undef (AARCH64_HAVE_ISA (SME2p1),
                        "__ARM_FEATURE_SME2p1", pfile);
+  aarch64_def_or_undef (TARGET_SME2p2, "__ARM_FEATURE_SME2p2", pfile);
   aarch64_def_or_undef (TARGET_FAMINMAX, "__ARM_FEATURE_FAMINMAX", pfile);
   aarch64_def_or_undef (TARGET_PCDPHINT, "__ARM_FEATURE_PCDPHINT", pfile);
   aarch64_def_or_undef (AARCH64_HAVE_ISA (SME_TMOP),
diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_3.c 
b/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_3.c
index f1f70ed7b5c..9c96249050d 100644
--- a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_3.c
+++ b/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_3.c
@@ -32,6 +32,10 @@
 #error "__ARM_FEATURE_SVE2p1 is defined but should not be!"
 #endif
 
+#ifdef __ARM_FEATURE_SVE2p2
+#error "__ARM_FEATURE_SVE2p2 is defined but should not be!"
+#endif
+
 #pragma GCC push_options
 #pragma GCC target ("arch=armv8.2-a+sve")
 
@@ -63,6 +67,10 @@
 #error "__ARM_FEATURE_SVE2p1 is defined but should not be!"
 #endif
 
+#ifdef __ARM_FEATURE_SVE2p2
+#error "__ARM_FEATURE_SVE2p2 is defined but should not be!"
+#endif
+
 #pragma GCC pop_options
 
 #pragma GCC push_options
@@ -96,6 +104,10 @@
 #error "__ARM_FEATURE_SVE2p1 is defined but should not be!"
 #endif
 
+#ifdef __ARM_FEATURE_SVE2p2
+#error "__ARM_FEATURE_SVE2p2 is defined but should not be!"
+#endif
+
 #pragma GCC pop_options
 
 #pragma GCC push_options
@@ -287,6 +299,47 @@
 #error "__ARM_FEATURE_SVE2p1 is not defined but should be!"
 #endif
 
+#ifdef __ARM_FEATURE_SVE2p2
+#error "__ARM_FEATURE_SVE2p2 is defined but should not be!"
+#endif
+
+#pragma GCC pop_options
+
+#pragma GCC push_options
+#pragma GCC target ("arch=armv9-a+sve2p2")
+
+#ifndef __ARM_FEATURE_SVE
+#error "__ARM_FEATURE_SVE is not defined but should be!"
+#endif
+
+#ifndef __ARM_FEATURE_SVE2
+#error "__ARM_FEATURE_SVE2 is not defined but should be!"
+#endif
+
+#ifdef __ARM_FEATURE_SVE2_AES
+#error "__ARM_FEATURE_SVE2_AES is defined but should not be!"
+#endif
+
+#ifdef __ARM_FEATURE_SVE2_BITPERM
+#error "__ARM_FEATURE_SVE2_BITPERM is defined but should not be!"
+#endif
+
+#ifdef __ARM_FEATURE_SVE2_SHA3
+#error "__ARM_FEATURE_SVE2_SHA3 is defined but should not be!"
+#endif
+
+#ifdef __ARM_FEATURE_SVE2_SM4
+#error "__ARM_FEATURE_SVE2_SM4 is defined but should not be!"
+#endif
+
+#ifndef __ARM_FEATURE_SVE2p1
+#error "__ARM_FEATURE_SVE2p1 is not defined but should be!"
+#endif
+
+#ifndef __ARM_FEATURE_SVE2p2
+#error "__ARM_FEATURE_SVE2p2 is not defined but should be!"
+#endif
+
 #pragma GCC pop_options
 
 #pragma GCC push_options
@@ -320,6 +373,48 @@
 #error "__ARM_FEATURE_SVE2p1 is not defined but should be!"
 #endif
 
+#ifdef __ARM_FEATURE_SVE2p2
+#error "__ARM_FEATURE_SVE2p2 is defined but should not be!"
+#endif
+
+#pragma GCC pop_options
+
+#pragma GCC push_options
+#pragma GCC target 
("arch=armv9-a+sve2-aes+sve2-bitperm+sve2-sha3+sve2-sm4+sve2p1+sve2p2")
+
+#ifndef __ARM_FEATURE_SVE
+#error "__ARM_FEATURE_SVE is not defined but should be!"
+#endif
+
+#ifndef __ARM_FEATURE_SVE2
+#error "__ARM_FEATURE_SVE2 is not defined but should be!"
+#endif
+
+#ifndef __ARM_FEATURE_SVE2_AES
+#error "__ARM_FEATURE_SVE2_AES is not defined but should be!"
+#endif
+
+#ifndef __ARM_FEATURE_SVE2_BITPERM
+#error "__ARM_FEATURE_SVE2_BITPERM is not defined but should be!"
+#endif
+
+#ifndef __ARM_FEATURE_SVE2_SHA3
+#error "__ARM_FEATURE_SVE2_SHA3 is not defined but should be!"
+#endif
+
+#ifndef __ARM_FEATURE_SVE2_SM4
+#error "__ARM_FEATURE_SVE2_SM4 is not defined but should be!"
+#endif
+
+#ifndef __ARM_FEATURE_SVE2p1
+#error "__ARM_FEATURE_SVE2p1 is not defined but should be!"
+#endif
+
+#ifndef __ARM_FEATURE_SVE2p2
+#error "__ARM_FEATURE_SVE2p2 is not defined but should be!"
+#endif
+
+
 #pragma GCC push_options
 #pragma GCC target ("general-regs-only")
 
@@ -351,6 +446,11 @@
 #error "__ARM_FEATURE_SVE2p1 is defined but should not be!"
 #endif
 
+#ifdef __ARM_FEATURE_SVE2p2
+#error "__ARM_FEATURE_SVE2p2 is defined but should not be!"
+#endif
+
+
 #pragma GCC pop_options
 
 #pragma GCC pop_options
diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_4.c 
b/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_4.c
index ea112f12c79..4a3ad6fdd06 100644
--- a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_4.c
+++ b/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_4.c
@@ -218,6 +218,20 @@
 #error Foo
 #endif
 
+#pragma GCC target "+nothing+sve2+sme2p2"
+#ifndef __ARM_FEATURE_SME
+#error Foo
+#endif
+#ifndef __ARM_FEATURE_SME2
+#error Foo
+#endif
+#ifndef __ARM_FEATURE_SME2p1
+#error Foo
+#endif
+#ifndef __ARM_FEATURE_SME2p2
+#error Foo
+#endif
+
 #pragma GCC target "+nothing+sve2+sme-mop4"
 #ifndef __ARM_FEATURE_SME_MOP4
 #error "__ARM_FEATURE_SME_MOP4 not defined"
-- 
2.43.0

Reply via email to