weirflow 0.1.0

GPU-first dataflow analysis primitives for Vyre and Santh compiler pipelines.
Documentation
//! DF-2  -  reaching definitions.
//!
//! Classical forward monotone dataflow over the CFG. This façade keeps the
//! public reaching API stable while program construction, CPU oracle, closure
//! execution, graph planning, resident execution, and tests live in focused
//! modules.

#[cfg(any(test, feature = "cpu-parity"))]
mod oracle;
mod plan;
mod program;
#[cfg(test)]
#[allow(deprecated)]
mod tests;

pub(crate) const OP_ID: &str = "weir::reaching";

crate::define_analysis_family! {
    family: ReachingFamily,
    kind: crate::fixed_point_graph::FixedPointAnalysisKind::Reaching,
    name: "reaching_closure",
    program_builder: reaching_defs_step,
    graph_prep: plan::prepare_reaching_graph,
    graph_prep_scratch: plan::prepare_reaching_graph_with_scratch,
    input_buffer: "fin",
    output_buffer: "fout",
    closure_prefix: reaching_closure,
    resident_prefix: reaching_closure_resident,
    word_capacity: "reaching_closure",
    frontier_output: "frontier",
    resident_capacity: "reaching_closure resident",
    resident_output: "frontier",
    visibility: pub,
}

/// GPU reaching-definition closure with soundness evidence.
pub fn reaching_closure_evidence_via<F>(
    dispatch: &F,
    node_count: u32,
    edge_offsets: &[u32],
    edge_targets: &[u32],
    edge_kind_mask: &[u32],
    seed_bits: &[u32],
    max_iterations: u32,
) -> Result<crate::soundness::DataflowEvidence<Vec<u32>>, String>
where
    F: Fn(&vyre::ir::Program, &[Vec<u8>], Option<[u32; 3]>) -> Result<Vec<Vec<u8>>, String>,
{
    reaching_closure_via(
        dispatch,
        node_count,
        edge_offsets,
        edge_targets,
        edge_kind_mask,
        seed_bits,
        max_iterations,
    )
    .map(|value| crate::soundness::DataflowEvidence::new(value, crate::soundness::Soundness::Exact))
}

#[cfg(any(test, feature = "cpu-parity"))]
#[allow(deprecated)]
pub(crate) use oracle::reaching_closure_cpu;
pub use plan::{
    prepare_reaching_graph, prepare_reaching_graph_into, prepare_reaching_graph_into_with_scratch,
    prepare_reaching_graph_with_scratch, prepare_reaching_plan, prepare_reaching_plan_into,
    prepare_reaching_plan_into_with_scratch, prepare_reaching_plan_with_scratch,
};
pub use program::{reaching_defs_step, ReachingDefs};

#[cfg(test)]
use vyre::ir::Program;
#[cfg(test)]
use vyre_primitives::graph::program_graph::ProgramGraphShape;