default NATIVE_SIMD_BIT_WIDTH to 128

This commit is contained in:
jakubtomsu
2026-04-10 16:30:44 +02:00
parent c5fbf2dd9f
commit c55797356f

View File

@@ -17,20 +17,18 @@ RUNTIME_REQUIRE :: false // !ODIN_TILDE
@(private)
__float16 :: f16 when __ODIN_LLVM_F16_SUPPORTED else u16
HAS_HARDWARE_SIMD :: NATIVE_SIMD_BIT_WIDTH != 0
HAS_HARDWARE_SIMD :: false when (ODIN_ARCH == .amd64 || ODIN_ARCH == .i386) && !intrinsics.has_target_feature("sse2") else
false when (ODIN_ARCH == .arm64 || ODIN_ARCH == .arm32) && !intrinsics.has_target_feature("neon") else
false when (ODIN_ARCH == .wasm64p32 || ODIN_ARCH == .wasm32) && !intrinsics.has_target_feature("simd128") else
false when (ODIN_ARCH == .riscv64) && !intrinsics.has_target_feature("v") else
true
// Number of bits in the largest native SIMD register.
// 0 when target doesn't support hardware SIMD.
// Size of a native SIMD register for the current compilation target
NATIVE_SIMD_BIT_WIDTH ::
512 when (ODIN_ARCH == .amd64) && intrinsics.has_target_feature("avx512f") else
256 when (ODIN_ARCH == .amd64) && (intrinsics.has_target_feature("avx2") || intrinsics.has_target_feature("avx")) else
128 when (ODIN_ARCH == .amd64 || ODIN_ARCH == .i386) && intrinsics.has_target_feature("sse") else
// ARM: SVE can be larger, but NEON is always 128
128 when (ODIN_ARCH == .arm64 || ODIN_ARCH == .arm32) && intrinsics.has_target_feature("neon") else
// VLEN can be between 32 and thousands of bits. 128 is a safe bet.
128 when (ODIN_ARCH == .riscv64) && intrinsics.has_target_feature("v") else
128 when (ODIN_ARCH == .wasm64p32 || ODIN_ARCH == .wasm32) && intrinsics.has_target_feature("simd128") else
0
// Fallback for no hardware SIMD, but also SSE, NEON, SVE, RVV and WASM SIMD128.
128
@(private)
byte_slice :: #force_inline proc "contextless" (data: rawptr, len: int) -> []byte #no_bounds_check {