vyre-conform 0.1.0

Conformance suite for vyre backends — proves byte-identical output to CPU reference
Documentation
use super::{pair_bytes, sig, u32_bytes, InputGenerator};
use crate::spec::types::OpSignature;

/// Exhaustively covers single-byte u32 ranges.
///
/// - Unary u32: full 0..=255 (256 inputs).
/// - Binary u32: only a 16×16 grid (0..=15 for each operand).
pub struct ExhaustiveByteRange;

impl InputGenerator for ExhaustiveByteRange {
    fn name(&self) -> &'static str {
        "exhaustive_byte_range"
    }

    fn handles(&self, signature: &OpSignature) -> bool {
        sig::is_unary_u32(signature) || sig::is_binary_u32(signature)
    }

    fn generate(&self, signature: &OpSignature, _seed: u64) -> Vec<(String, Vec<u8>)> {
        if sig::is_unary_u32(signature) {
            (0_u32..=255)
                .map(|value| (format!("u32:{value}"), u32_bytes(value)))
                .collect()
        } else if sig::is_binary_u32(signature) {
            let mut out = Vec::with_capacity(256);
            for left in 0_u32..=15 {
                for right in 0_u32..=15 {
                    out.push((format!("pair:{left}:{right}"), pair_bytes(left, right)));
                }
            }
            out
        } else {
            Vec::new()
        }
    }
}