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 reaching(
8 &mut self,
9 graph: CsrGraph<'_>,
10 seed_bits: &[u32],
11 max_iterations: u32,
12 ) -> Result<Vec<u32>, String> {
13 crate::reaching::reaching_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 pub fn reaching_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::reaching::reaching_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 pub fn prepare_reaching(
48 &mut self,
49 graph: CsrGraph<'_>,
50 ) -> Result<crate::fixed_point_graph::FixedPointForwardGraph, String> {
51 self.scratch.prepare_edge_kind_masks(
52 graph.edge_kind_mask,
53 vyre_primitives::predicate::edge_kind::CONTROL,
54 )?;
55 crate::fixed_point_graph::FixedPointForwardGraph::new_for_kind(
56 crate::fixed_point_graph::FixedPointAnalysisKind::Reaching,
57 "reaching_closure",
58 graph.node_count,
59 graph.edge_offsets,
60 graph.edge_targets,
61 &self.scratch.edge_kind_masks,
62 )
63 }
64
65 pub fn prepare_reaching_into(
67 &mut self,
68 graph: CsrGraph<'_>,
69 prepared: &mut crate::fixed_point_graph::FixedPointForwardGraph,
70 ) -> Result<(), String> {
71 crate::reaching::prepare_reaching_graph_into_with_scratch(
72 prepared,
73 graph.node_count,
74 graph.edge_offsets,
75 graph.edge_targets,
76 graph.edge_kind_mask,
77 &mut self.scratch,
78 )
79 }
80
81 pub fn prepare_reaching_plan(
83 &mut self,
84 graph: CsrGraph<'_>,
85 ) -> Result<crate::fixed_point_graph::FixedPointAnalysisPlan, String> {
86 crate::reaching::prepare_reaching_plan_with_scratch(
87 graph.node_count,
88 graph.edge_offsets,
89 graph.edge_targets,
90 graph.edge_kind_mask,
91 &mut self.scratch,
92 )
93 }
94
95 pub fn prepare_reaching_plan_into(
97 &mut self,
98 graph: CsrGraph<'_>,
99 plan: &mut crate::fixed_point_graph::FixedPointAnalysisPlan,
100 ) -> Result<(), String> {
101 crate::reaching::prepare_reaching_plan_into_with_scratch(
102 plan,
103 graph.node_count,
104 graph.edge_offsets,
105 graph.edge_targets,
106 graph.edge_kind_mask,
107 &mut self.scratch,
108 )
109 }
110
111 pub fn reaching_prepared(
113 &mut self,
114 graph: &crate::fixed_point_graph::FixedPointForwardGraph,
115 seed_bits: &[u32],
116 max_iterations: u32,
117 ) -> Result<Vec<u32>, String> {
118 crate::reaching::reaching_closure_prepared_borrowed_into_with_scratch_via(
119 self.dispatch,
120 graph,
121 seed_bits,
122 max_iterations,
123 &mut self.scratch,
124 )
125 }
126
127 pub fn reaching_prepared_into(
130 &mut self,
131 graph: &crate::fixed_point_graph::FixedPointForwardGraph,
132 seed_bits: &[u32],
133 max_iterations: u32,
134 result: &mut Vec<u32>,
135 ) -> Result<(), String> {
136 crate::reaching::reaching_closure_prepared_borrowed_into_result_with_scratch_via(
137 self.dispatch,
138 graph,
139 seed_bits,
140 max_iterations,
141 &mut self.scratch,
142 result,
143 )
144 }
145
146 pub fn reaching_plan(
148 &mut self,
149 plan: &crate::fixed_point_graph::FixedPointAnalysisPlan,
150 seed_bits: &[u32],
151 max_iterations: u32,
152 ) -> Result<Vec<u32>, String> {
153 crate::reaching::reaching_closure_plan_borrowed_into_with_scratch_via(
154 self.dispatch,
155 plan,
156 seed_bits,
157 max_iterations,
158 &mut self.scratch,
159 )
160 }
161
162 pub fn reaching_plan_into(
165 &mut self,
166 plan: &crate::fixed_point_graph::FixedPointAnalysisPlan,
167 seed_bits: &[u32],
168 max_iterations: u32,
169 result: &mut Vec<u32>,
170 ) -> Result<(), String> {
171 crate::reaching::reaching_closure_plan_borrowed_into_result_with_scratch_via(
172 self.dispatch,
173 plan,
174 seed_bits,
175 max_iterations,
176 &mut self.scratch,
177 result,
178 )
179 }
180}