Skip to content

Commit

Permalink
lib/arm: remove unnecessary NATIVE macros
Browse files Browse the repository at this point in the history
Since most of the uses of the HAVE_*_NATIVE macros have been removed,
and most of them provide no additional value over the original
compiler-provided macro like __ARM_FEATURE_CRC32 anyway, there's not
much point in having them anymore.  Remove them, except for
HAVE_NEON_NATIVE and which is still worthwhile to have.
  • Loading branch information
ebiggers committed Mar 17, 2024
1 parent 0c0530c commit 6c31ccb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/arm/adler32_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ adler32_arm_neon_dotprod(u32 adler, const u8 *p, size_t len)
#undef ATTRIBUTES
#endif /* NEON+dotprod implementation */

#if defined(adler32_arm_neon_dotprod) && HAVE_DOTPROD_NATIVE
#if defined(adler32_arm_neon_dotprod) && defined(__ARM_FEATURE_DOTPROD)
#define DEFAULT_IMPL adler32_arm_neon_dotprod
#else
static inline adler32_func_t
Expand Down
24 changes: 10 additions & 14 deletions lib/arm/cpu_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@
#define ARM_CPU_FEATURE_SHA3 (1 << 4)
#define ARM_CPU_FEATURE_DOTPROD (1 << 5)

#define HAVE_NEON(features) (HAVE_NEON_NATIVE || ((features) & ARM_CPU_FEATURE_NEON))
#define HAVE_PMULL(features) (HAVE_PMULL_NATIVE || ((features) & ARM_CPU_FEATURE_PMULL))
#define HAVE_CRC32(features) (HAVE_CRC32_NATIVE || ((features) & ARM_CPU_FEATURE_CRC32))
#define HAVE_SHA3(features) (HAVE_SHA3_NATIVE || ((features) & ARM_CPU_FEATURE_SHA3))
#define HAVE_DOTPROD(features) (HAVE_DOTPROD_NATIVE || ((features) & ARM_CPU_FEATURE_DOTPROD))

#if HAVE_DYNAMIC_ARM_CPU_FEATURES
#define ARM_CPU_FEATURES_KNOWN (1U << 31)
extern volatile u32 libdeflate_arm_cpu_features;
Expand All @@ -79,8 +73,10 @@ static inline u32 get_arm_cpu_features(void) { return 0; }

/* NEON */
#if defined(__ARM_NEON) || (defined(_MSC_VER) && defined(ARCH_ARM64))
# define HAVE_NEON(features) 1
# define HAVE_NEON_NATIVE 1
#else
# define HAVE_NEON(features) ((features) & ARM_CPU_FEATURE_NEON)
# define HAVE_NEON_NATIVE 0
#endif
/*
Expand All @@ -98,9 +94,9 @@ static inline u32 get_arm_cpu_features(void) { return 0; }

/* PMULL */
#ifdef __ARM_FEATURE_CRYPTO
# define HAVE_PMULL_NATIVE 1
# define HAVE_PMULL(features) 1
#else
# define HAVE_PMULL_NATIVE 0
# define HAVE_PMULL(features) ((features) & ARM_CPU_FEATURE_PMULL)
#endif
#if defined(ARCH_ARM64) && HAVE_NEON_INTRIN && \
(GCC_PREREQ(6, 1) || defined(__clang__) || defined(_MSC_VER)) && \
Expand All @@ -118,9 +114,9 @@ static inline u32 get_arm_cpu_features(void) { return 0; }

/* CRC32 */
#ifdef __ARM_FEATURE_CRC32
# define HAVE_CRC32_NATIVE 1
# define HAVE_CRC32(features) 1
#else
# define HAVE_CRC32_NATIVE 0
# define HAVE_CRC32(features) ((features) & ARM_CPU_FEATURE_CRC32)
#endif
#if defined(ARCH_ARM64) && \
(defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER))
Expand Down Expand Up @@ -166,9 +162,9 @@ static inline u32 get_arm_cpu_features(void) { return 0; }

/* SHA3 (needed for the eor3 instruction) */
#ifdef __ARM_FEATURE_SHA3
# define HAVE_SHA3_NATIVE 1
# define HAVE_SHA3(features) 1
#else
# define HAVE_SHA3_NATIVE 0
# define HAVE_SHA3(features) ((features) & ARM_CPU_FEATURE_SHA3)
#endif
#if defined(ARCH_ARM64) && HAVE_NEON_INTRIN && \
(GCC_PREREQ(9, 1) /* r268049 */ || \
Expand All @@ -194,9 +190,9 @@ static inline u32 get_arm_cpu_features(void) { return 0; }

/* dotprod */
#ifdef __ARM_FEATURE_DOTPROD
# define HAVE_DOTPROD_NATIVE 1
# define HAVE_DOTPROD(features) 1
#else
# define HAVE_DOTPROD_NATIVE 0
# define HAVE_DOTPROD(features) ((features) & ARM_CPU_FEATURE_DOTPROD)
#endif
#if defined(ARCH_ARM64) && HAVE_NEON_INTRIN && \
(GCC_PREREQ(8, 1) || CLANG_PREREQ(7, 0, 10010000) || defined(_MSC_VER))
Expand Down

0 comments on commit 6c31ccb

Please sign in to comment.