| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Wrench.Isa.Wasm32.Instruction
Description
The instruction set itself: the Wasm32Isa type, the assembly syntax that
produces it, the field guards every immediate has to pass, and the size each
instruction occupies.
Synopsis
- data Wasm32Isa w l
- = I32Const l
- | I32Add
- | I32Sub
- | I32Mul
- | I32DivS
- | I32RemS
- | I32And
- | I32Or
- | I32Xor
- | I32Shl
- | I32ShrS
- | I32ShrU
- | I32Eqz
- | I32Eq
- | I32LtS
- | I32LeS
- | I32GtS
- | I32GeS
- | I32LtU
- | I32LeU
- | I32GtU
- | I32GeU
- | I32Load l
- | I32Load8U l
- | I32Load8S l
- | I32Store l
- | I32Store8 l
- | Block
- | Loop
- | If
- | Else
- | End
- | Br l
- | BrIf l
- | Unreachable
- | Call {
- callParamCount :: l
- callResultCount :: l
- | Return
- | LocalGet l
- | LocalSet l
- | LocalTee l
- | LocalsReserve l
- | Drop
- | Select
- | SpInit
- | Halt
- wasm32Mnemonics :: [Text]
Documentation
One instruction. Each entry starts with its syntax and stack effect.
Constructors
| I32Const l | i32.const <value: i32> ( -- value: i32 ) Push an immediate: a number or a label, which is how a function address is produced (see Functions and locals). |
| I32Add | i32.add ( a: i32, b: i32 -- sum: i32 ) |
| I32Sub | i32.sub ( a: i32, b: i32 -- difference: i32 )
|
| I32Mul | i32.mul ( a: i32, b: i32 -- product: i32 ) Keeps the low 32 bits of the product. |
| I32DivS | i32.div_s ( a: i32, b: i32 -- quotient: i32 ) Signed division truncating toward zero: |
| I32RemS | i32.rem_s ( a: i32, b: i32 -- remainder: i32 ) Signed remainder with the sign of |
| I32And | i32.and ( a: i32, b: i32 -- bits: i32 ) |
| I32Or | i32.or ( a: i32, b: i32 -- bits: i32 ) |
| I32Xor | i32.xor ( a: i32, b: i32 -- bits: i32 ) |
| I32Shl | i32.shl ( value: i32, amount: i32 -- shifted: i32 ) Shift left. The amount is taken modulo 32, as for every shift. |
| I32ShrS | i32.shr_s ( value: i32, amount: i32 -- shifted: i32 ) Arithmetic (sign-extending) shift right. |
| I32ShrU | i32.shr_u ( value: i32, amount: i32 -- shifted: i32 ) Logical (zero-filling) shift right. |
| I32Eqz | i32.eqz ( value: i32 -- flag: i32 ) Push |
| I32Eq | i32.eq ( a: i32, b: i32 -- flag: i32 ) Push |
| I32LtS | i32.lt_s ( a: i32, b: i32 -- flag: i32 ) Signed |
| I32LeS | i32.le_s ( a: i32, b: i32 -- flag: i32 ) Signed |
| I32GtS | i32.gt_s ( a: i32, b: i32 -- flag: i32 ) Signed |
| I32GeS | i32.ge_s ( a: i32, b: i32 -- flag: i32 ) Signed |
| I32LtU | i32.lt_u ( a: i32, b: i32 -- flag: i32 ) Unsigned |
| I32LeU | i32.le_u ( a: i32, b: i32 -- flag: i32 ) Unsigned |
| I32GtU | i32.gt_u ( a: i32, b: i32 -- flag: i32 ) Unsigned |
| I32GeU | i32.ge_u ( a: i32, b: i32 -- flag: i32 ) Unsigned |
| I32Load l | i32.load <offset: u8> ( address: i32 -- value: i32 ) Push the word at i32.const point i32.load 4 ; point.y |
| I32Load8U l | i32.load8_u <offset: u8> ( address: i32 -- value: i32 ) Like |
| I32Load8S l | i32.load8_s <offset: u8> ( address: i32 -- value: i32 ) Like |
| I32Store l | i32.store <offset: u8> ( address: i32, value: i32 -- ) Write the word at |
| I32Store8 l | i32.store8 <offset: u8> ( address: i32, value: i32 -- ) Like |
| Block | block ( -- ) Open a scope; a branch to it continues after its |
| Loop | loop ( -- ) Open a scope; a branch to it continues at the start of its body. Without a branch the body runs once. |
| If | if ( condition: i32 -- ) Run the following body if the condition is non-zero, otherwise
continue after the matching |
| Else | else ( -- ) Reached at the end of a taken |
| End | end ( -- ) Close the |
| Br l | br <depth: u8> ( -- ) Branch to the scope |
| BrIf l | br_if <depth: u8> ( condition: i32 -- )
|
| Unreachable | unreachable ( -- ) Stop with an error. |
| Call | call <paramCount: u8>, <resultCount: u8> ( ...params: i32, target: i32 -- ...results: i32 ) Call the function at |
Fields
| |
| Return | return ( ...results: i32 -- ) Leave the current function, closing every scope it still has open
and passing the call's |
| LocalGet l | local.get <index: u8> ( -- value: i32 ) |
| LocalSet l | local.set <index: u8> ( value: i32 -- ) |
| LocalTee l | local.tee <index: u8> ( value: i32 -- value: i32 ) Like |
| LocalsReserve l | locals.reserve <count: u8> ( -- ) Add |
| Drop | drop ( value: i32 -- ) Discard the top value, e.g. a result the caller does not need. |
| Select | select ( a: i32, b: i32, condition: i32 -- chosen: i32 ) Push |
| SpInit | sp.init ( address: i32 -- ) Move |
| Halt | halt ( -- ) Stop the machine. |
Instances
| Functor (Wasm32Isa w) Source # | |
| IsWord w => DerefMnemonic (Wasm32Isa w) w Source # | |
Defined in Wrench.Isa.Wasm32.Instruction | |
| IsWord w => Machine (Wasm32St w) (Wasm32Isa w w) w Source # | |
| Show l => Show (Wasm32Isa w l) Source # | |
| Eq l => Eq (Wasm32Isa w l) Source # | |
| ByteSize (Wasm32Isa w l) Source # | |
| CommentStart (Wasm32Isa w l) Source # | |
Defined in Wrench.Isa.Wasm32.Instruction Methods | |
| IsWord w => MnemonicParser (Wasm32Isa w (Ref w)) Source # | |
wasm32Mnemonics :: [Text] Source #
Every mnemonic the MnemonicParser instance accepts.