xqvm 0.3.0-rc1

X-Quadratic Virtual Machine — bytecode interpreter for the XQuad Toolchain
Documentation

X-Quadratic Virtual Machine — bytecode types and interpreter.

This crate contains two layers:

  1. Bytecode (xqvm::bytecode) — opcode table, instruction codec, [InstructionBuilder], and [Program]. no_std + alloc-compatible.
  2. Interpreter — [Vm], [Error], [RegVal], and supporting types. The no_std core is always compiled; std-only additions (tracers, [RuntimeDiagnostic], [Disassembly]) are gated on the std feature.
Item Description
[opcodes!] X-macro — the single source of truth for the opcode table
[Opcode] #[repr(u8)] enum
[Instruction] Fully decoded instruction with operands
[Register] 8-bit register slot operand
[Program] Complete program: raw instruction bytes + jump table
[InstructionBuilder] Fluent bytecode assembler
[InstructionStream] Incremental seekable reader
[bytecode::codec] [bytecode::codec::encode] / decode — wire format
[bytecode::error] Bytecode-layer error types
[Vm] The interpreter — stack, registers, loop stack
[Error] Runtime fault variants
[XqmxModel] QUBO/Ising/discrete optimization model
[RegVal] Register value type

Quick start

use xqvm::{Vm, InstructionBuilder};

let mut b = InstructionBuilder::new();
b.emit_push(10).emit_push(32).emit_add().emit_halt();
let program = b.build().unwrap();

let mut vm = Vm::new();
vm.run(&program).unwrap();
assert_eq!(vm.stack(), &[42]);