浏览代码

core/simd: Add `IS_EMULTATED` so there is one place to look for potatos

Yawning Angel 1 年之前
父节点
当前提交
7020e9b66a
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      core/simd/simd.odin

+ 7 - 0
core/simd/simd.odin

@@ -3,6 +3,13 @@ package simd
 import "base:builtin"
 import "base:intrinsics"
 
+// IS_EMULATED is true iff the compile-time target lacks hardware support
+// for at least 128-bit SIMD.
+IS_EMULATED :: true when (ODIN_ARCH == .amd64 || ODIN_ARCH == .i386) && !intrinsics.has_target_feature("sse2") else
+	true when (ODIN_ARCH == .arm64 || ODIN_ARCH == .arm32) && !intrinsics.has_target_feature("neon") else
+	true when (ODIN_ARCH == .wasm64p32 || ODIN_ARCH == .wasm32) && !intrinsics.has_target_feature("simd128") else
+	false
+
 // 128-bit vector aliases
 u8x16 :: #simd[16]u8
 i8x16 :: #simd[16]i8