vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
use crate::ir::DataType;
use crate::ops::Backend;
use crate::ops::{IntrinsicDescriptor, OpSpec};

// WGSL lowering source for `hash.hmac_md5`.

/// Concrete HMAC-MD5 WGSL kernel.
pub const WGSL: &str = include_str!("wgsl/hmac_md5.wgsl");

/// Compute HMAC-MD5 and return four big-endian digest words.
#[must_use]
pub fn hmac_md5(key: &[u8], msg: &[u8]) -> [u32; 4] {
    crate::ops::hash::reference::hmac::hmac_md5_words(key, msg)
}

pub const INPUTS: &[DataType] = &[DataType::Bytes, DataType::Bytes];

pub const LAWS: &[crate::ops::AlgebraicLaw] = &[];

pub const OUTPUTS: &[DataType] = &[const { DataType::U32 }; 4];

/// Declarative operation specification for `hash.hmac_md5`.
pub const SPEC: OpSpec = OpSpec::intrinsic(
    "hash.hmac_md5",
    INPUTS,
    OUTPUTS,
    LAWS,
    wgsl_only,
    IntrinsicDescriptor::new(
        "hash.hmac_md5.wgsl",
        "wgsl-hmac-md5",
        crate::ops::hash::cpu_refs::hmac_md5,
    ),
);

pub fn wgsl_only(backend: &Backend) -> bool {
    matches!(backend, Backend::Wgsl)
}