Skip to main content

Crate xqvm

Crate xqvm 

Source
Expand description

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. InterpreterVm, Error, RegVal, and supporting types. The no_std core is always compiled; std-only additions (tracers, RuntimeDiagnostic, Disassembly) are gated on the std feature.
ItemDescription
opcodes!X-macro — the single source of truth for the opcode table
Opcode#[repr(u8)] enum
InstructionFully decoded instruction with operands
Register8-bit register slot operand
ProgramComplete program: raw instruction bytes + jump table
InstructionBuilderFluent bytecode assembler
InstructionStreamIncremental seekable reader
bytecode::codecbytecode::codec::encode / decode — wire format
bytecode::errorBytecode-layer error types
VmThe interpreter — stack, registers, loop stack
ErrorRuntime fault variants
XqmxModelQUBO/Ising/discrete optimization model
RegValRegister 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]);

Re-exports§

pub use bytecode::codec;
pub use bytecode::Instruction;
pub use bytecode::InstructionBuilder;
pub use bytecode::InstructionStream;
pub use bytecode::JumpTable;
pub use bytecode::LabelId;
pub use bytecode::Opcode;
pub use bytecode::Program;
pub use bytecode::ProgramDecodeError;
pub use bytecode::Register;
pub use bytecode::RegisterEffect;
pub use bytecode::StackEffect;
pub use disasm::Disassembly;
pub use tracer::JsonTracer;
pub use tracer::TextTracer;
pub use tracer::NoopTracer;
pub use tracer::StepState;
pub use tracer::Tracer;
pub use verifier::RegType;
pub use verifier::VerifierError;

Modules§

bytecode
Bytecode layer (no_std-compatible): opcode table, instruction codec, InstructionBuilder, and Program.
dataflow
Worklist-based data-flow analysis framework.
disasm
Pretty printer for XQVM bytecode.
tracer
Execution tracing for the XQVM interpreter.
verifier
Pre-execution bytecode verifier for XQVM programs.

Macros§

opcodes
Invoke $mac! with the complete XQVM opcode table.

Structs§

IncompatibleTypeError
Error returned by RegVal typed accessors when the register holds an incompatible kind.
RuntimeDiagnostic
A runtime Error enriched with a disassembly listing as source context.
Vm
The XQVM bytecode interpreter.
XqmxModel
A quadratic optimization model (QUBO/Ising/discrete).
XqmxSample
A candidate solution for an XQMX model.

Enums§

Domain
Variable domain for an XQMX model or sample.
Error
Errors that can occur during XQVM bytecode execution.
RegVal
A value that can be stored in an XQVM register.
RegValKind
Discriminant tag for a RegVal variant.