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_sha1`.

/// Shared WGSL helpers for HMAC-SHA-1.
pub const WGSL: &str = concat!(
    include_str!("wgsl_shaders/words.wgsl"),
    "\n",
    include_str!("wgsl_shaders/sha1.wgsl"),
);

/// Compute HMAC-SHA-1 and return five big-endian digest words.
#[must_use]
pub fn hmac_sha1(key: &[u8], msg: &[u8]) -> [u32; 5] {
    crate::ops::hash::reference::hmac::hmac_sha1_words(key, msg)
}

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

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

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

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

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