#[repr(u8)]pub enum Opcode {
Show 72 variants
Ret = 0,
Call = 1,
CallIndirect = 2,
Jump = 3,
BrIf = 4,
BrIfNot = 5,
BrIfXeq32 = 6,
BrIfXneq32 = 7,
BrIfXslt32 = 8,
BrIfXslteq32 = 9,
BrIfXult32 = 10,
BrIfXulteq32 = 11,
BrIfXeq64 = 12,
BrIfXneq64 = 13,
BrIfXslt64 = 14,
BrIfXslteq64 = 15,
BrIfXult64 = 16,
BrIfXulteq64 = 17,
BrTable32 = 18,
Xmov = 19,
Fmov = 20,
Vmov = 21,
Xconst8 = 22,
Xconst16 = 23,
Xconst32 = 24,
Xconst64 = 25,
Xadd32 = 26,
Xadd64 = 27,
Xeq64 = 28,
Xneq64 = 29,
Xslt64 = 30,
Xslteq64 = 31,
Xult64 = 32,
Xulteq64 = 33,
Xeq32 = 34,
Xneq32 = 35,
Xslt32 = 36,
Xslteq32 = 37,
Xult32 = 38,
Xulteq32 = 39,
Load32U = 40,
Load32S = 41,
Load64 = 42,
Load32UOffset8 = 43,
Load32SOffset8 = 44,
Load64Offset8 = 45,
Load32UOffset64 = 46,
Load32SOffset64 = 47,
Load64Offset64 = 48,
Store32 = 49,
Store64 = 50,
Store32SOffset8 = 51,
Store64Offset8 = 52,
Store32SOffset64 = 53,
Store64Offset64 = 54,
PushFrame = 55,
PopFrame = 56,
XPush32 = 57,
XPush32Many = 58,
XPush64 = 59,
XPush64Many = 60,
XPop32 = 61,
XPop32Many = 62,
XPop64 = 63,
XPop64Many = 64,
BitcastIntFromFloat32 = 65,
BitcastIntFromFloat64 = 66,
BitcastFloatFromInt32 = 67,
BitcastFloatFromInt64 = 68,
StackAlloc32 = 69,
StackFree32 = 70,
ExtendedOp = 71,
}Expand description
An opcode without its immediates and operands.
Variants§
Ret = 0
Transfer control the address in the lr register.
Call = 1
Transfer control to the PC at the given offset and set the lr
register to the PC just after this instruction.
CallIndirect = 2
Transfer control to the PC in reg and set lr to the PC just
after this instruction.
Jump = 3
Unconditionally transfer control to the PC at the given offset.
BrIf = 4
Conditionally transfer control to the given PC offset if cond
contains a non-zero value.
BrIfNot = 5
Conditionally transfer control to the given PC offset if cond
contains a zero value.
BrIfXeq32 = 6
Branch if a == b.
BrIfXneq32 = 7
Branch if a != b.
BrIfXslt32 = 8
Branch if signed a < b.
BrIfXslteq32 = 9
Branch if signed a <= b.
BrIfXult32 = 10
Branch if unsigned a < b.
BrIfXulteq32 = 11
Branch if unsigned a <= b.
BrIfXeq64 = 12
Branch if a == b.
BrIfXneq64 = 13
Branch if a != b.
BrIfXslt64 = 14
Branch if signed a < b.
BrIfXslteq64 = 15
Branch if signed a <= b.
BrIfXult64 = 16
Branch if unsigned a < b.
BrIfXulteq64 = 17
Branch if unsigned a <= b.
BrTable32 = 18
Branch to the label indicated by idx.
After this instruction are amt instances of PcRelOffset
and the idx selects which one will be branched to. The value
of idx is clamped to amt - 1 (e.g. the last offset is the
“default” one.
Xmov = 19
Move between x registers.
Fmov = 20
Move between f registers.
Vmov = 21
Move between v registers.
Xconst8 = 22
Set dst = sign_extend(imm8).
Xconst16 = 23
Set dst = sign_extend(imm16).
Xconst32 = 24
Set dst = sign_extend(imm32).
Xconst64 = 25
Set dst = imm64.
Xadd32 = 26
32-bit wrapping addition: low32(dst) = low32(src1) + low32(src2).
The upper 32-bits of dst are unmodified.
Xadd64 = 27
64-bit wrapping addition: dst = src1 + src2.
Xeq64 = 28
64-bit equality.
Xneq64 = 29
64-bit inequality.
Xslt64 = 30
64-bit signed less-than.
Xslteq64 = 31
64-bit signed less-than-equal.
Xult64 = 32
64-bit unsigned less-than.
Xulteq64 = 33
64-bit unsigned less-than-equal.
Xeq32 = 34
32-bit equality.
Xneq32 = 35
32-bit inequality.
Xslt32 = 36
32-bit signed less-than.
Xslteq32 = 37
32-bit signed less-than-equal.
Xult32 = 38
32-bit unsigned less-than.
Xulteq32 = 39
32-bit unsigned less-than-equal.
Load32U = 40
dst = zero_extend(load32(ptr))
Load32S = 41
dst = sign_extend(load32(ptr))
Load64 = 42
dst = load64(ptr)
Load32UOffset8 = 43
dst = zero_extend(load32(ptr + offset8))
Load32SOffset8 = 44
dst = sign_extend(load32(ptr + offset8))
Load64Offset8 = 45
dst = load64(ptr + offset8)
Load32UOffset64 = 46
dst = zero_extend(load32(ptr + offset64))
Load32SOffset64 = 47
dst = sign_extend(load32(ptr + offset64))
Load64Offset64 = 48
dst = load64(ptr + offset64)
Store32 = 49
*ptr = low32(src)
Store64 = 50
*ptr = src
Store32SOffset8 = 51
*(ptr + sign_extend(offset8)) = low32(src)
Store64Offset8 = 52
*(ptr + sign_extend(offset8)) = src
Store32SOffset64 = 53
*(ptr + sign_extend(offset64)) = low32(src)
Store64Offset64 = 54
*(ptr + sign_extend(offset64)) = src
PushFrame = 55
push lr; push fp; fp = sp
PopFrame = 56
sp = fp; pop fp; pop lr
XPush32 = 57
*sp = low32(src); sp = sp.checked_add(4)
XPush32Many = 58
for src in srcs { xpush32 src }
XPush64 = 59
*sp = src; sp = sp.checked_add(8)
XPush64Many = 60
for src in srcs { xpush64 src }
XPop32 = 61
*dst = *sp; sp -= 4
XPop32Many = 62
for dst in dsts.rev() { xpop32 dst }
XPop64 = 63
*dst = *sp; sp -= 8
XPop64Many = 64
for dst in dsts.rev() { xpop64 dst }
BitcastIntFromFloat32 = 65
low32(dst) = bitcast low32(src) as i32
BitcastIntFromFloat64 = 66
dst = bitcast src as i64
BitcastFloatFromInt32 = 67
low32(dst) = bitcast low32(src) as f32
BitcastFloatFromInt64 = 68
dst = bitcast src as f64
StackAlloc32 = 69
sp = sp.checked_sub(amt)
StackFree32 = 70
sp = sp + amt
ExtendedOp = 71
The extended-op opcode. An ExtendedOpcode follows this opcode.
Implementations§
Source§impl Opcode
impl Opcode
Sourcepub fn new(byte: u8) -> Option<Self>
pub fn new(byte: u8) -> Option<Self>
Create a new Opcode from the given byte.
Returns None if byte is not a valid opcode.
Sourcepub unsafe fn unchecked_new(byte: u8) -> Self
pub unsafe fn unchecked_new(byte: u8) -> Self
Like new but does not check whether byte is a valid opcode.
§Safety
It is unsafe to pass a byte that is not a valid opcode.