vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
use super::registry;
use crate::ops::OpSpec;
use rustc_hash::FxHashMap;
use std::sync::LazyLock;

/// Pre-built O(1) index from operation ID to its static spec reference.
///
/// Constructed once on first access. Every subsequent `lookup()` call is a
/// single hash probe instead of a linear scan of the full registry.
static REGISTRY_MAP: LazyLock<FxHashMap<&'static str, &'static OpSpec>> =
    LazyLock::new(|| registry().map(|op| (op.id(), op)).collect());

/// Look up an operation by its stable ID.
///
/// This is called in the interpreter hot path (`eval_call`) and during
/// conformance certification. The backing index is built once on first
/// use and gives O(1) amortised lookup thereafter.
#[must_use]
pub fn lookup(op_id: &str) -> Option<&'static OpSpec> {
    REGISTRY_MAP.get(op_id).copied()
}