Skip to content

Commit 45219f2

Browse files
committed
Rename SIMD_IS_EMULATED to capability-affirmative HAS_HARDWARE_SIMD
1 parent edbd247 commit 45219f2

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

base/runtime/internal.odin

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ RUNTIME_REQUIRE :: false // !ODIN_TILDE
1616
@(private)
1717
__float16 :: f16 when __ODIN_LLVM_F16_SUPPORTED else u16
1818

19-
SIMD_IS_EMULATED :: true when (ODIN_ARCH == .amd64 || ODIN_ARCH == .i386) && !intrinsics.has_target_feature("sse2") else
20-
true when (ODIN_ARCH == .arm64 || ODIN_ARCH == .arm32) && !intrinsics.has_target_feature("neon") else
21-
true when (ODIN_ARCH == .wasm64p32 || ODIN_ARCH == .wasm32) && !intrinsics.has_target_feature("simd128") else
22-
true when (ODIN_ARCH == .riscv64) && !intrinsics.has_target_feature("v") else
23-
false
19+
HAS_HARDWARE_SIMD :: false when (ODIN_ARCH == .amd64 || ODIN_ARCH == .i386) && !intrinsics.has_target_feature("sse2") else
20+
false when (ODIN_ARCH == .arm64 || ODIN_ARCH == .arm32) && !intrinsics.has_target_feature("neon") else
21+
false when (ODIN_ARCH == .wasm64p32 || ODIN_ARCH == .wasm32) && !intrinsics.has_target_feature("simd128") else
22+
false when (ODIN_ARCH == .riscv64) && !intrinsics.has_target_feature("v") else
23+
true
24+
2425

2526
@(private)
2627
byte_slice :: #force_inline proc "contextless" (data: rawptr, len: int) -> []byte #no_bounds_check {
@@ -241,7 +242,7 @@ memory_equal :: proc "contextless" (x, y: rawptr, n: int) -> bool {
241242
m := uint(0)
242243

243244
if n >= 8 {
244-
when !SIMD_IS_EMULATED {
245+
when HAS_HARDWARE_SIMD {
245246
// Avoid using 256-bit SIMD on platforms where its emulation is
246247
// likely to be less than ideal.
247248
when ODIN_ARCH == .amd64 && intrinsics.has_target_feature("avx2") {
@@ -295,7 +296,7 @@ memory_compare :: proc "contextless" (x, y: rawptr, n: int) -> int #no_bounds_ch
295296
i := uint(0)
296297
m := uint(0)
297298

298-
when !SIMD_IS_EMULATED {
299+
when HAS_HARDWARE_SIMD {
299300
when ODIN_ARCH == .amd64 && intrinsics.has_target_feature("avx2") {
300301
m = n / 32 * 32
301302
for /**/; i < m; i += 32 {
@@ -364,7 +365,7 @@ memory_compare_zero :: proc "contextless" (a: rawptr, n: int) -> int #no_bounds_
364365
bytes := ([^]u8)(a)
365366

366367
if n >= 8 {
367-
when !SIMD_IS_EMULATED {
368+
when HAS_HARDWARE_SIMD {
368369
when ODIN_ARCH == .amd64 && intrinsics.has_target_feature("avx2") {
369370
scanner32: #simd[32]u8
370371
m = n / 32 * 32

core/bytes/bytes.odin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ index_byte :: proc "contextless" (s: []byte, c: byte) -> (index: int) #no_bounds
350350
}
351351

352352
c_vec: simd.u8x16 = c
353-
when !simd.IS_EMULATED {
353+
when simd.HAS_HARDWARE_SIMD {
354354
// Note: While this is something that could also logically take
355355
// advantage of AVX512, the various downclocking and power
356356
// consumption related woes make premature to have a dedicated
@@ -485,7 +485,7 @@ last_index_byte :: proc "contextless" (s: []byte, c: byte) -> int #no_bounds_che
485485
}
486486

487487
c_vec: simd.u8x16 = c
488-
when !simd.IS_EMULATED {
488+
when simd.HAS_HARDWARE_SIMD {
489489
// Note: While this is something that could also logically take
490490
// advantage of AVX512, the various downclocking and power
491491
// consumption related woes make premature to have a dedicated

core/crypto/_chacha20/simd128/chacha20_simd128.odin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ when ODIN_ARCH == .arm64 || ODIN_ARCH == .arm32 {
3939

4040
// Some targets lack runtime feature detection, and will flat out refuse
4141
// to load binaries that have unknown instructions. This is distinct from
42-
// `simd.IS_EMULATED` as actually good designs support runtime feature
42+
// `simd.HAS_HARDWARE_SIMD` as actually good designs support runtime feature
4343
// detection and that constant establishes a baseline.
4444
//
4545
// See:

core/simd/simd.odin

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import "base:runtime"
2626
/*
2727
Check if SIMD is software-emulated on a target platform.
2828
29-
This value is `false`, when the compile-time target has the hardware support for
30-
at 128-bit (or wider) SIMD. If the compile-time target lacks the hardware support
31-
for 128-bit SIMD, this value is `true`, and all SIMD operations will likely be
29+
This value is `true`, when the compile-time target has the hardware support for
30+
at least 128-bit (or wider) SIMD. If the compile-time target lacks the hardware support
31+
for 128-bit SIMD, this value is `false`, and all SIMD operations will likely be
3232
emulated.
3333
*/
34-
IS_EMULATED :: runtime.SIMD_IS_EMULATED
34+
HAS_HARDWARE_SIMD :: runtime.HAS_HARDWARE_SIMD
3535

3636
/*
3737
Vector of 16 `u8` lanes (128 bits).

0 commit comments

Comments
 (0)