diff --git a/Cargo.toml b/Cargo.toml index f3f4f5b..e87a687 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] diff --git a/dataflow_analysis/Cargo.toml b/dataflow_analysis/Cargo.toml new file mode 100644 index 0000000..9b331b3 --- /dev/null +++ b/dataflow_analysis/Cargo.toml @@ -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"] diff --git a/dataflow_analysis/src/lib.rs b/dataflow_analysis/src/lib.rs new file mode 100644 index 0000000..dd36d89 --- /dev/null +++ b/dataflow_analysis/src/lib.rs @@ -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() {} +} diff --git a/driver/Cargo.toml b/driver/Cargo.toml index fba8483..3b988fb 100644 --- a/driver/Cargo.toml +++ b/driver/Cargo.toml @@ -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" } diff --git a/driver/src/main.rs b/driver/src/main.rs index b96fc51..e1ee648 100644 --- a/driver/src/main.rs +++ b/driver/src/main.rs @@ -1,6 +1,7 @@ use std::{error::Error, io::Read}; use clap::Parser; +use dataflow_analysis::DataflowAnalyses; use optimizations::{OptimizationPass, PassManager}; #[derive(Parser)] @@ -11,6 +12,9 @@ struct Args { #[arg(long, value_enum)] optimizations: Vec, + + #[arg(short, long, value_enum, help = "Type of dataflow analysis to run")] + dataflow_analysis: Option, } fn main() -> Result<(), Box> { @@ -39,7 +43,11 @@ fn main() -> Result<(), Box> { 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(()) }