Skip to main content

weir/fixed_point_batch/
points_to.rs

1use super::{CsrGraph, FixedPointBatch};
2
3impl<'a, F> FixedPointBatch<'a, F>
4where
5    F: Fn(&vyre::ir::Program, &[&[u8]], Option<[u32; 3]>, &mut Vec<Vec<u8>>) -> Result<(), String>,
6{
7    pub fn points_to_subset(
8        &mut self,
9        graph: CsrGraph<'_>,
10        seed_bits: &[u32],
11        max_iterations: u32,
12    ) -> Result<Vec<u32>, String> {
13        crate::points_to::subset_closure_borrowed_into_with_scratch_via(
14            self.dispatch,
15            graph.node_count,
16            graph.edge_offsets,
17            graph.edge_targets,
18            graph.edge_kind_mask,
19            seed_bits,
20            max_iterations,
21            &mut self.scratch,
22        )
23    }
24
25    /// Run Andersen subset closure into caller-owned result storage.
26    pub fn points_to_subset_into(
27        &mut self,
28        graph: CsrGraph<'_>,
29        seed_bits: &[u32],
30        max_iterations: u32,
31        result: &mut Vec<u32>,
32    ) -> Result<(), String> {
33        crate::points_to::subset_closure_borrowed_into_result_with_scratch_via(
34            self.dispatch,
35            graph.node_count,
36            graph.edge_offsets,
37            graph.edge_targets,
38            graph.edge_kind_mask,
39            seed_bits,
40            max_iterations,
41            &mut self.scratch,
42            result,
43        )
44    }
45
46    /// Prepare points-to subset graph buffers for repeated batch runs.
47    pub fn prepare_points_to_subset(
48        &self,
49        graph: CsrGraph<'_>,
50    ) -> Result<crate::fixed_point_graph::FixedPointForwardGraph, String> {
51        crate::points_to::prepare_points_to_subset_graph(
52            graph.node_count,
53            graph.edge_offsets,
54            graph.edge_targets,
55            graph.edge_kind_mask,
56        )
57    }
58
59    /// Repack points-to subset graph buffers into an existing prepared graph.
60    pub fn prepare_points_to_subset_into(
61        &self,
62        graph: CsrGraph<'_>,
63        prepared: &mut crate::fixed_point_graph::FixedPointForwardGraph,
64    ) -> Result<(), String> {
65        crate::points_to::prepare_points_to_subset_graph_into(
66            prepared,
67            graph.node_count,
68            graph.edge_offsets,
69            graph.edge_targets,
70            graph.edge_kind_mask,
71        )
72    }
73
74    /// Prepare points-to subset graph buffers and Program for repeated runs.
75    pub fn prepare_points_to_subset_plan(
76        &self,
77        graph: CsrGraph<'_>,
78    ) -> Result<crate::fixed_point_graph::FixedPointAnalysisPlan, String> {
79        crate::points_to::prepare_points_to_subset_plan(
80            graph.node_count,
81            graph.edge_offsets,
82            graph.edge_targets,
83            graph.edge_kind_mask,
84        )
85    }
86
87    /// Repack a points-to subset plan in place for a new graph layout.
88    pub fn prepare_points_to_subset_plan_into(
89        &self,
90        graph: CsrGraph<'_>,
91        plan: &mut crate::fixed_point_graph::FixedPointAnalysisPlan,
92    ) -> Result<(), String> {
93        crate::points_to::prepare_points_to_subset_plan_into(
94            plan,
95            graph.node_count,
96            graph.edge_offsets,
97            graph.edge_targets,
98            graph.edge_kind_mask,
99        )
100    }
101
102    /// Run points-to subset closure against prepared graph buffers.
103    pub fn points_to_subset_prepared(
104        &mut self,
105        graph: &crate::fixed_point_graph::FixedPointForwardGraph,
106        seed_bits: &[u32],
107        max_iterations: u32,
108    ) -> Result<Vec<u32>, String> {
109        crate::points_to::subset_closure_prepared_borrowed_into_with_scratch_via(
110            self.dispatch,
111            graph,
112            seed_bits,
113            max_iterations,
114            &mut self.scratch,
115        )
116    }
117
118    /// Run points-to subset closure against prepared graph buffers into
119    /// caller-owned result storage.
120    pub fn points_to_subset_prepared_into(
121        &mut self,
122        graph: &crate::fixed_point_graph::FixedPointForwardGraph,
123        seed_bits: &[u32],
124        max_iterations: u32,
125        result: &mut Vec<u32>,
126    ) -> Result<(), String> {
127        crate::points_to::subset_closure_prepared_borrowed_into_result_with_scratch_via(
128            self.dispatch,
129            graph,
130            seed_bits,
131            max_iterations,
132            &mut self.scratch,
133            result,
134        )
135    }
136
137    /// Run points-to subset closure against a prepared graph+Program plan.
138    pub fn points_to_subset_plan(
139        &mut self,
140        plan: &crate::fixed_point_graph::FixedPointAnalysisPlan,
141        seed_bits: &[u32],
142        max_iterations: u32,
143    ) -> Result<Vec<u32>, String> {
144        crate::points_to::subset_closure_plan_borrowed_into_with_scratch_via(
145            self.dispatch,
146            plan,
147            seed_bits,
148            max_iterations,
149            &mut self.scratch,
150        )
151    }
152
153    /// Run points-to subset closure against a prepared graph+Program plan into
154    /// caller-owned result storage.
155    pub fn points_to_subset_plan_into(
156        &mut self,
157        plan: &crate::fixed_point_graph::FixedPointAnalysisPlan,
158        seed_bits: &[u32],
159        max_iterations: u32,
160        result: &mut Vec<u32>,
161    ) -> Result<(), String> {
162        crate::points_to::subset_closure_plan_borrowed_into_result_with_scratch_via(
163            self.dispatch,
164            plan,
165            seed_bits,
166            max_iterations,
167            &mut self.scratch,
168            result,
169        )
170    }
171}