Wilco Dijkstra <wilco.dijks...@arm.com> writes:
> Cleanup HWCAP defines - rather than including hwcap.h and then repeating it 
> using
> #ifndef, just define the HWCAPs we need exactly as in hwcap.h.
>
> libgcc:
>         * config/aarch64/cpuinfo.c: Cleanup HWCAP defines.

Thanks for doing this.  I agree it's a significant improvement over
the status quo.  It will be a while before we can reasonably require
a glibc that provides asm/hwcap.h.  And even once we do, new hwcaps
will be added on a regular basis, so we can never rely totally on the
installed header file.  And if, as now, glibc needs to extend the
structure, we can't rely on the installed header file having the
most up-to-date definition.

So in practice, if we stuck to the current approach of trying to
include asm/hwcaps.h, we'd always need to maintain a fallback definition,
and would need increasingly complex code to decide whether the installed
header file is new enough.  Having two versions doubles the amount of
testing needed.  It also increases rather than decreases the amount of
code.

OK for trunk from my POV, but please leave 24 hrs for others to object.

Richard

>
> ---
>
> diff --git a/libgcc/config/aarch64/cpuinfo.c b/libgcc/config/aarch64/cpuinfo.c
> index 
> 14877f5d8410a51fe47f94cb1a2ff5399f95c253..a4958a00fb53d77a0c2291337543324951ca20df
>  100644
> --- a/libgcc/config/aarch64/cpuinfo.c
> +++ b/libgcc/config/aarch64/cpuinfo.c
> @@ -37,211 +37,64 @@ typedef struct __ifunc_arg_t {
>  } __ifunc_arg_t;
>  #endif
>  
> -#if __has_include(<asm/hwcap.h>)
> -#include <asm/hwcap.h>
> -
>  /* Architecture features used in Function Multi Versioning.  */
>  struct {
>    unsigned long long features;
>    /* As features grows new fields could be added.  */
>  } __aarch64_cpu_features __attribute__((visibility("hidden"), nocommon));
>  
> -#ifndef _IFUNC_ARG_HWCAP
>  #define _IFUNC_ARG_HWCAP (1ULL << 62)
> -#endif
> -#ifndef AT_HWCAP
>  #define AT_HWCAP 16
> -#endif
> -#ifndef HWCAP_FP
> -#define HWCAP_FP (1 << 0)
> -#endif
> -#ifndef HWCAP_ASIMD
> -#define HWCAP_ASIMD (1 << 1)
> -#endif
> -#ifndef HWCAP_EVTSTRM
> -#define HWCAP_EVTSTRM (1 << 2)
> -#endif
> -#ifndef HWCAP_AES
> -#define HWCAP_AES (1 << 3)
> -#endif
> -#ifndef HWCAP_PMULL
> -#define HWCAP_PMULL (1 << 4)
> -#endif
> -#ifndef HWCAP_SHA1
> -#define HWCAP_SHA1 (1 << 5)
> -#endif
> -#ifndef HWCAP_SHA2
> -#define HWCAP_SHA2 (1 << 6)
> -#endif
> -#ifndef HWCAP_CRC32
> -#define HWCAP_CRC32 (1 << 7)
> -#endif
> -#ifndef HWCAP_ATOMICS
> -#define HWCAP_ATOMICS (1 << 8)
> -#endif
> -#ifndef HWCAP_FPHP
> -#define HWCAP_FPHP (1 << 9)
> -#endif
> -#ifndef HWCAP_ASIMDHP
> -#define HWCAP_ASIMDHP (1 << 10)
> -#endif
> -#ifndef HWCAP_CPUID
> -#define HWCAP_CPUID (1 << 11)
> -#endif
> -#ifndef HWCAP_ASIMDRDM
> -#define HWCAP_ASIMDRDM (1 << 12)
> -#endif
> -#ifndef HWCAP_JSCVT
> -#define HWCAP_JSCVT (1 << 13)
> -#endif
> -#ifndef HWCAP_FCMA
> -#define HWCAP_FCMA (1 << 14)
> -#endif
> -#ifndef HWCAP_LRCPC
> -#define HWCAP_LRCPC (1 << 15)
> -#endif
> -#ifndef HWCAP_DCPOP
> -#define HWCAP_DCPOP (1 << 16)
> -#endif
> -#ifndef HWCAP_SHA3
> -#define HWCAP_SHA3 (1 << 17)
> -#endif
> -#ifndef HWCAP_SM3
> -#define HWCAP_SM3 (1 << 18)
> -#endif
> -#ifndef HWCAP_SM4
> -#define HWCAP_SM4 (1 << 19)
> -#endif
> -#ifndef HWCAP_ASIMDDP
> -#define HWCAP_ASIMDDP (1 << 20)
> -#endif
> -#ifndef HWCAP_SHA512
> -#define HWCAP_SHA512 (1 << 21)
> -#endif
> -#ifndef HWCAP_SVE
> -#define HWCAP_SVE (1 << 22)
> -#endif
> -#ifndef HWCAP_ASIMDFHM
> -#define HWCAP_ASIMDFHM (1 << 23)
> -#endif
> -#ifndef HWCAP_DIT
> -#define HWCAP_DIT (1 << 24)
> -#endif
> -#ifndef HWCAP_ILRCPC
> -#define HWCAP_ILRCPC (1 << 26)
> -#endif
> -#ifndef HWCAP_FLAGM
> -#define HWCAP_FLAGM (1 << 27)
> -#endif
> -#ifndef HWCAP_SSBS
> -#define HWCAP_SSBS (1 << 28)
> -#endif
> -#ifndef HWCAP_SB
> -#define HWCAP_SB (1 << 29)
> -#endif
> -#ifndef HWCAP_PACA
> -#define HWCAP_PACA (1 << 30)
> -#endif
> -#ifndef HWCAP_PACG
> -#define HWCAP_PACG (1UL << 31)
> -#endif
> -
> -#ifndef AT_HWCAP2
>  #define AT_HWCAP2 26
> -#endif
> -#ifndef HWCAP2_DCPODP
> -#define HWCAP2_DCPODP (1 << 0)
> -#endif
> -#ifndef HWCAP2_SVE2
> -#define HWCAP2_SVE2 (1 << 1)
> -#endif
> -#ifndef HWCAP2_SVEAES
> -#define HWCAP2_SVEAES (1 << 2)
> -#endif
> -#ifndef HWCAP2_SVEPMULL
> -#define HWCAP2_SVEPMULL (1 << 3)
> -#endif
> -#ifndef HWCAP2_SVEBITPERM
> -#define HWCAP2_SVEBITPERM (1 << 4)
> -#endif
> -#ifndef HWCAP2_SVESHA3
> -#define HWCAP2_SVESHA3 (1 << 5)
> -#endif
> -#ifndef HWCAP2_SVESM4
> -#define HWCAP2_SVESM4 (1 << 6)
> -#endif
> -#ifndef HWCAP2_FLAGM2
> -#define HWCAP2_FLAGM2 (1 << 7)
> -#endif
> -#ifndef HWCAP2_FRINT
> -#define HWCAP2_FRINT (1 << 8)
> -#endif
> -#ifndef HWCAP2_SVEI8MM
> -#define HWCAP2_SVEI8MM (1 << 9)
> -#endif
> -#ifndef HWCAP2_SVEF32MM
> -#define HWCAP2_SVEF32MM (1 << 10)
> -#endif
> -#ifndef HWCAP2_SVEF64MM
> -#define HWCAP2_SVEF64MM (1 << 11)
> -#endif
> -#ifndef HWCAP2_SVEBF16
> -#define HWCAP2_SVEBF16 (1 << 12)
> -#endif
> -#ifndef HWCAP2_I8MM
> -#define HWCAP2_I8MM (1 << 13)
> -#endif
> -#ifndef HWCAP2_BF16
> -#define HWCAP2_BF16 (1 << 14)
> -#endif
> -#ifndef HWCAP2_DGH
> -#define HWCAP2_DGH (1 << 15)
> -#endif
> -#ifndef HWCAP2_RNG
> -#define HWCAP2_RNG (1 << 16)
> -#endif
> -#ifndef HWCAP2_BTI
> -#define HWCAP2_BTI (1 << 17)
> -#endif
> -#ifndef HWCAP2_MTE
> -#define HWCAP2_MTE (1 << 18)
> -#endif
> -#ifndef HWCAP2_RPRES
> -#define HWCAP2_RPRES (1 << 21)
> -#endif
> -#ifndef HWCAP2_MTE3
> -#define HWCAP2_MTE3 (1 << 22)
> -#endif
> -#ifndef HWCAP2_SME
> -#define HWCAP2_SME (1 << 23)
> -#endif
> -#ifndef HWCAP2_SME_I16I64
> -#define HWCAP2_SME_I16I64 (1 << 24)
> -#endif
> -#ifndef HWCAP2_SME_F64F64
> -#define HWCAP2_SME_F64F64 (1 << 25)
> -#endif
> -#ifndef HWCAP2_WFXT
> -#define HWCAP2_WFXT (1UL << 31)
> -#endif
> -#ifndef HWCAP2_EBF16
> -#define HWCAP2_EBF16 (1UL << 32)
> -#endif
> -#ifndef HWCAP2_SVE_EBF16
> -#define HWCAP2_SVE_EBF16 (1UL << 33)
> -#endif
> -#ifndef HWCAP2_CSSC
> -#define HWCAP2_CSSC (1UL << 34)
> -#endif
> -#ifndef HWCAP2_SME2
> -#define HWCAP2_SME2 (1UL << 37)
> -#endif
> -#ifndef HWCAP2_MOPS
> -#define HWCAP2_MOPS (1UL << 43)
> -#endif
> -#ifndef HWCAP2_LRCPC3
> -#define HWCAP2_LRCPC3        (1UL << 46)
> -#endif
> +
> +#define HWCAP_FP             (1 << 0)
> +#define HWCAP_ASIMD          (1 << 1)
> +#define HWCAP_PMULL          (1 << 4)
> +#define HWCAP_SHA2           (1 << 6)
> +#define HWCAP_CRC32          (1 << 7)
> +#define HWCAP_ATOMICS                (1 << 8)
> +#define HWCAP_FPHP           (1 << 9)
> +#define HWCAP_ASIMDHP                (1 << 10)
> +#define HWCAP_ASIMDRDM               (1 << 12)
> +#define HWCAP_JSCVT          (1 << 13)
> +#define HWCAP_FCMA           (1 << 14)
> +#define HWCAP_LRCPC          (1 << 15)
> +#define HWCAP_DCPOP          (1 << 16)
> +#define HWCAP_SHA3           (1 << 17)
> +#define HWCAP_SM3            (1 << 18)
> +#define HWCAP_SM4            (1 << 19)
> +#define HWCAP_ASIMDDP                (1 << 20)
> +#define HWCAP_SVE            (1 << 22)
> +#define HWCAP_ASIMDFHM               (1 << 23)
> +#define HWCAP_DIT            (1 << 24)
> +#define HWCAP_ILRCPC         (1 << 26)
> +#define HWCAP_FLAGM          (1 << 27)
> +#define HWCAP_SSBS           (1 << 28)
> +#define HWCAP_SB             (1 << 29)
> +
> +#define HWCAP2_DCPODP                (1 << 0)
> +#define HWCAP2_SVE2          (1 << 1)
> +#define HWCAP2_SVEPMULL              (1 << 3)
> +#define HWCAP2_SVEBITPERM    (1 << 4)
> +#define HWCAP2_SVESHA3               (1 << 5)
> +#define HWCAP2_SVESM4                (1 << 6)
> +#define HWCAP2_FLAGM2                (1 << 7)
> +#define HWCAP2_FRINT         (1 << 8)
> +#define HWCAP2_SVEF32MM              (1 << 10)
> +#define HWCAP2_SVEF64MM              (1 << 11)
> +#define HWCAP2_I8MM          (1 << 13)
> +#define HWCAP2_BF16          (1 << 14)
> +#define HWCAP2_RNG           (1 << 16)
> +#define HWCAP2_BTI           (1 << 17)
> +#define HWCAP2_MTE           (1 << 18)
> +#define HWCAP2_SME           (1 << 23)
> +#define HWCAP2_SME_I16I64    (1 << 24)
> +#define HWCAP2_SME_F64F64    (1 << 25)
> +#define HWCAP2_WFXT          (1UL << 31)
> +#define HWCAP2_CSSC          (1UL << 34)
> +#define HWCAP2_SME2          (1UL << 37)
> +#define HWCAP2_MOPS          (1UL << 43)
> +#define HWCAP2_LRCPC3                (1UL << 46)
>  
>  static void
>  __init_cpu_features_constructor (unsigned long hwcap,
> @@ -382,5 +235,4 @@ __init_cpu_features(void)
>  #undef getCPUFeature
>  #undef setCPUFeature
>  }
> -#endif /* __has_include(<asm/hwcap.h>)  */
>  #endif /* __has_include(<sys/auxv.h>)  */

Reply via email to