Selects one of the first two operands based on the value of the third operand 1 2.
The valtype
immediate is optional, so long as the result type (and type of the first two operands) is a numeric type 1.
Otherwise, the valtype
immediate declares the result type 1.
Opcode | Instruction | Immediates | Stack Arity |
---|---|---|---|
0x1B |
select |
none | |
0x1C |
select |
;; The first operand will be the result if the condition is not 0
i32.const 10
;; The second operand will be the result if the condition is 0
i32.const 20
;; The third operand is the condition
i32.const 1
select
;; The first operand will be the result if the condition is not 0
ref.func $func1
;; The second operand will be the result if the condition is 0
ref.func $func2
;; The third operand is the condition
i32.const 1
select funcref
Footnotes
-
Structure, Parametric Instructions - https://www.w3.org/TR/wasm-core-2/syntax/instructions.html#parametric-instructions ↩ ↩2 ↩3
-
Execution, Parametric Instructions, select(t*) - https://www.w3.org/TR/wasm-core-2/exec/instructions.html#exec-select ↩