Nilton Constantino f80cb64f66
pr 58
2026-02-02 16:31:06 +00:00

57 lines
1.5 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),
/// External calls (imports). (dep_alias, module_path, symbol_name, arg_count)
ImportCall(String, String, String, 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,
}