Skip to main content

weir/
reaching.rs

1//! DF-2  -  reaching definitions.
2//!
3//! Classical forward monotone dataflow over the CFG. This façade keeps the
4//! public reaching API stable while program construction, CPU oracle, closure
5//! execution, graph planning, resident execution, and tests live in focused
6//! modules.
7
8#[cfg(any(test, feature = "cpu-parity"))]
9mod oracle;
10mod plan;
11mod program;
12#[cfg(test)]
13#[allow(deprecated)]
14mod tests;
15
16pub(crate) const OP_ID: &str = "weir::reaching";
17
18crate::define_analysis_family! {
19    family: ReachingFamily,
20    kind: crate::fixed_point_graph::FixedPointAnalysisKind::Reaching,
21    name: "reaching_closure",
22    program_builder: reaching_defs_step,
23    graph_prep: plan::prepare_reaching_graph,
24    graph_prep_scratch: plan::prepare_reaching_graph_with_scratch,
25    input_buffer: "fin",
26    output_buffer: "fout",
27    closure_prefix: reaching_closure,
28    resident_prefix: reaching_closure_resident,
29    word_capacity: "reaching_closure",
30    frontier_output: "frontier",
31    resident_capacity: "reaching_closure resident",
32    resident_output: "frontier",
33    visibility: pub,
34}
35
36/// GPU reaching-definition closure with soundness evidence.
37pub fn reaching_closure_evidence_via<F>(
38    dispatch: &F,
39    node_count: u32,
40    edge_offsets: &[u32],
41    edge_targets: &[u32],
42    edge_kind_mask: &[u32],
43    seed_bits: &[u32],
44    max_iterations: u32,
45) -> Result<crate::soundness::DataflowEvidence<Vec<u32>>, String>
46where
47    F: Fn(&vyre::ir::Program, &[Vec<u8>], Option<[u32; 3]>) -> Result<Vec<Vec<u8>>, String>,
48{
49    reaching_closure_via(
50        dispatch,
51        node_count,
52        edge_offsets,
53        edge_targets,
54        edge_kind_mask,
55        seed_bits,
56        max_iterations,
57    )
58    .map(|value| crate::soundness::DataflowEvidence::new(value, crate::soundness::Soundness::Exact))
59}
60
61#[cfg(any(test, feature = "cpu-parity"))]
62#[allow(deprecated)]
63pub(crate) use oracle::reaching_closure_cpu;
64pub use plan::{
65    prepare_reaching_graph, prepare_reaching_graph_into, prepare_reaching_graph_into_with_scratch,
66    prepare_reaching_graph_with_scratch, prepare_reaching_plan, prepare_reaching_plan_into,
67    prepare_reaching_plan_into_with_scratch, prepare_reaching_plan_with_scratch,
68};
69pub use program::{reaching_defs_step, ReachingDefs};
70
71#[cfg(test)]
72use vyre::ir::Program;
73#[cfg(test)]
74use vyre_primitives::graph::program_graph::ProgramGraphShape;