Skip to content

Commit

Permalink
Add dataflow analysis scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjoseph1995 committed Nov 5, 2024
1 parent 2007deb commit e45d2da
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
resolver = "2"
members = ["bril/bril-rs/bril2json", "common", "driver", "optimizations", "bril/brilirs"]
members = ["bril/bril-rs/bril2json", "common", "driver", "optimizations", "bril/brilirs", "dataflow_analysis"]
12 changes: 12 additions & 0 deletions dataflow_analysis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "dataflow_analysis"
version = "0.1.0"
edition = "2021"

[dependencies]
clap = "4.5.20"

[dependencies.bril-rs]
version = "0.1.0"
path = "../bril/bril-rs"
features = ["ssa", "memory", "float", "speculate", "position"]
19 changes: 19 additions & 0 deletions dataflow_analysis/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use bril_rs::Program;
use clap::ValueEnum;

#[derive(ValueEnum, Clone, Debug, PartialEq, Copy)]
pub enum DataflowAnalyses {
LiveVariable,
}

pub fn run_analysis(dataflow_analysis_name: DataflowAnalyses, program: &Program) -> () {
todo!()
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {}
}
1 change: 1 addition & 0 deletions driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ edition = "2021"
[dependencies]
clap = { version = "4.5.20", features = ["derive"] }
common = { version = "0.1.0", path = "../common" }
dataflow_analysis = { version = "0.1.0", path = "../dataflow_analysis" }
optimizations = { version = "0.1.0", path = "../optimizations" }
12 changes: 10 additions & 2 deletions driver/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{error::Error, io::Read};

use clap::Parser;
use dataflow_analysis::DataflowAnalyses;
use optimizations::{OptimizationPass, PassManager};

#[derive(Parser)]
Expand All @@ -11,6 +12,9 @@ struct Args {

#[arg(long, value_enum)]
optimizations: Vec<OptimizationPass>,

#[arg(short, long, value_enum, help = "Type of dataflow analysis to run")]
dataflow_analysis: Option<DataflowAnalyses>,
}

fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -39,7 +43,11 @@ fn main() -> Result<(), Box<dyn Error>> {
pass_manager.register_pass(*optimization);
}
program = pass_manager.run(program);

println!("{}", program);
if let Some(dataflow_analysis_name) = args.dataflow_analysis {
dataflow_analysis::run_analysis(dataflow_analysis_name, &program);
} else {
// Simply print the optimized program
println!("{}", program);
}
Ok(())
}

0 comments on commit e45d2da

Please sign in to comment.