Refactor SIMD architecture for agnostic dispatch and cleanup#129
Merged
Conversation
Split every SIMD-accelerated family into an architecture-neutral dispatch
facade (Clp<Family>Simd) over a per-arch backend (Clp<Family>X86Backend),
so algorithm/mode units no longer carry {$IFDEF CRYPTOLIB_X86_SIMD} gating,
inline asm, or direct TCpuFeatures/TIntrinsicsVector probes. Off-SIMD builds
fall through to the existing scalar reference paths unchanged.
Families routed through a facade: AES engine, ChaCha, Salsa20, Poly1305,
GHASH/GF(2^128), GCM-SIV POLYVAL, binary-polynomial multiply, and the fused
AES AEAD resolver.
Made the six AEAD mode units architecture-agnostic (GCM, CCM, EAX, OCB,
GCM-SIV, GcmUtilities): removed all x86 guards and lifted the GCM inline asm
(block XOR, byte-reverse, fused shuffled-GHASH, the PSHUFB mask) out of
ClpGcmBlockCipher into ClpGhashX86Backend behind the TGhashSimd facade.
The fused-kernel registry and IFused*Kernel interfaces are arch-neutral and
return nil off-SIMD, so no compile-time gating remains in the mode layer.
Naming/clarity:
- ClpAesNiAeadResolver -> ClpAesFusedAeadX86Backend
- TGhashSimd.HasPclmul -> HasCarrylessMultiply (neutral over PCLMULQDQ/PMULL)
- Neutralized PCLMULQDQ wording in resourcestrings
- Introduced shared TPoly1305State record unit (breaks engine<->backend cycle)
- Trimmed comments that rot: "x86 today, arm later" speculation, specific
SSE/AVX version tiers in backend docs, and "off-x86" -> "off-SIMD" in the
arch-neutral units. The SIMD feature-detection layer still names tiers
(its job); x86 backends keep AES-NI/PCLMULQDQ where those identify a kernel.
Behavior is byte-for-byte identical on x86; the moved asm and capability
gates are the same instructions/tiers relocated.
Each Clp<Family>Simd facade carried a {$ELSEIF DEFINED(CRYPTOLIB_ARM_SIMD)}
branch (uses import + one call per method) pointing at ARM backend units that
do not exist yet. The branch is never compiled (CRYPTOLIB_ARM_SIMD is undefined),
so it was a dangling reference to units that aren't there. ARM implementations
are deferred, so drop the reserved slots now; they'll be re-added alongside the
real ARM backends later.
Collapses each dispatch to:
{$IF X86} <x86 call> {$ELSE} Result := False / no-op {$IFEND}
Facades cleaned (8), with the reserved unit/class removed from each:
- ClpAesSimd -> ClpAesEngineArm / TAesEngineArm
- ClpBinPolySimd -> ClpBinPolyArmV128Backend / TBinPolyArmV128Backend
- ClpPoly1305Simd -> ClpPoly1305ArmBackend / TPoly1305ArmBackend
- ClpGhashSimd -> ClpGhashArmBackend / TGhashArmBackend
- ClpGcmSivSimd -> ClpGcmSivArmBackend / TGcmSivArmBackend
- ClpAesFusedAeadSimd -> ClpAesFusedAeadArmBackend / TAesFusedAeadArmBackend
- ClpSalsaSimd -> ClpSalsaArmBackend / TSalsaArmBackend
- ClpChaChaSimd -> ClpChaChaArmBackend / TChaChaArmBackend
No behavior change on any target: only the never-compiled ARM branch is
removed; the x86 path and the scalar fallback are untouched. The ARM
build/detection infrastructure (CRYPTOLIB_ARM_SIMD/FORCE_NEON/FORCE_SVE in
CryptoLib.inc, and ClpArmSimdFeatures/ClpArmHwCapProvider) is intentionally
kept as the foundation for future ARM backends.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.