use super::{andersen_points_to, POINTS_TO_EDGE_MASK};
use vyre_primitives::graph::program_graph::ProgramGraphShape;
pub fn prepare_points_to_subset_graph(
node_count: u32,
edge_offsets: &[u32],
edge_targets: &[u32],
edge_kind_mask: &[u32],
) -> Result<crate::fixed_point_graph::FixedPointForwardGraph, String> {
crate::fixed_point_graph::FixedPointForwardGraph::new_with_edge_kind_mask_for_kind(
crate::fixed_point_graph::FixedPointAnalysisKind::PointsToSubset,
"points_to subset_closure_via",
node_count,
edge_offsets,
edge_targets,
edge_kind_mask,
POINTS_TO_EDGE_MASK,
)
}
pub fn prepare_points_to_subset_graph_with_scratch(
node_count: u32,
edge_offsets: &[u32],
edge_targets: &[u32],
edge_kind_mask: &[u32],
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
) -> Result<crate::fixed_point_graph::FixedPointForwardGraph, String> {
scratch.prepare_edge_kind_masks(edge_kind_mask, super::POINTS_TO_EDGE_MASK)?;
crate::fixed_point_graph::FixedPointForwardGraph::new_for_kind(
crate::fixed_point_graph::FixedPointAnalysisKind::PointsToSubset,
"points_to subset_closure_via",
node_count,
edge_offsets,
edge_targets,
&scratch.edge_kind_masks,
)
}
pub fn prepare_points_to_subset_graph_into(
graph: &mut crate::fixed_point_graph::FixedPointForwardGraph,
node_count: u32,
edge_offsets: &[u32],
edge_targets: &[u32],
edge_kind_mask: &[u32],
) -> Result<(), String> {
graph.replace_with_edge_kind_mask_for_kind(
crate::fixed_point_graph::FixedPointAnalysisKind::PointsToSubset,
"points_to subset_closure_via",
node_count,
edge_offsets,
edge_targets,
edge_kind_mask,
POINTS_TO_EDGE_MASK,
)
}
pub fn prepare_points_to_subset_plan(
node_count: u32,
edge_offsets: &[u32],
edge_targets: &[u32],
edge_kind_mask: &[u32],
) -> Result<crate::fixed_point_graph::FixedPointAnalysisPlan, String> {
let graph =
prepare_points_to_subset_graph(node_count, edge_offsets, edge_targets, edge_kind_mask)?;
let program = andersen_points_to(
ProgramGraphShape::new(graph.node_count, graph.edge_count),
"pts_in",
"pts_out",
);
Ok(
crate::fixed_point_graph::FixedPointAnalysisPlan::new_for_kind(
crate::fixed_point_graph::FixedPointAnalysisKind::PointsToSubset,
graph,
program,
),
)
}
pub fn prepare_points_to_subset_plan_into(
plan: &mut crate::fixed_point_graph::FixedPointAnalysisPlan,
node_count: u32,
edge_offsets: &[u32],
edge_targets: &[u32],
edge_kind_mask: &[u32],
) -> Result<(), String> {
plan.require_kind(
crate::fixed_point_graph::FixedPointAnalysisKind::PointsToSubset,
"prepare_points_to_subset_plan_into",
)?;
prepare_points_to_subset_graph_into(
plan.graph_mut(),
node_count,
edge_offsets,
edge_targets,
edge_kind_mask,
)?;
let program = andersen_points_to(
ProgramGraphShape::new(plan.graph().node_count, plan.graph().edge_count),
"pts_in",
"pts_out",
);
plan.replace_program_for_kind(
crate::fixed_point_graph::FixedPointAnalysisKind::PointsToSubset,
program,
);
Ok(())
}