On Mon, Nov 03, 2025 at 01:45:13PM +0000, Alfie Richards wrote:
> Changes the "sve2-sm4", "sve2-sha3", "sve2-bitperm", and "sve2-aes"
> to be aliases which imply both "sve2" and the new option "sve-sm4",
> "sve-sha3", "sve-bitperm", or "sve-aes" respectively.

If we want to treat "+sve2-bitperm" as equivalent to "+sve2+sve-bitperm", then
we'll need to canonicalise the feature bitmasks to either include or exclude
the SVE2_BITPERM bit to avoid breaking can_inline checks.  I addressed an
equivalent problem for "+crypto" in  r15-7196-gb53781ce1e49fc.

Another possible consideration is that this patch would break handling of
+nosve2-bitperm (with no backwards-compatible alternative available).  If we
wanted to continue supporting that then we'd need to make SVE_BITPERM and
explicit off for this flag, but I don't think this is important.

Alice

> 
> This granularity is needed to model the 2024 Architecture Extensions
> dependencies.
> 
> gcc/ChangeLog:
> 
>       * config/aarch64/aarch64-option-extensions.def
>       (sve-aes): New cli extension option.
>       (sve2-aes): Changed to be alias of sve2+sve-aes2.
>       (sve-bitperm): New cli extension option.
>       (sve2-bitperm): Changed to be alias of sve2+sve-bitperm.
>       (sve-sm4): New cli extension option.
>       (sve2-sm4): Changed to be alias of sve2+sve-sm4.
>       (sve-sm4): New cli extension option.
>       (sve2-sm4): Changed to be alias of sve2+sve-sm4.
>       * config/aarch64/aarch64.h (TARGET_SVE2_AES): Updated to require
>       sve2+sve-aes.
>       (TARGET_SVE2_BITPERM): Updated to require sve2+sve-bitperm.
>       (TARGET_SVE2_SHA3): Updated to require sve2+sve-sha3.
>       (TARGET_SVE2_SM4): Updated to require sve2+sve-sm4
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.target/aarch64/pragma_cpp_predefs_5.c: New test.
> ---
>  .../aarch64/aarch64-option-extensions.def     |  16 +-
>  gcc/config/aarch64/aarch64.h                  |  15 +-
>  .../gcc.target/aarch64/pragma_cpp_predefs_5.c | 221 ++++++++++++++++++
>  gcc/testsuite/lib/target-supports.exp         |   3 +-
>  4 files changed, 246 insertions(+), 9 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_5.c
> 
> diff --git a/gcc/config/aarch64/aarch64-option-extensions.def 
> b/gcc/config/aarch64/aarch64-option-extensions.def
> index a70375c053f..2e03b5b75fc 100644
> --- a/gcc/config/aarch64/aarch64-option-extensions.def
> +++ b/gcc/config/aarch64/aarch64-option-extensions.def
> @@ -188,20 +188,28 @@ AARCH64_FMV_FEATURE("f64mm", SVE_F64MM, (F64MM))
>  
>  AARCH64_OPT_FMV_EXTENSION("sve2", SVE2, (SVE), (), (), "sve2")
>  
> -AARCH64_OPT_EXTENSION("sve2-aes", SVE2_AES, (SVE2, AES), (), (), "sveaes")
> +AARCH64_OPT_EXTENSION("sve-aes", SVE_AES, (AES), (), (), "sveaes")
> +
> +AARCH64_OPT_EXTENSION("sve2-aes", SVE2_AES, (SVE2, SVE_AES), (), (), 
> "sveaes")
>  
>  AARCH64_FMV_FEATURE("sve2-aes", SVE_PMULL128, (SVE2_AES))
>  
> -AARCH64_OPT_EXTENSION("sve2-bitperm", SVE2_BITPERM, (SVE2), (), (),
> +AARCH64_OPT_EXTENSION("sve-bitperm", SVE_BITPERM, (), (), (), "svebitperm")
> +
> +AARCH64_OPT_EXTENSION("sve2-bitperm", SVE2_BITPERM, (SVE2, SVE_BITPERM), (), 
> (),
>                     "svebitperm")
>  
>  AARCH64_FMV_FEATURE("sve2-bitperm", SVE_BITPERM, (SVE2_BITPERM))
>  
> -AARCH64_OPT_EXTENSION("sve2-sha3", SVE2_SHA3, (SVE2, SHA3), (), (), 
> "svesha3")
> +AARCH64_OPT_EXTENSION("sve-sha3", SVE_SHA3, (SHA3), (), (), "svesha3")
> +
> +AARCH64_OPT_EXTENSION("sve2-sha3", SVE2_SHA3, (SVE2, SVE_SHA3), (), (), 
> "svesha3")
>  
>  AARCH64_FMV_FEATURE("sve2-sha3", SVE_SHA3, (SVE2_SHA3))
>  
> -AARCH64_OPT_EXTENSION("sve2-sm4", SVE2_SM4, (SVE2, SM4), (), (), "svesm4")
> +AARCH64_OPT_EXTENSION("sve-sm4", SVE_SM4, (SM4), (), (), "svesm4")
> +
> +AARCH64_OPT_EXTENSION("sve2-sm4", SVE2_SM4, (SVE2, SVE_SM4), (), (), 
> "svesm4")
>  
>  AARCH64_FMV_FEATURE("sve2-sm4", SVE_SM4, (SVE2_SM4))
>  
> diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
> index 2cd929d83f9..47d8fc09925 100644
> --- a/gcc/config/aarch64/aarch64.h
> +++ b/gcc/config/aarch64/aarch64.h
> @@ -291,17 +291,24 @@ constexpr auto AARCH64_FL_DEFAULT_ISA_MODE 
> ATTRIBUTE_UNUSED
>  #define TARGET_SVE2 AARCH64_HAVE_ISA (SVE2)
>  
>  /* SVE2 AES instructions, enabled through +sve2-aes.  */
> -#define TARGET_SVE2_AES (AARCH64_HAVE_ISA (SVE2_AES) && TARGET_NON_STREAMING)
> +#define TARGET_SVE2_AES (AARCH64_HAVE_ISA (SVE2) \
> +                      && AARCH64_HAVE_ISA (SVE_AES) \
> +                      && TARGET_NON_STREAMING)
>  
>  /* SVE2 BITPERM instructions, enabled through +sve2-bitperm.  */
> -#define TARGET_SVE2_BITPERM (AARCH64_HAVE_ISA (SVE2_BITPERM) \
> +#define TARGET_SVE2_BITPERM (AARCH64_HAVE_ISA (SVE2) \
> +                          && AARCH64_HAVE_ISA (SVE_BITPERM) \
>                            && TARGET_NON_STREAMING)
>  
>  /* SVE2 SHA3 instructions, enabled through +sve2-sha3.  */
> -#define TARGET_SVE2_SHA3 (AARCH64_HAVE_ISA (SVE2_SHA3) && 
> TARGET_NON_STREAMING)
> +#define TARGET_SVE2_SHA3 (AARCH64_HAVE_ISA (SVE2) \
> +                       && AARCH64_HAVE_ISA (SVE_SHA3) \
> +                       && TARGET_NON_STREAMING)
>  
>  /* SVE2 SM4 instructions, enabled through +sve2-sm4.  */
> -#define TARGET_SVE2_SM4 (AARCH64_HAVE_ISA (SVE2_SM4) && TARGET_NON_STREAMING)
> +#define TARGET_SVE2_SM4 (AARCH64_HAVE_ISA (SVE2) \
> +                      && AARCH64_HAVE_ISA (SVE_SM4) \
> +                      && TARGET_NON_STREAMING)
>  
>  /* SVE2p1 instructions, enabled through +sve2p1.  */
>  #define TARGET_SVE2p1 AARCH64_HAVE_ISA (SVE2p1)
> diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_5.c 
> b/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_5.c
> new file mode 100644
> index 00000000000..b15d1c95398
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_5.c
> @@ -0,0 +1,221 @@
> +/* { dg-do assemble { target { { aarch64_asm_sve-sm4_ok && 
> aarch64_asm_sve-sha3_ok } && { aarch64_asm_sve-aes_ok && 
> aarch64_asm_sve-bitperm_ok } } } } */
> +/* { dg-do compile { target { ! { { aarch64_asm_sve-sm4_ok && 
> aarch64_asm_sve-sha3_ok } && { aarch64_asm_sve-aes_ok && 
> aarch64_asm_sve-bitperm_ok } } } } } */
> +/* { dg-options "-O2" } */
> +
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a")
> +
> +#ifdef __ARM_FEATURE_SVE
> +#error "__ARM_FEATURE_SVE is defined but should not be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_SVE2
> +#error "__ARM_FEATURE_SVE2 is defined but should not be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_AES
> +#error "__ARM_FEATURE_AES is defined but should not 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_SM4
> +#error "__ARM_FEATURE_SM4 is defined but should not be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_SVE2_SM4
> +#error "__ARM_FEATURE_SVE2_SM4 is defined but should not be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_SHA3
> +#error "__ARM_FEATURE_SHA3 is defined but should not be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_SVE2_SHA3
> +#error "__ARM_FEATURE_SVE2_SHA3 is defined but should not be!"
> +#endif
> +
> +#pragma GCC pop_options
> +
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a+sve-bitperm")
> +
> +#ifdef __ARM_FEATURE_SVE
> +#error "__ARM_FEATURE_SVE is defined but should not be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_SVE2
> +#error "__ARM_FEATURE_SVE2 is defined but should not be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_SVE2_BitPerm
> +#error "__ARM_FEATURE_SVE2_BitPerm is defined but should not be!"
> +#endif
> +
> +#pragma GCC pop_options
> +
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a+sve2-bitperm")
> +
> +#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_BITPERM
> +#error "__ARM_FEATURE_SVE2_BITPERM is not defined but should be!"
> +#endif
> +
> +#pragma GCC pop_options
> +
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a+sve2+sve-bitperm")
> +
> +#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_BITPERM
> +#error "__ARM_FEATURE_SVE2_BITPERMis not defined but should be!"
> +#endif
> +
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a+sve-sha3")
> +
> +#ifdef __ARM_FEATURE_SVE
> +#error "__ARM_FEATURE_SVE is defined but should not be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_SVE2
> +#error "__ARM_FEATURE_SVE2 is defined but should not be!"
> +#endif
> +
> +#ifndef __ARM_FEATURE_SHA3
> +#error "__ARM_FEATURE_SHA3 is not defined but should be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_SVE2_SHA3
> +#error "__ARM_FEATURE_SVE2_SHA3 is defined but should not be!"
> +#endif
> +
> +#pragma GCC pop_options
> +
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a+sve2-sha3")
> +
> +#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_SHA3
> +#error "__ARM_FEATURE_SHA3 is not defined but should be!"
> +#endif
> +
> +#ifndef __ARM_FEATURE_SVE2_SHA3
> +#error "__ARM_FEATURE_SVE2_SHA3 is not defined but should be!"
> +#endif
> +
> +#pragma GCC pop_options
> +
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a+sve2+sve-sha3")
> +
> +#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_SHA3
> +#error "__ARM_FEATURE_SHA3 is not defined but should be!"
> +#endif
> +
> +#ifndef __ARM_FEATURE_SVE2_SHA3
> +#error "__ARM_FEATURE_SVE2_SHA3 is not defined but should be!"
> +#endif
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a+sve-aes")
> +
> +#ifdef __ARM_FEATURE_SVE
> +#error "__ARM_FEATURE_SVE is defined but should not be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_SVE2
> +#error "__ARM_FEATURE_SVE2 is defined but should not be!"
> +#endif
> +
> +#ifndef __ARM_FEATURE_AES
> +#error "__ARM_FEATURE_AES is not defined but should be!"
> +#endif
> +
> +#ifdef __ARM_FEATURE_SVE2_AES
> +#error "__ARM_FEATURE_SVE2_AES is defined but should not be!"
> +#endif
> +
> +#pragma GCC pop_options
> +
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a+sve2-aes")
> +
> +#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_AES
> +#error "__ARM_FEATURE_AES is not defined but should be!"
> +#endif
> +
> +#ifndef __ARM_FEATURE_SVE2_AES
> +#error "__ARM_FEATURE_SVE2_AES is not defined but should be!"
> +#endif
> +
> +#pragma GCC pop_options
> +
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a+sve2+sve-aes")
> +
> +#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_AES
> +#error "__ARM_FEATURE_AES is not defined but should be!"
> +#endif
> +
> +#ifndef __ARM_FEATURE_SVE2_AES
> +#error "__ARM_FEATURE_SVE2_AES is not defined but should be!"
> +#endif
> +#pragma GCC pop_options
> +
> +int
> +foo (int a)
> +{
> +  return a;
> +}
> diff --git a/gcc/testsuite/lib/target-supports.exp 
> b/gcc/testsuite/lib/target-supports.exp
> index f90cd26e6e6..9c2d71137a0 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -12536,7 +12536,8 @@ proc 
> check_effective_target_aarch64_gas_has_build_attributes { } {
>  set exts {
>      "bf16" "cmpbr" "crc" "crypto" "dotprod" "f32mm" "f64mm" "faminmax"
>      "fp" "fp8" "fp8dot2" "fp8dot4" "fp8fma" "i8mm" "ls64" "lse" "lut"
> -    "sb" "simd" "sve-b16b16" "sve" "sve2"
> +    "sb" "simd" "sve-b16b16" "sve" "sve2" "sve-sm4" "sve-aes" "sve-bitperm"
> +    "sve-sha3"
>  }
>  
>  # We don't support SME without SVE2, so we'll use armv9 as the base
> -- 
> 2.34.1
> 

Reply via email to