vyre 0.2.0

GPU bytecode condition engine
Documentation
mod common;
mod flow;
mod switch_cases;

/// Generate the pass-3 evaluation shader.
///
/// This shader implements the full vyre bytecode ISA on GPU, evaluating one
/// rule program per invocation against pre-scattered match metadata.
pub fn build_eval_shader(max_stack: u32, max_for_iterations: u32) -> String {
    let simple_cases = switch_cases::instruction_cases("(*stack)", "return ABORT_SENTINEL;");
    [
        common::header(max_stack, max_for_iterations),
        r#"

fn exec_simple_inst(inst: Instruction, rule_id: u32, sp_in: u32, stack: ptr<function, array<u32, STACK_SIZE>>) -> u32 {
    var sp = sp_in;
    switch inst.opcode {
"#
        .to_string(),
        simple_cases,
        r#"
        default: { return ABORT_SENTINEL; }
    }
    return sp;
}
"#
        .to_string(),
        flow::shader_flow(max_stack, &switch_cases::instruction_cases("stack", "return;")),
    ]
    .join("")
}