MDN / load: Wasm SIMD load/store instruction
MDN / load: Wasm SIMD load/store instruction
The load SIMD load/store instruction loads all lanes of a v128 value interpretation with values from a given memory address.
(module
(import "console" "log" (func $log (param i32)))
(memory $memory 1)
(data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\00\01\02\03")
(func $main
i32.const 5
v128.load
i32x4.extract_lane 3
call $log
)
(start $main)
)
WebAssembly.instantiateStreaming(fetch("{%wasm-url%}"), { console });
Syntax
;; Common usage
v128.load
;; With optional immediate operands
v128.load mem_idx offset=int align=int
v128.load: The
v128.loadinstruction.
mem_idx: An integer representing the memory index, in cases where the module uses multiple memories. The default is
0.
offset=int: An integer representing a constant number of bytes to add to the memory address before loading. The default is
0.
align=int: An integer representing a hint to the Wasm engine about what alignment to expect for the final address. The minimum value is
1and the default and maximum value is16. Analignvalue has to be a power of2.
Type
[memory_address] -> [output]
memory_address: An integer representing the memory address to load from.
output: The output
v128type.
Binary encoding
InstructionBinary formatExample text => binaryv128.load0xfd 0:u32 mem_idx:u8 offset:u32 align:u32v128.load 0 offset=0 align=16 => 0xfd 0x00 0x04 0x00While Wasm text format specifies the literal align value, the binary equivalent represents the exponent of the formula 2^x used to calculate the alignment. So for example, align=1 is equivalent to 0x00 (2^0), while align=16 is equivalent to 0x04 (2^4).