splat: Wasm SIMD conversion instruction
The splat SIMD conversion instruction copies the same value to all lanes of a v128 value interpretation.
Try it
(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 });
Syntax
value_type.splat
value_type-
The type of value the instruction is being run on. The following
v128value interpretations supportsplat:i8x16i16x8i32x4i64x2f32x4f64x2
splat-
The
splatinstruction. Must always be included after thevalue_typeand a period (.).
Type
[input, value] -> [output]
Binary encoding
| 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 |