https://gcc.gnu.org/g:8653813b1e4377bf01c3b1a45c11b9616f5886fe
commit r17-981-g8653813b1e4377bf01c3b1a45c11b9616f5886fe Author: Artemiy Volkov <[email protected]> Date: Thu Mar 12 12:21:06 2026 +0000 aarch64: add __ARM_FEATURE_ macros for SVE2.2 and SME2.2 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. Diff: --- 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 8da9163bc32b..eb08882af55f 100644 --- a/gcc/config/aarch64/aarch64-c.cc +++ b/gcc/config/aarch64/aarch64-c.cc @@ -232,6 +232,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); @@ -310,6 +311,7 @@ aarch64_update_cpp_builtins (cpp_reader *pfile) aarch64_def_or_undef (TARGET_SME2, "__ARM_FEATURE_SME2", 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); 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 f1f70ed7b5c1..9c96249050d7 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 84713c928293..04e3ae5d6aaa 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 "branch-protection=standard" #ifndef __ARM_FEATURE_BTI_DEFAULT #error Foo
