weirflow 0.1.0

GPU-first dataflow analysis primitives for Vyre and Santh compiler pipelines.
Documentation
use std::collections::{HashMap, HashSet};
use weir::graph_layout::CsrGraph;
use weir::reachability_witness::{try_prepare_witness_graph, NodeAttr};
use weir::ssa::{try_compute_dominators, Block, Cfg};

#[test]
fn debug_empty_cfg() {
    let empty_cfg = Cfg {
        entry: 0,
        blocks: HashMap::new(),
    };
    println!("empty cfg: {:?}", try_compute_dominators(&empty_cfg));
}

#[test]
fn debug_entry_not_found() {
    let mut blocks = HashMap::new();
    blocks.insert(
        0,
        Block {
            id: 0,
            preds: vec![],
            succs: vec![],
            defs: HashSet::new(),
            uses: HashSet::new(),
        },
    );
    blocks.insert(
        1,
        Block {
            id: 1,
            preds: vec![0],
            succs: vec![],
            defs: HashSet::new(),
            uses: HashSet::new(),
        },
    );
    let mut cfg = Cfg {
        entry: 100,
        blocks: blocks.clone(),
    };
    println!("entry=100: {:?}", try_compute_dominators(&cfg));
    cfg.entry = u32::MAX;
    println!("entry=MAX: {:?}", try_compute_dominators(&cfg));
}

#[test]
fn debug_witness() {
    let attrs = vec![
        NodeAttr {
            byte_start: 0,
            byte_end: 4,
            file_idx: 0,
        },
        NodeAttr {
            byte_start: 5,
            byte_end: 9,
            file_idx: 0,
        },
        NodeAttr {
            byte_start: 10,
            byte_end: 14,
            file_idx: 0,
        },
        NodeAttr {
            byte_start: 15,
            byte_end: 19,
            file_idx: 0,
        },
    ];
    let files = vec!["a.c".to_string()];
    let desc = vec![
        "s".to_string(),
        "m".to_string(),
        "m2".to_string(),
        "t".to_string(),
    ];
    let offsets = &[0u32, 1, 2, 3, 3];
    let targets = &[1u32, 2, 1, 3];
    let masks = &[1u32, 1, 1, 1];
    println!(
        "cyclic witness: {:?}",
        try_prepare_witness_graph(offsets, targets, masks, &attrs, &files, &desc, "c")
    );
}

#[test]
fn debug_malformed() {
    // Line 478 was: (3, &[0, 0, 0, 0], &[], &[], true)
    let r = CsrGraph::new(3, &[0, 0, 0, 0], &[], &[]).validate("test");
    println!("empty rows: {:?}", r);
}