From add16b35fe9c775f1502480906ddeb09954a0813 Mon Sep 17 00:00:00 2001 From: Ryan Ziegler <rzig408@gmail.com> Date: Fri, 1 Nov 2024 15:19:45 -0400 Subject: [PATCH] fix Xdot check, get frontend to compile --- juno_frontend/src/main.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/juno_frontend/src/main.rs b/juno_frontend/src/main.rs index 67c89255..2b0dc6b7 100644 --- a/juno_frontend/src/main.rs +++ b/juno_frontend/src/main.rs @@ -14,7 +14,7 @@ mod types; use codegen::*; -use std::path::PathBuf; +use std::path::Path; extern crate hercules_ir; @@ -62,7 +62,9 @@ fn main() { pm.add_pass(hercules_opt::pass::Pass::Verify); } add_verified_pass!(pm, args, PhiElim); - pm.add_pass(hercules_opt::pass::Pass::Xdot(true)); + if args.x_dot { + pm.add_pass(hercules_opt::pass::Pass::Xdot(true)); + } add_pass!(pm, args, CCP); add_pass!(pm, args, DCE); add_pass!(pm, args, GVN); @@ -77,17 +79,15 @@ fn main() { if args.x_dot { pm.add_pass(hercules_opt::pass::Pass::Xdot(true)); } - match args.output { - Some(file) => pm.add_pass(hercules_opt::pass::Pass::Codegen(file)), - None => { - let mut path = PathBuf::from(src_file); - path.set_extension("hbin"); - println!("{:?}", path); - pm.add_pass(hercules_opt::pass::Pass::Codegen( - path.to_str().unwrap().to_string(), - )); - } - } + + let src_file_path = Path::new(&src_file); + let module_name = String::from(src_file_path.file_stem().unwrap().to_str().unwrap()); + let output_folder = match args.output { + Some(output_folder) => output_folder, + None => String::from(src_file_path.parent().unwrap().to_str().unwrap()) + }; + pm.add_pass(hercules_opt::pass::Pass::Codegen(output_folder, module_name)); + let _ = pm.run_passes(); } Err(errs) => { -- GitLab