Expand description
X-Quadratic Virtual Machine — bytecode types and interpreter.
This crate contains two layers:
- Bytecode (
xqvm::bytecode) — opcode table, instruction codec,InstructionBuilder, andProgram.no_std + alloc-compatible. - Interpreter —
Vm,Error,RegVal, and supporting types. Theno_stdcore is always compiled;std-only additions (tracers,RuntimeDiagnostic,Disassembly) are gated on thestdfeature.
| 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]);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, andProgram. - 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§
- Incompatible
Type Error - Error returned by
RegValtyped accessors when the register holds an incompatible kind. - Runtime
Diagnostic - A runtime
Errorenriched with a disassembly listing as source context. - Vm
- The XQVM bytecode interpreter.
- Xqmx
Model - A quadratic optimization model (QUBO/Ising/discrete).
- Xqmx
Sample - 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.
- RegVal
Kind - Discriminant tag for a
RegValvariant.