Skip to content

Commit

Permalink
lib: make lists of CPU feature bits easier to read
Browse files Browse the repository at this point in the history
  • Loading branch information
ebiggers committed Mar 2, 2024
1 parent 609d982 commit 82ff676
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions lib/arm/cpu_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 (1U << 0)
#define ARM_CPU_FEATURE_PMULL (1U << 1)
#define ARM_CPU_FEATURE_CRC32 (1U << 2)
#define ARM_CPU_FEATURE_SHA3 (1U << 3)
#define ARM_CPU_FEATURE_DOTPROD (1U << 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))
Expand All @@ -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);
Expand Down
26 changes: 13 additions & 13 deletions lib/x86/cpu_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 (1U << 0)
#define X86_CPU_FEATURE_PCLMULQDQ (1U << 1)
#define X86_CPU_FEATURE_AVX (1U << 2)
#define X86_CPU_FEATURE_AVX2 (1U << 3)
#define X86_CPU_FEATURE_BMI2 (1U << 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 (1U << 5)
#define X86_CPU_FEATURE_AVX512F (1U << 6)
#define X86_CPU_FEATURE_AVX512BW (1U << 7)
#define X86_CPU_FEATURE_AVX512VL (1U << 8)
#define X86_CPU_FEATURE_VPCLMULQDQ (1U << 9)
#define X86_CPU_FEATURE_AVX512VNNI (1U << 10)
#define X86_CPU_FEATURE_AVXVNNI (1U << 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);
Expand Down

0 comments on commit 82ff676

Please sign in to comment.