Nilton Constantino adcb34826c
pr 40
2026-01-31 01:33:19 +00:00

55 lines
1.4 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),
/// Push a bounded value (0..0xFFFF).
PushBounded(u32),
/// Placeholder for function calls.
Call(FunctionId, u32),
/// Host calls (syscalls). (id, return_slots)
HostCall(u32, 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 { gate: ValueId, field: FieldId },
/// Writes to heap at gate + field. Pops gate and value.
GateStoreField { gate: ValueId, field: FieldId, value: ValueId },
/// Reads from heap at gate + index.
GateLoadIndex { gate: ValueId, index: ValueId },
/// Writes to heap at gate + index.
GateStoreIndex { gate: ValueId, index: ValueId, value: ValueId },
Free,
}