vyre-reference 0.4.1

Pure-Rust CPU reference interpreter for vyre IR — byte-identical oracle for backend conformance and small-data fallback
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{dual_impls::common, workgroup::Memory};
use vyre_primitives::HashFnv1a;

const FNV_OFFSET: u32 = 0x811c_9dc5;
const FNV_PRIME: u32 = 0x0100_0193;

impl common::ReferenceEvaluator for HashFnv1a {
    fn evaluate(&self, inputs: &[Memory]) -> Result<Memory, common::EvalError> {
        let mut hash = FNV_OFFSET;
        let input = common::one_input(inputs, "hash_fnv1a")?;
        for byte in &input {
            hash ^= u32::from(*byte);
            hash = hash.wrapping_mul(FNV_PRIME);
        }
        Ok(Memory::from_bytes(hash.to_le_bytes().to_vec()))
    }
}