Skip to content

Latest commit

 

History

History
41 lines (24 loc) · 1.48 KB

splat.md

File metadata and controls

41 lines (24 loc) · 1.48 KB

splat (create vector with identical lanes)

Creates a new vector by repeating the given operand value for each lane and places the new vector on the stack 1

There are 6 opcodes, to indicate the size of the operand and shape of the resulting vector

Opcode Instruction Stack Arity
0xFD 15 i8x16.splat $[ \mathsf{i32} ] \to [ \mathsf{v128} ]$
0xFD 16 i16x8.splat $[ \mathsf{i32} ] \to [ \mathsf{v128} ]$
0xFD 17 i32x4.splat $[ \mathsf{i32} ] \to [ \mathsf{v128} ]$
0xFD 18 i64x2.splat $[ \mathsf{i64} ] \to [ \mathsf{v128} ]$
0xFD 19 f32x4.splat $[ \mathsf{f32} ] \to [ \mathsf{v128} ]$
0xFD 20 f64x2.splat $[ \mathsf{f64} ] \to [ \mathsf{v128} ]$

WAT Examples

Creating a vector be repeating a constant

;; Place a value (10) on the stack to be the repeated operand
i32.const 10

i8x16.splat
;; Resulting vector contains the operand value (10) repeated in
;; each lane, i.e.
;;  [ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 ]

References

Footnotes

  1. WebAssembly Core Specification, Execution, Vector Instructions, shape.splat - https://webassembly.github.io/spec/core/bikeshed/#-hrefsyntax-shapemathitshapemathsfhrefsyntax-instr-vecmathsfsplat%E2%91%A0