Skip to content

Commit

Permalink
arm crc32: define SIMDE_ARCH_ARM_CRC32 and consistently use it
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Sep 13, 2024
1 parent 99ac62b commit a891834
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
21 changes: 13 additions & 8 deletions simde/arm/neon/crc32.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

#include "types.h"

#if defined(__ARM_ACLE) || (defined(__GNUC__) && defined(SIMDE_ARCH_ARM_CRC32))
#include <arm_acle.h>
#endif
// ^^ Due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70974

HEDLEY_DIAGNOSTIC_PUSH
SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
SIMDE_BEGIN_DECLS_
Expand All @@ -55,7 +60,7 @@ uint32_t simde_crc32_eor_mask(uint32_t a, uint32_t b, uint32_t mask) {
SIMDE_FUNCTION_ATTRIBUTES
uint32_t
simde___crc32b(uint32_t a, uint8_t b) {
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(__ARM_ACLE)
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32b(a, b);
#else
uint32_t r_acc = HEDLEY_STATIC_CAST(uint32_t, simde_crc32_reverseBits(a, 32));
Expand All @@ -81,7 +86,7 @@ simde___crc32b(uint32_t a, uint8_t b) {
SIMDE_FUNCTION_ATTRIBUTES
uint32_t
simde___crc32h(uint32_t a, uint16_t b) {
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(__ARM_ACLE)
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32h(a, b);
#else
uint32_t r_acc = HEDLEY_STATIC_CAST(uint32_t, simde_crc32_reverseBits(a, 32));
Expand All @@ -107,7 +112,7 @@ simde___crc32h(uint32_t a, uint16_t b) {
SIMDE_FUNCTION_ATTRIBUTES
uint32_t
simde___crc32w(uint32_t a, uint32_t b) {
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(__ARM_ACLE)
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32w(a, b);
#else
uint32_t r_acc = HEDLEY_STATIC_CAST(uint32_t, simde_crc32_reverseBits(a, 32));
Expand All @@ -132,7 +137,7 @@ simde___crc32w(uint32_t a, uint32_t b) {
SIMDE_FUNCTION_ATTRIBUTES
uint32_t
simde___crc32d(uint32_t a, uint64_t b) {
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(__ARM_ACLE)
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32d(a, b);
#else
uint32_t r_acc = HEDLEY_STATIC_CAST(uint32_t, simde_crc32_reverseBits(a, 32));
Expand Down Expand Up @@ -167,7 +172,7 @@ simde___crc32d(uint32_t a, uint64_t b) {
SIMDE_FUNCTION_ATTRIBUTES
uint32_t
simde___crc32cb(uint32_t a, uint8_t b) {
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(__ARM_ACLE)
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32cb(a, b);
#else
uint32_t r_acc = HEDLEY_STATIC_CAST(uint32_t, simde_crc32_reverseBits(a, 32));
Expand All @@ -193,7 +198,7 @@ simde___crc32cb(uint32_t a, uint8_t b) {
SIMDE_FUNCTION_ATTRIBUTES
uint32_t
simde___crc32ch(uint32_t a, uint16_t b) {
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(__ARM_ACLE)
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32ch(a, b);
#else
uint32_t r_acc = HEDLEY_STATIC_CAST(uint32_t, simde_crc32_reverseBits(a, 32));
Expand All @@ -219,7 +224,7 @@ simde___crc32ch(uint32_t a, uint16_t b) {
SIMDE_FUNCTION_ATTRIBUTES
uint32_t
simde___crc32cw(uint32_t a, uint32_t b) {
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(__ARM_ACLE)
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32cw(a, b);
#else
uint32_t r_acc = HEDLEY_STATIC_CAST(uint32_t, simde_crc32_reverseBits(a, 32));
Expand All @@ -244,7 +249,7 @@ simde___crc32cw(uint32_t a, uint32_t b) {
SIMDE_FUNCTION_ATTRIBUTES
uint32_t
simde___crc32cd(uint32_t a, uint64_t b) {
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(__ARM_ACLE)
#if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32cd(a, b);
#else
uint32_t r_acc = HEDLEY_STATIC_CAST(uint32_t, simde_crc32_reverseBits(a, 32));
Expand Down
3 changes: 3 additions & 0 deletions simde/simde-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
#if defined(__ARM_FEATURE_CRYPTO) && __ARM_FEATURE_CRYPTO
# define SIMDE_ARCH_ARM_CRYPTO
#endif
#if defined(__ARM_FEATURE_CRC32) && __ARM_FEATURE_CRC32
# define SIMDE_ARCH_ARM_CRC32
#endif
#if defined(__ARM_FEATURE_DOTPROD) && __ARM_FEATURE_DOTPROD
# define SIMDE_ARCH_ARM_DOTPROD
#endif
Expand Down
11 changes: 6 additions & 5 deletions simde/x86/sse4.2.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@

#include "sse4.1.h"

#if defined(__ARM_ACLE) || (defined(__GNUC__) && defined(__ARM_FEATURE_CRC32))
#if defined(__ARM_ACLE) || (defined(__GNUC__) && defined(SIMDE_ARCH_ARM_CRC32))
#include <arm_acle.h>
#endif
// ^^ Due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70974

HEDLEY_DIAGNOSTIC_PUSH
SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
Expand Down Expand Up @@ -295,7 +296,7 @@ simde_mm_crc32_u8(uint32_t prevcrc, uint8_t v) {
#if defined(SIMDE_X86_SSE4_2_NATIVE)
return _mm_crc32_u8(prevcrc, v);
#else
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_CRC32)
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32cb(prevcrc, v);
#else
uint32_t crc = prevcrc;
Expand Down Expand Up @@ -328,7 +329,7 @@ simde_mm_crc32_u16(uint32_t prevcrc, uint16_t v) {
#if defined(SIMDE_X86_SSE4_2_NATIVE)
return _mm_crc32_u16(prevcrc, v);
#else
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_CRC32)
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32ch(prevcrc, v);
#else
uint32_t crc = prevcrc;
Expand All @@ -348,7 +349,7 @@ simde_mm_crc32_u32(uint32_t prevcrc, uint32_t v) {
#if defined(SIMDE_X86_SSE4_2_NATIVE)
return _mm_crc32_u32(prevcrc, v);
#else
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_CRC32)
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32cw(prevcrc, v);
#else
uint32_t crc = prevcrc;
Expand All @@ -368,7 +369,7 @@ simde_mm_crc32_u64(uint64_t prevcrc, uint64_t v) {
#if defined(SIMDE_X86_SSE4_2_NATIVE) && defined(SIMDE_ARCH_AMD64)
return _mm_crc32_u64(prevcrc, v);
#else
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_CRC32)
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(SIMDE_ARCH_ARM_CRC32)
return __crc32cd(HEDLEY_STATIC_CAST(uint32_t, prevcrc), v);
#else
uint64_t crc = prevcrc;
Expand Down

0 comments on commit a891834

Please sign in to comment.