vyre-conform 0.1.0

Conformance suite for vyre backends — proves byte-identical output to CPU reference
Documentation
//! Comparator-type compatibility validation.

use super::ComparatorKind;

/// Validate that the comparator kind is appropriate for the data type.
/// Integer ops MUST use ExactMatch. Approximate is only valid for float ops.
///
/// Call this at spec registration time to catch agents that declare
/// Approximate on integer ops to make broken implementations pass.
#[inline]
pub fn validate_comparator_for_type(
    kind: &ComparatorKind,
    output_type: &crate::spec::types::DataType,
    op_id: &str,
) {
    match output_type {
        crate::spec::types::DataType::U32
        | crate::spec::types::DataType::I32
        | crate::spec::types::DataType::U64
        | crate::spec::types::DataType::Vec2U32
        | crate::spec::types::DataType::Vec4U32
        | crate::spec::types::DataType::Bytes => {
            assert!(
                matches!(
                    kind,
                    ComparatorKind::ExactMatch | ComparatorKind::UnorderedMatch
                ),
                "Fix: op '{}' has integer/byte output type {:?} but uses {:?} comparator. \
                 Integer ops MUST use ExactMatch or UnorderedMatch. \
                 Approximate is only valid for future float ops.",
                op_id,
                output_type,
                kind
            );
        }
        _ => {} // Float types may use Approximate
    }
}