The splat SIMD conversion instruction copies the same value to all lanes of a v128 value interpretation.
(module
(import "console" "log" (func $log (param f32)))
(func $main
(local $s v128)
f32.const 16.2
f32x4.splat
local.set $s
local.get $s
f32x4.extract_lane 0
call $log ;; log the result
local.get $s
f32x4.extract_lane 1
call $log ;; log the result
local.get $s
f32x4.extract_lane 2
call $log ;; log the result
local.get $s
f32x4.extract_lane 3
call $log ;; log the result
)
(start $main)
)WebAssembly.instantiateStreaming(fetch("{%wasm-url%}"), { console });value_type.splat
value_typeThe type of value the instruction is being run on. The following v128 value interpretations support splat:
i8x16i16x8i32x4i64x2f32x4f64x2splatThe splat instruction. Must always be included after the value_type and a period (.).
[input, value] -> [output]
inputThe input v128 value interpretation.
valueThe value you want to copy to all lanes of the v128.
outputThe resulting v128 value interpretation after all lanes of the input value have been set to the value.
| Instruction | Binary format | Example text => binary |
|---|---|---|
i8x16.splat | 0xfd 15:u32 | i8x16.splat => 0xfd 0x0f |
i16x8.splat | 0xfd 16:u32 | i16x8.splat => 0xfd 0x10 |
i32x4.splat | 0xfd 17:u32 | i32x4.splat => 0xfd 0x11 |
i64x2.splat | 0xfd 18:u32 | i64x2.splat => 0xfd 0x12 |
f32x4.splat | 0xfd 19:u32 | f32x4.splat => 0xfd 0x13 |
f64x2.splat | 0xfd 20:u32 | f64x2.splat => 0xfd 0x14 |