shl: Wasm SIMD bitwise instruction
The shl SIMD bitwise instruction shifts the bits in each lane of a v128 value interpretation to the left by the same specified amount.
Try it
(module
(import "console" "log" (func $log (param i32)))
(func $main
v128.const i32x4 1 2 4 6
i32.const 3
i32x4.shl
i32x4.extract_lane 1
call $log ;; log the result
)
(start $main)
)
WebAssembly.instantiateStreaming(fetch("{%wasm-url%}"), { console });
Syntax
value_type.shl
value_type-
The type of value the instruction is being run on. The following
v128value interpretations supportshl:i8x16i16x8i32x4i64x2
shl-
The
shlinstruction. Must always be included after thevalue_typeand a period (.).
Type
[input, shift_value] -> [output]
input-
The input
v128value interpretation. shift_value-
The value that you want to shift the lanes by.
output-
The output
v128value interpretation.
Binary encoding
| Instruction | Binary format | Example text => binary |
|---|---|---|
i8x16.shl |
0xfd 107:u32 |
i8x16.shl => 0xfd 0x6b |
i16x8.shl |
0xfd 139:u32 |
i16x8.shl => 0xfd 0x8b 0x01 |
i32x4.shl |
0xfd 171:u32 |
i32x4.shl => 0xfd 0xab 0x01 |
i64x2.shl |
0xfd 203:u32 |
i64x2.shl => 0xfd 0xcb 0x01 |