#[non_exhaustive]pub enum Op {
Show 23 variants
Move {
dst: Reg,
src: Reg,
},
LoadConst {
dst: Reg,
index: Const,
},
LoadNil {
dst: Reg,
},
LoadBool {
dst: Reg,
val: bool,
},
LoadInt {
dst: Reg,
val: i32,
},
Add {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Sub {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Mul {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Div {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Rem {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Neg {
dst: Reg,
src: Reg,
},
Eq {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Ne {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Lt {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Le {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Gt {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Ge {
dst: Reg,
lhs: Reg,
rhs: Reg,
},
Not {
dst: Reg,
src: Reg,
},
Jump {
target: Addr,
},
JumpIfTrue {
cond: Reg,
target: Addr,
},
JumpIfFalse {
cond: Reg,
target: Addr,
},
Return {
src: Reg,
},
Halt,
}Expand description
A single decoded instruction.
Instructions divide into data movement (Move, Load*), arithmetic
(Add…Neg), comparison (Eq…Ge), the logical Not, control flow
(Jump, JumpIfTrue, JumpIfFalse), and termination (Return, Halt).
Arithmetic and comparison operands are numeric: an integer combines with an
integer to give an integer (with overflow checked), and any float operand
promotes the result to float. Comparisons and Not produce booleans. See the
individual variants and the crate root for the exact semantics.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Move
Copy the value in src into dst.
LoadConst
Load the constant at pool position index into dst.
LoadNil
Load nil into dst.
LoadBool
Load the boolean val into dst.
LoadInt
Load the 32-bit integer immediate val into dst.
Small integers travel in the instruction itself, avoiding a constant-pool round trip for the common case.
Add
dst = lhs + rhs (numeric; integer add is overflow-checked).
Fields
Sub
dst = lhs - rhs (numeric; integer subtract is overflow-checked).
Fields
Mul
dst = lhs * rhs (numeric; integer multiply is overflow-checked).
Fields
Div
dst = lhs / rhs (numeric; integer divide-by-zero errors, float follows IEEE-754).
Fields
Rem
dst = lhs % rhs (numeric; integer remainder-by-zero errors).
Fields
Neg
dst = -src (numeric; integer negation is overflow-checked).
Eq
dst = (lhs == rhs) as a boolean. Numeric operands compare by value across
int/float; other kinds compare structurally. Floats use IEEE-754 equality.
Fields
Ne
dst = (lhs != rhs) — the boolean negation of Op::Eq.
Fields
Lt
dst = (lhs < rhs) (numeric operands only).
Fields
Le
dst = (lhs <= rhs) (numeric operands only).
Fields
Gt
dst = (lhs > rhs) (numeric operands only).
Fields
Ge
dst = (lhs >= rhs) (numeric operands only).
Fields
Not
dst = !src. src must be a boolean.
Jump
Unconditionally set the program counter to target.
JumpIfTrue
Branch to target when cond holds a true boolean; otherwise fall
through. cond must be a boolean.
Fields
JumpIfFalse
Branch to target when cond holds a false boolean; otherwise fall
through. cond must be a boolean.
Fields
Return
Stop execution and yield the value in src as the run’s result.
Halt
Stop execution and yield nil.
Trait Implementations§
impl Copy for Op
Source§impl<'de> Deserialize<'de> for Op
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Op
serde only.