vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
//! Generated operation registry.
//!
//! `build.rs` scans the operation source tree and writes the registry into
//! `$OUT_DIR`; this file only exposes that generated list to lookup helpers.

use crate::ops::OpSpec;

include!(concat!(env!("OUT_DIR"), "/ops_registry.rs"));

#[cfg(test)]
/// Test-only operation used to verify recursive call-depth validation.
pub static TEST_OP_1: OpSpec = OpSpec::composition_inlinable("test.op1", &[], &[], &[], || {
    crate::ir::Program::new(
        vec![],
        [1, 1, 1],
        vec![crate::ir::Node::let_bind(
            "x",
            crate::ir::Expr::call("test.op2", vec![]),
        )],
    )
});

#[cfg(test)]
/// Test-only operation used to verify recursive call-depth validation.
pub static TEST_OP_2: OpSpec = OpSpec::composition_inlinable("test.op2", &[], &[], &[], || {
    crate::ir::Program::new(
        vec![],
        [1, 1, 1],
        vec![crate::ir::Node::let_bind(
            "x",
            crate::ir::Expr::call("test.op1", vec![]),
        )],
    )
});

#[cfg(test)]
static TEST_REGISTRY: &[&OpSpec] = &[&TEST_OP_1, &TEST_OP_2];

/// Iterate over every registered `OpSpec`.
pub fn registry() -> impl Iterator<Item = &'static OpSpec> {
    #[cfg(test)]
    {
        TEST_REGISTRY
            .iter()
            .copied()
            .chain(GENERATED_REGISTRY.iter().copied())
    }

    #[cfg(not(test))]
    {
        GENERATED_REGISTRY.iter().copied()
    }
}