Extend System.Runtime.Intrinsics.Arm to support nint and nuint (ArmBase + Crc32)#127327
Extend System.Runtime.Intrinsics.Arm to support nint and nuint (ArmBase + Crc32)#127327
Conversation
|
@copilot please go with option C. But note that in the full task list that the |
… type to var_types Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/244a0b75-c1b0-46b3-b53e-23ed8cf7401a Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
Done in 6f34511 — landed the
|
There was a problem hiding this comment.
Pull request overview
This PR implements the approved System.Runtime.Intrinsics.Arm API expansion to add nint/nuint overloads for a small, scoped subset (ArmBase + Crc32), and refactors the JIT’s GenTreeHWIntrinsic “auxiliary type” tracking from CorInfoType to var_types to better match existing JIT type plumbing.
Changes:
- Added
nint/nuintoverloads toArmBase(LeadingZeroCount,ReverseElementBits) andArmBase.Arm64(LeadingSignCount), plusnuintoverloads toCrc32(ComputeCrc32,ComputeCrc32C). - Refactored
GenTreeHWIntrinsicauxiliary type storage/accessors to usevar_types, updating all impacted JIT call sites and removing now-deadCorInfoTypeSIMD base-type helpers. - Extended the ARM intrinsic test generator inputs to cover the new
ArmBasenint/nuintoverloads with pointer-size-aware validation.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/Common/GenerateHWIntrinsicTests/Arm/BaseTests.cs | Adds generator entries for ArmBase nint/nuint overload coverage. |
| src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs | Updates ref assembly with the new nint/nuint overload signatures. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/ArmBase.cs | Adds nint/nuint overloads to the supported implementation surface. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/ArmBase.PlatformNotSupported.cs | Mirrors new ArmBase overloads for unsupported platforms. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Crc32.cs | Adds nuint overloads to Crc32 supported implementation surface. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Crc32.PlatformNotSupported.cs | Mirrors new Crc32 overloads for unsupported platforms. |
| src/coreclr/jit/gentree.h | Changes auxiliary type storage to var_types (gtAuxiliaryType) and updates accessors. |
| src/coreclr/jit/gentree.cpp | Updates cloning/folding/memory-load logic to use var_types auxiliary type APIs. |
| src/coreclr/jit/hwintrinsic.cpp | Migrates auxiliary type tracking to var_types and updates affected import paths. |
| src/coreclr/jit/hwintrinsicarm64.cpp | Migrates auxiliary type tracking to var_types for Arm64 intrinsics import paths. |
| src/coreclr/jit/hwintrinsicxarch.cpp | Migrates auxiliary type tracking to var_types for xarch intrinsic import paths. |
| src/coreclr/jit/valuenum.cpp | Migrates auxiliary type checks to var_types for ARM64 constant folding/value numbering. |
| src/coreclr/jit/simd.cpp | Removes the CorInfoType-returning SIMD base-type helper (now unused). |
| src/coreclr/jit/compiler.h | Removes declarations for the deleted CorInfoType SIMD base-type helpers. |
… slots for nint/nuint dispatch Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/c2ab4e66-3233-4d8d-b691-668aa5db1675 Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
Implements the approved API proposal to extend
System.Runtime.Intrinsics.Armwithnint/nuintoverloads. Per reviewer guidance, this PR is scoped down to Option C: theArmBase+Crc32managed surface plus theGenTreeHWIntrinsicauxiliary-type refactor. The bulk of the proposal (AdvSimd+AdvSimd.Arm64) is deferred to follow-up PRs.Description
Managed surface (implementation,
PlatformNotSupportedmirror, and ref assembly)ArmBaseLeadingZeroCount(nint),LeadingZeroCount(nuint)ReverseElementBits(nint),ReverseElementBits(nuint)ArmBase.Arm64LeadingSignCount(nint)Crc32ComputeCrc32(uint crc, nuint data)ComputeCrc32C(uint crc, nuint data)No APIs are added beyond the approved proposal. The managed bodies are simple self-call intrinsic stubs; the JIT handles dispatch via the hwintrinsic list (see below).
JIT hwintrinsic list — 64-bit instruction slots for the 32-bit classes
In
src/coreclr/jit/hwintrinsiclistarm64.h, theTYP_LONG/TYP_ULONGslots of the 32-bit-class entries are now populated so thatnint/nuintoverloads (whichJitType2PreciseVarTypemaps toTYP_LONG/TYP_ULONGon 64-bit) dispatch to the correct Arm64 instruction without needing a managed-side redirect to*.Arm64.*:NI_ArmBase_LeadingZeroCount— addedINS_clzforTYP_LONG/TYP_ULONGNI_ArmBase_ReverseElementBits— addedINS_rbitforTYP_LONG/TYP_ULONGNI_Crc32_ComputeCrc32— addedINS_crc32xforTYP_ULONGNI_Crc32_ComputeCrc32C— addedINS_crc32cxforTYP_ULONGCodegen uses
emitActualTypeSize(intrin.baseType)forHW_Category_Scalar, so the 8-byte operand size flows through automatically. On Arm32,nint/nuintis 32-bit and theseTYP_LONG/TYP_ULONGslots are never reached.JIT refactor —
GenTreeHWIntrinsicauxiliary typeSwitched the tracked auxiliary type from
CorInfoTypetovar_types:gtAuxiliaryJitType→gtAuxiliaryType, default changed fromCORINFO_TYPE_UNDEFtoTYP_UNKNOWN.GetAuxiliaryJitType()/SetAuxiliaryJitType(CorInfoType)removed.GetAuxiliaryType()now returns the storedvar_typesdirectly; newSetAuxiliaryType(var_types)added.hwintrinsic.cpp,hwintrinsicarm64.cpp,hwintrinsicxarch.cpp,gentree.cpp, andvaluenum.cpp. SentinelsCORINFO_TYPE_PTR/CORINFO_TYPE_UNDEFare translated at the boundary toTYP_U_IMPL/TYP_UNKNOWN.getBaseJitTypeAndSizeOfSIMDType/getBaseJitTypeOfSIMDTypehelpers are removed fromcompiler.handsimd.cpp; callers use the existingvar_types-returninggetBaseTypeAndSizeOfSIMDType/getBaseTypeOfSIMDType.Tests
New generator inputs added in
src/tests/Common/GenerateHWIntrinsicTests/Arm/BaseTests.csfor thenint/nuintoverloads ofLeadingZeroCount,LeadingSignCount, andReverseElementBits, with bit-size-aware validation logic that is correct on both 32-bit and 64-bit.Generator entries for the
Crc32nuintoverloads are intentionally not added in this PR: their expected CRC output must be platform-conditional and precomputed per architecture, which the currentScalarBinOpTesttemplate doesn't support cleanly. This can be added as a follow-up once a small cross-platform helper is introduced.Scope deferred to follow-up PRs
AdvSimdandAdvSimd.Arm64nint/nuintoverloads (hundreds of methods inAdvSimd.cs/AdvSimd.PlatformNotSupported.cs).AdvSimdoverloads.Crc32nuinttest-generator entries (see note above).Testing
./build.sh clr+libs -rc release— 0 errors, 0 warnings. JIT C++ refactor compiles clean on x64; the managed surface (including the ref assembly) compiles clean../build.sh clr.alljits -c release— cross-compiles all JIT targets includinglibclrjit_universal_arm64_x64.so, exercising the updatedhwintrinsiclistarm64.h. 0 errors, 0 warnings.