|
24 | 24 | /* |
25 | 25 | * Keccak-f1600 |
26 | 26 | * |
27 | | - * - On Arm-based Apple CPUs, we pick a pure Neon implementation. |
| 27 | + * - On Arm-based Apple CPUs, or if MLK_SYS_AARCH64_FAST_SHA3 is set, |
| 28 | + * we pick a pure Neon implementation. |
28 | 29 | * - Otherwise, unless MLK_SYS_AARCH64_SLOW_BARREL_SHIFTER is set, |
29 | 30 | * we use lazy-rotation scalar assembly from @[HYBRID]. |
30 | 31 | * - Otherwise, if MLK_SYS_AARCH64_SLOW_BARREL_SHIFTER is set, we |
31 | 32 | * fall back to the standard C implementation. |
32 | 33 | */ |
33 | | -#if defined(__ARM_FEATURE_SHA3) && defined(__APPLE__) |
| 34 | +#if defined(__ARM_FEATURE_SHA3) && \ |
| 35 | + (defined(__APPLE__) || defined(MLK_SYS_AARCH64_FAST_SHA3)) |
34 | 36 | #include "x1_v84a.h" |
35 | 37 | #elif !defined(MLK_SYS_AARCH64_SLOW_BARREL_SHIFTER) |
36 | 38 | #include "x1_scalar.h" |
|
42 | 44 | * The optimal implementation is highly CPU-specific; see @[HYBRID]. |
43 | 45 | * |
44 | 46 | * For now, if v8.4-A is not implemented, we fall back to Keccak-f1600. |
45 | | - * If v8.4-A is implemented and we are on an Apple CPU, we use a plain |
46 | | - * Neon-based implementation. |
47 | | - * If v8.4-A is implemented and we are not on an Apple CPU, we use a |
48 | | - * scalar/Neon/Neon hybrid. |
49 | | - * The reason for this distinction is that Apple CPUs appear to implement |
50 | | - * the SHA3 instructions on all SIMD units, while Arm CPUs prior to Cortex-X4 |
51 | | - * don't, and ordinary Neon instructions are still needed. |
| 47 | + * If v8.4-A is implemented and we are on an Apple CPU or |
| 48 | + * MLK_SYS_AARCH64_FAST_SHA3 is set, we use a plain Neon-based |
| 49 | + * implementation. |
| 50 | + * Otherwise, if v8.4-A is implemented, we use a scalar/Neon/Neon hybrid. |
| 51 | + * The reason for this distinction is that Apple CPUs (and CPUs flagged with |
| 52 | + * MLK_SYS_AARCH64_FAST_SHA3) implement the SHA3 instructions on all SIMD |
| 53 | + * units, while Arm CPUs prior to Cortex-X4 don't, and ordinary Neon |
| 54 | + * instructions are still needed. |
52 | 55 | */ |
53 | 56 | #if defined(__ARM_FEATURE_SHA3) |
54 | 57 | /* |
55 | | - * For Apple-M cores, we use a plain implementation leveraging SHA3 |
56 | | - * instructions only. |
| 58 | + * For Apple-M cores (and CPUs flagged with MLK_SYS_AARCH64_FAST_SHA3), we |
| 59 | + * use a plain implementation leveraging SHA3 instructions only. |
57 | 60 | */ |
58 | | -#if defined(__APPLE__) |
| 61 | +#if defined(__APPLE__) || defined(MLK_SYS_AARCH64_FAST_SHA3) |
59 | 62 | #include "x2_v84a.h" |
60 | 63 | #else |
61 | 64 | #include "x4_v8a_v84a_scalar.h" |
|
0 commit comments