So I am trying to use core::arch::wasm32::i32x4_* functions in order to compile SIMD intrinsics into WebAssembly.
The intrinsic functions I am trying to use are implemented here and documented here. Most of these functions are not stable and so I am using rustc 1.45.0-nightly (2020-05-30). In addition, the compiler required that I opt into these options:
// https://github.com/rust-lang/rust/issues/44839
#![feature(wasm_target_feature)]
// https://github.com/rust-lang/rust/issues/69098
#![feature(target_feature_11)]
I see in mod.rs of wasm32 that the functions I am trying to use are feature gated with #[cfg(any(target_feature = "simd128", dox))]
The function I am implementing, looks like this:
#[cfg(target_arch = "wasm32")]
#[target_feature(enable = "simd128")]
unsafe fn _dot_simd(&self) -> i32 {
// use core::arch::wasm32::*;
core::arch::wasm32::memory_size(3); /*<-- this line works since it is stable */
core::arch::wasm32::i32x4_splat(32); /*<-- this line errors */
42
}
If I understand #[target_feature(enable = "simd128")] correctly, the code above would work since it forces "simd128" feature be enabled regardless of the hardware. I also tried enabling that feature through -C target_feature=+simd128 but that also did not change anything.
The error I am getting is
i32x4_splat(32);
^^^^^^^^^^^ not found in core::arch::wasm32
And the command I run to compile is wasm-pack build which under the hood runs:
cargo build --lib --release --target wasm32-unknown-unknown
Could you help me see what I am missing?