weirflow 0.1.0

GPU-first dataflow analysis primitives for Vyre and Santh compiler pipelines.
Documentation
use super::OP_ID;
use vyre::ir::Program;
use vyre_primitives::graph::csr_backward_traverse::csr_backward_traverse;
use vyre_primitives::graph::program_graph::ProgramGraphShape;

/// Build one reverse-BFS step. Caller invokes this Program in a
/// host loop until the slice bitset stops growing (same fixpoint
/// driver pattern as DF-2 reaching, DF-3 points-to).
///
/// Buffer contract: `frontier_in` is the current slice bitset (seed
/// is one bit set  -  the sink node). `frontier_out` is the expanded
/// bitset after one reverse-edge traversal. The caller-supplied
/// `ProgramGraph` buffers are bound at the canonical `pg_*` names
/// (callgraph ∪ reach ∪ dom merged via three-way `fuse_programs`).
///
/// PHASE6_DATAFLOW HIGH: previous 5-arg entry hardcoded
/// `ProgramGraphShape::new(1, 1)` and ignored the `reach`,
/// `callgraph`, `dom` buffer arguments  -  i.e. it produced a
/// 1-node-grid kernel for any real CFG, silently losing every
/// dependency edge. The 5-arg shim is now `#[deprecated]` and
/// delegates with a pessimistic shape that surfaces the bug.
/// Callers MUST use the explicit-shape entry below.
#[must_use]
pub fn backward_slice(shape: ProgramGraphShape, frontier_in: &str, frontier_out: &str) -> Program {
    vyre_harness::region::tag_program(
        OP_ID,
        csr_backward_traverse(shape, frontier_in, frontier_out, u32::MAX),
    )
}

/// Deprecated alias for back-compat with callers that imported the
/// pre-fix `backward_slice_with_shape` name.
#[deprecated(
    since = "0.4.1",
    note = "use `backward_slice(shape, frontier_in, frontier_out)` directly  -  the suffix is redundant since the 5-arg entry was removed"
)]
#[must_use]
pub fn backward_slice_with_shape(
    shape: ProgramGraphShape,
    frontier_in: &str,
    frontier_out: &str,
) -> Program {
    backward_slice(shape, frontier_in, frontier_out)
}

/// Marker type for the backward-slice dataflow primitive.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct BackwardSlice;

impl crate::soundness::SoundnessTagged for BackwardSlice {
    fn soundness(&self) -> crate::soundness::Soundness {
        crate::soundness::Soundness::MayOver
    }
}

inventory::submit! {
    vyre_harness::OpEntry::new(
        OP_ID,
        || backward_slice(ProgramGraphShape::new(4, 3), "frontier_in", "frontier_out"),
        Some(|| {
            let u32s = crate::dispatch_decode::pack_u32;
            vec![vec![
                u32s(&[0, 0, 0, 0]),
                u32s(&[0, 1, 2, 3, 3]),
                u32s(&[1, 3, 1]),
                u32s(&[1, 1, 1]),
                u32s(&[0, 0, 0, 0]),
                u32s(&[0b0010]),
                u32s(&[0]),
            ]]
        }),
        Some(|| {
            let u32s = crate::dispatch_decode::pack_u32;
            vec![vec![u32s(&[0b0101])]]
        }),
    )
}