From 3aea1f3a4fe5293e2d06e2257581c0e92e9ace81 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Fri, 1 Mar 2024 20:26:34 -0800 Subject: [PATCH] lib: make lists of CPU feature bits easier to read --- lib/arm/cpu_features.h | 12 ++++++------ lib/x86/cpu_features.h | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/arm/cpu_features.h b/lib/arm/cpu_features.h index 4fa6e43a..30920c6b 100644 --- a/lib/arm/cpu_features.h +++ b/lib/arm/cpu_features.h @@ -43,11 +43,11 @@ # define HAVE_DYNAMIC_ARM_CPU_FEATURES 1 #endif -#define ARM_CPU_FEATURE_NEON 0x00000001 -#define ARM_CPU_FEATURE_PMULL 0x00000002 -#define ARM_CPU_FEATURE_CRC32 0x00000004 -#define ARM_CPU_FEATURE_SHA3 0x00000008 -#define ARM_CPU_FEATURE_DOTPROD 0x00000010 +#define ARM_CPU_FEATURE_NEON (1 << 0) +#define ARM_CPU_FEATURE_PMULL (1 << 1) +#define ARM_CPU_FEATURE_CRC32 (1 << 2) +#define ARM_CPU_FEATURE_SHA3 (1 << 3) +#define ARM_CPU_FEATURE_DOTPROD (1 << 4) #define HAVE_NEON(features) (HAVE_NEON_NATIVE || ((features) & ARM_CPU_FEATURE_NEON)) #define HAVE_PMULL(features) (HAVE_PMULL_NATIVE || ((features) & ARM_CPU_FEATURE_PMULL)) @@ -56,7 +56,7 @@ #define HAVE_DOTPROD(features) (HAVE_DOTPROD_NATIVE || ((features) & ARM_CPU_FEATURE_DOTPROD)) #if HAVE_DYNAMIC_ARM_CPU_FEATURES -#define ARM_CPU_FEATURES_KNOWN 0x80000000 +#define ARM_CPU_FEATURES_KNOWN (1U << 31) extern volatile u32 libdeflate_arm_cpu_features; void libdeflate_init_arm_cpu_features(void); diff --git a/lib/x86/cpu_features.h b/lib/x86/cpu_features.h index a8159964..b4c00118 100644 --- a/lib/x86/cpu_features.h +++ b/lib/x86/cpu_features.h @@ -39,27 +39,27 @@ # define HAVE_DYNAMIC_X86_CPU_FEATURES 1 #endif -#define X86_CPU_FEATURE_SSE2 0x00000001 -#define X86_CPU_FEATURE_PCLMULQDQ 0x00000002 -#define X86_CPU_FEATURE_AVX 0x00000004 -#define X86_CPU_FEATURE_AVX2 0x00000008 -#define X86_CPU_FEATURE_BMI2 0x00000010 +#define X86_CPU_FEATURE_SSE2 (1 << 0) +#define X86_CPU_FEATURE_PCLMULQDQ (1 << 1) +#define X86_CPU_FEATURE_AVX (1 << 2) +#define X86_CPU_FEATURE_AVX2 (1 << 3) +#define X86_CPU_FEATURE_BMI2 (1 << 4) /* * ZMM indicates whether 512-bit vectors (zmm registers) should be used. On * some CPUs, to avoid downclocking issues we don't set ZMM even if the CPU * supports it, i.e. even if AVX512F is set. On these CPUs, we may still use * AVX-512 instructions, but only with ymm and xmm registers. */ -#define X86_CPU_FEATURE_ZMM 0x00000020 -#define X86_CPU_FEATURE_AVX512F 0x00000040 -#define X86_CPU_FEATURE_AVX512BW 0x00000080 -#define X86_CPU_FEATURE_AVX512VL 0x00000100 -#define X86_CPU_FEATURE_VPCLMULQDQ 0x00000200 -#define X86_CPU_FEATURE_AVX512VNNI 0x00000400 -#define X86_CPU_FEATURE_AVXVNNI 0x00000800 +#define X86_CPU_FEATURE_ZMM (1 << 5) +#define X86_CPU_FEATURE_AVX512F (1 << 6) +#define X86_CPU_FEATURE_AVX512BW (1 << 7) +#define X86_CPU_FEATURE_AVX512VL (1 << 8) +#define X86_CPU_FEATURE_VPCLMULQDQ (1 << 9) +#define X86_CPU_FEATURE_AVX512VNNI (1 << 10) +#define X86_CPU_FEATURE_AVXVNNI (1 << 11) #if HAVE_DYNAMIC_X86_CPU_FEATURES -#define X86_CPU_FEATURES_KNOWN 0x80000000 +#define X86_CPU_FEATURES_KNOWN (1U << 31) extern volatile u32 libdeflate_x86_cpu_features; void libdeflate_init_x86_cpu_features(void);