Skip to main content

weir/live/
program.rs

1use vyre::ir::Program;
2use vyre_primitives::graph::csr_forward_traverse::csr_forward_traverse;
3use vyre_primitives::graph::program_graph::ProgramGraphShape;
4
5use super::OP_ID;
6
7#[must_use]
8/// Build one backward live-variable propagation step over a reversed graph.
9pub fn live_step(shape: ProgramGraphShape, frontier_in: &str, frontier_out: &str) -> Program {
10    // Backward analysis on a forward primitive  -  caller flips edges.
11    csr_forward_traverse(shape, frontier_in, frontier_out, 0xFFFF_FFFF)
12}
13
14inventory::submit! {
15    vyre_harness::OpEntry::new(
16        OP_ID,
17        || live_step(ProgramGraphShape::new(4, 3), "fin", "fout"),
18        Some(|| {
19            let to_bytes = crate::dispatch_decode::pack_u32;
20            // CFG reversed (backward analysis): 3→2→1→0 in storage.
21            vec![vec![
22                to_bytes(&[0, 0, 0, 0]),
23                to_bytes(&[0, 0, 1, 2, 3]),
24                to_bytes(&[0, 1, 2]),
25                to_bytes(&[1, 1, 1]),
26                to_bytes(&[0, 0, 0, 0]),
27                to_bytes(&[0b1000]),
28                to_bytes(&[0b1000]),
29            ]]
30        }),
31        Some(|| {
32            let to_bytes = crate::dispatch_decode::pack_u32;
33            vec![vec![to_bytes(&[0b1100])]]
34        }),
35    )
36}
37
38inventory::submit! {
39    vyre_harness::ConvergenceContract {
40        op_id: OP_ID,
41        max_iterations: 64,
42    }
43}
44
45/// Marker type for the live-variables dataflow primitive.
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47pub struct Liveness;
48
49impl crate::soundness::SoundnessTagged for Liveness {
50    fn soundness(&self) -> crate::soundness::Soundness {
51        crate::soundness::Soundness::Exact
52    }
53}