Skip to main content

vyre_reference/
lib.rs

1//! Pure Rust reference interpreter for vyre IR programs.
2//!
3//! This module is the executable specification for IR semantics. It is
4//! intentionally slow and direct: every current IR expression and node variant
5//! has a named evaluator function.
6
7/// Dual-reference trait and registry types.
8pub mod dual;
9/// Re-export of vyre's canonical hash primitives (MD5, SHA1/2/3, BLAKE2/3,
10/// RIPEMD160, SipHash, xxHash, HMAC, KDF). The canonical implementations
11/// live in `vyre::ops::hash::reference` so that core ops and the IR
12/// interpreter agree byte-for-byte; this re-export keeps the
13/// `vyre_reference::hash::…` path stable for downstream consumers.
14pub use vyre::ops::hash::reference as hash;
15/// Operation-specific standalone CPU references.
16pub mod primitive;
17/// Runtime value representation for interpreter inputs and outputs.
18pub mod value;
19
20/// Atomic operation reference implementations.
21pub mod atomics;
22/// CPU operation traits used by concrete reference implementations.
23pub mod cpu_op;
24/// Expression evaluator (BinOp, UnOp, Load, Call, etc).
25pub mod eval_expr;
26/// Statement evaluator (Let, Store, If, Loop, Barrier, etc).
27pub mod eval_node;
28/// Flat byte adapter used by [`crate::cpu_op::CpuOp`].
29pub mod flat_cpu;
30/// IEEE 754 strict floating-point utilities.
31pub mod ieee754;
32/// Top-level interpreter entry point and error types.
33pub mod interp;
34/// Workgroup simulation: invocation IDs, shared memory.
35pub mod workgroup;
36
37mod oob;
38mod ops;
39mod typed_ops;
40
41/// Execute a vyre IR program on the pure Rust reference interpreter.
42pub use interp::run;
43
44/// Resolve an operation ID to its two independently-written references.
45pub fn resolve_dual(op_id: &str) -> Option<(dual::ReferenceFn, dual::ReferenceFn)> {
46    match op_id {
47        primitive::bitwise::xor::OP_ID => Some((
48            primitive::bitwise::xor::reference_a::reference,
49            primitive::bitwise::xor::reference_b::reference,
50        )),
51        _ => None,
52    }
53}
54
55/// Return the complete list of operation IDs that have dual references registered.
56///
57/// This is the canonical enumeration used by the differential fuzzing gate.
58/// Every new dual-reference pair MUST add its OP_ID here.
59pub fn dual_op_ids() -> &'static [&'static str] {
60    &[primitive::bitwise::xor::OP_ID]
61}