Add RISC-V scalar fallback support - #318
Conversation
|
@microsoft-github-policy-service agree |
| #define _XM_SSE_INTRINSICS_ | ||
| #elif defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || __arm__ || __aarch64__ | ||
| #define _XM_ARM_NEON_INTRINSICS_ | ||
| #elif defined(__riscv) |
There was a problem hiding this comment.
Why do you need to update the library instead of just defining -D_XM_NO_INTRINSICS_ in your build?
There was a problem hiding this comment.
You're right that defining _XM_NO_INTRINSICS_ is sufficient, so this change is not required to make a RISC-V consumer build.
The narrower rationale for handling __riscv in the header is to give a recognized target a consistent default. DirectXMath is header-only and is often included transitively, so otherwise every consumer build must know about and propagate a DirectXMath-specific macro to every translation unit. Selecting the existing scalar implementation avoids that integration requirement; it does not claim RISC-V intrinsics, RVV optimization, or comprehensive platform validation.
I have narrowed the PR accordingly: it now contains only the target-selection change and a short documentation note. I removed the CMake message and the RISC-V-specific changes to the x86 extension headers.
If the project's policy is that scalar-only targets should explicitly opt in with _XM_NO_INTRINSICS_, then the build define is the appropriate solution and the library change is not strictly necessary.
Why
DirectXMath already has a complete
_XM_NO_INTRINSICS_scalar implementation. RISC-V consumers can opt into it with a build define, but__riscvis otherwise rejected by the header's target-selection logic. This patch makes that existing scalar implementation the conservative default for a recognized RISC-V target, so transitive consumers do not need to propagate a DirectXMath-specific define to every translation unit.This is a default-selection and portability change, not a correctness requirement or a claim of optimized RISC-V support.
What changed
Inc/DirectXMath.hso__riscvselects the existing_XM_NO_INTRINSICS_implementation.Verification
riscv64consumer with thedockcross/linux-riscv64toolchain.fileandreadelf.qemu-riscv64; the smoke test exercised vector construction and addition, matrix scaling and transformation, and collision helpers._XM_NO_INTRINSICS_.Scope
The patch intentionally does not add RVV intrinsics, assembly, a new backend, or RISC-V-specific handling to the x86 extension headers. If the project's policy is that scalar-only targets must explicitly define
_XM_NO_INTRINSICS_, then the existing build define remains sufficient and this default-selection change is not necessary.