weirflow 0.1.0

GPU-first dataflow analysis primitives for Vyre and Santh compiler pipelines.
Documentation
use super::{CsrGraph, FixedPointBatch};

impl<'a, F> FixedPointBatch<'a, F>
where
    F: Fn(&vyre::ir::Program, &[&[u8]], Option<[u32; 3]>, &mut Vec<Vec<u8>>) -> Result<(), String>,
{
    pub fn live(
        &mut self,
        graph: CsrGraph<'_>,
        seed_bits: &[u32],
        max_iterations: u32,
    ) -> Result<Vec<u32>, String> {
        crate::live::live_closure_borrowed_into_with_scratch_via(
            self.dispatch,
            graph.node_count,
            graph.edge_offsets,
            graph.edge_targets,
            graph.edge_kind_mask,
            seed_bits,
            max_iterations,
            &mut self.scratch,
        )
    }

    /// Run live-variable closure into caller-owned result storage.
    pub fn live_into(
        &mut self,
        graph: CsrGraph<'_>,
        seed_bits: &[u32],
        max_iterations: u32,
        result: &mut Vec<u32>,
    ) -> Result<(), String> {
        crate::live::live_closure_borrowed_into_result_with_scratch_via(
            self.dispatch,
            graph.node_count,
            graph.edge_offsets,
            graph.edge_targets,
            graph.edge_kind_mask,
            seed_bits,
            max_iterations,
            &mut self.scratch,
            result,
        )
    }

    /// Prepare live-variable reversed-control graph buffers for repeated runs.
    pub fn prepare_live(
        &mut self,
        graph: CsrGraph<'_>,
    ) -> Result<crate::fixed_point_graph::FixedPointForwardGraph, String> {
        crate::live::prepare_live_graph_with_scratch(
            graph.node_count,
            graph.edge_offsets,
            graph.edge_targets,
            graph.edge_kind_mask,
            &mut self.scratch,
        )
    }

    /// Repack live-variable graph buffers into an existing prepared graph.
    pub fn prepare_live_into(
        &mut self,
        graph: CsrGraph<'_>,
        prepared: &mut crate::fixed_point_graph::FixedPointForwardGraph,
    ) -> Result<(), String> {
        crate::live::prepare_live_graph_into_with_scratch(
            prepared,
            graph.node_count,
            graph.edge_offsets,
            graph.edge_targets,
            graph.edge_kind_mask,
            &mut self.scratch,
        )
    }

    /// Prepare live-variable graph buffers and Program for repeated runs.
    pub fn prepare_live_plan(
        &mut self,
        graph: CsrGraph<'_>,
    ) -> Result<crate::fixed_point_graph::FixedPointAnalysisPlan, String> {
        crate::live::prepare_live_plan_with_scratch(
            graph.node_count,
            graph.edge_offsets,
            graph.edge_targets,
            graph.edge_kind_mask,
            &mut self.scratch,
        )
    }

    /// Repack a live-variable plan in place for a new graph layout.
    pub fn prepare_live_plan_into(
        &mut self,
        graph: CsrGraph<'_>,
        plan: &mut crate::fixed_point_graph::FixedPointAnalysisPlan,
    ) -> Result<(), String> {
        crate::live::prepare_live_plan_into_with_scratch(
            plan,
            graph.node_count,
            graph.edge_offsets,
            graph.edge_targets,
            graph.edge_kind_mask,
            &mut self.scratch,
        )
    }

    /// Run live-variable closure against prepared reversed-control buffers.
    pub fn live_prepared(
        &mut self,
        graph: &crate::fixed_point_graph::FixedPointForwardGraph,
        seed_bits: &[u32],
        max_iterations: u32,
    ) -> Result<Vec<u32>, String> {
        crate::live::live_closure_prepared_borrowed_into_with_scratch_via(
            self.dispatch,
            graph,
            seed_bits,
            max_iterations,
            &mut self.scratch,
        )
    }

    /// Run live-variable closure against prepared reversed-control buffers
    /// into caller-owned result storage.
    pub fn live_prepared_into(
        &mut self,
        graph: &crate::fixed_point_graph::FixedPointForwardGraph,
        seed_bits: &[u32],
        max_iterations: u32,
        result: &mut Vec<u32>,
    ) -> Result<(), String> {
        crate::live::live_closure_prepared_borrowed_into_result_with_scratch_via(
            self.dispatch,
            graph,
            seed_bits,
            max_iterations,
            &mut self.scratch,
            result,
        )
    }

    /// Run live-variable closure against a prepared graph+Program plan.
    pub fn live_plan(
        &mut self,
        plan: &crate::fixed_point_graph::FixedPointAnalysisPlan,
        seed_bits: &[u32],
        max_iterations: u32,
    ) -> Result<Vec<u32>, String> {
        crate::live::live_closure_plan_borrowed_into_with_scratch_via(
            self.dispatch,
            plan,
            seed_bits,
            max_iterations,
            &mut self.scratch,
        )
    }

    /// Run live-variable closure against a prepared graph+Program plan into
    /// caller-owned result storage.
    pub fn live_plan_into(
        &mut self,
        plan: &crate::fixed_point_graph::FixedPointAnalysisPlan,
        seed_bits: &[u32],
        max_iterations: u32,
        result: &mut Vec<u32>,
    ) -> Result<(), String> {
        crate::live::live_closure_plan_borrowed_into_result_with_scratch_via(
            self.dispatch,
            plan,
            seed_bits,
            max_iterations,
            &mut self.scratch,
            result,
        )
    }
}