49 lines
1.1 KiB
Rust
49 lines
1.1 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use super::ids::{ConstId, FieldId, FunctionId, TypeId, ValueId};
|
|
|
|
/// Instructions within a basic block.
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
pub enum Instr {
|
|
/// Placeholder for constant loading.
|
|
PushConst(ConstId),
|
|
/// Placeholder for function calls.
|
|
Call(FunctionId, u32),
|
|
/// Host calls (syscalls).
|
|
HostCall(u32),
|
|
/// Variable access.
|
|
GetLocal(u32),
|
|
SetLocal(u32),
|
|
/// Stack operations.
|
|
Pop,
|
|
Dup,
|
|
/// Arithmetic.
|
|
Add,
|
|
Sub,
|
|
Mul,
|
|
Div,
|
|
Neg,
|
|
/// Logical/Comparison.
|
|
Eq,
|
|
Neq,
|
|
Lt,
|
|
Lte,
|
|
Gt,
|
|
Gte,
|
|
And,
|
|
Or,
|
|
Not,
|
|
/// HIP operations.
|
|
Alloc { ty: TypeId, slots: u32 },
|
|
BeginPeek { gate: ValueId },
|
|
BeginBorrow { gate: ValueId },
|
|
BeginMutate { gate: ValueId },
|
|
EndPeek,
|
|
EndBorrow,
|
|
EndMutate,
|
|
/// Reads from heap at gate + field. Pops gate, pushes value.
|
|
GateLoadField(FieldId),
|
|
/// Writes to heap at gate + field. Pops gate and value.
|
|
GateStoreField(FieldId),
|
|
Free,
|
|
}
|