Conversation
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.
Summary
Splits the monolithic
TCpuFeaturesclass into architecture-specific units (HlpX86SimdFeatures,HlpArmSimdFeatures) with shared SIMD level enums (HlpSimdLevels), and adds foundational ARM SIMD and target OS defines to the include files.Motivation
HlpCpuFeatureswas a single class that mixed x86-specific CPUID detection logic with the public dispatch API. This made it impossible to extend to ARM without further bloating the unit. TheTCpuSimdLevelenum was also x86-specific (SSE2,SSSE3,AVX2) but lived in the shared namespace, leaving no room for ARM SIMD levels.All dispatch units (
HlpBlake2BDispatch,HlpSHA2_256Dispatch, etc.) calledTCpuFeatures.GetActiveLevel()and matched againstTCpuSimdLevel.*— semantically x86 concepts that were presented as architecture-neutral.Changes
New units
HlpSimdLevels— definesTX86SimdLevel(Scalar, SSE2, SSSE3, AVX2) andTArmSimdLevel(Scalar, NEON, SVE, SVE2) as separate enums.HlpX86SimdFeatures—TX86SimdFeaturesclass containing all CPUID/XGETBV inline assembly, hardware probing, build-time override logic, and cached feature flags. Moved fromHlpCpuFeatureswith the addition ofHasAESNI()detection (CPUID leaf 1, ECX bit 25).HlpArmSimdFeatures—TArmSimdFeaturesclass with stub detection methods for NEON, SVE, SVE2, and crypto extensions (AES, SHA1, SHA256, SHA512, SHA3, PMULL). All detection methods currently returnFalse(markedTODO), providing the scaffolding for future ARM SIMD dispatch.Refactored
HlpCpuFeaturesTCpuFeaturesis now a thin facade with two class properties:TCpuFeatures.X86→ returnsTX86SimdFeaturesTCpuFeatures.Arm→ returnsTArmSimdFeaturesAll CPUID logic, class vars, and the
initializationsection have been removed from this unit. Detection now runs in each architecture-specific unit's owninitializationblock.Dispatch unit updates
All 12 dispatch units updated to use the new API:
TCpuFeatures.GetActiveLevel()→TCpuFeatures.X86.GetSimdLevel()TCpuSimdLevel.*→TX86SimdLevel.*TCpuFeatures.HasSHANI()→TCpuFeatures.X86.HasSHANI()TCpuFeatures.HasPCLMULQDQ()→TCpuFeatures.X86.HasPCLMULQDQ()TCpuFeatures.HasVPCLMULQDQ()→TCpuFeatures.X86.HasVPCLMULQDQ()HlpSimdLevelsto each dispatch unit'susesclause.Affected dispatch units: Adler32, CRC, Blake2B, Blake2S, Blake3, SHA1, SHA2-256, SHA2-512, SHA3, XXHash3, Argon2, Scrypt.
Include file additions
HashLib.inc(Delphi):HASHLIB_ARMandHASHLIB_AARCH64CPU architecture defines.HASHLIB_MSWINDOWS,HASHLIB_IOS,HASHLIB_MACOS,HASHLIB_ANDROID,HASHLIB_LINUX.HASHLIB_ARM_SIMDcomposite define (mirrors existingHASHLIB_X86_SIMD).HASHLIB_FORCE_NEON,HASHLIB_FORCE_SVE) with mutual exclusion compile-time check.HashLibFPC.inc(FPC):HASHLIB_ARM/HASHLIB_ARM_ASMandHASHLIB_AARCH64/HASHLIB_AARCH64_ASMdefines.HASHLIB_MSWINDOWS,HASHLIB_ANDROID,HASHLIB_IOS,HASHLIB_MACOS,HASHLIB_BSD,HASHLIB_LINUX,HASHLIB_SOLARIS.