mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-15 06:58:50 +00:00
Merge pull request #8 from m-spitfire/irviz
Fix: Optimize before visualizing IR
This commit is contained in:
40
bin/kecc.rs
40
bin/kecc.rs
@@ -141,6 +141,26 @@ fn compile_ir(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if matches.optimize {
|
||||||
|
O1::default().optimize(input);
|
||||||
|
} else {
|
||||||
|
if matches.simplify_cfg {
|
||||||
|
SimplifyCfg::default().optimize(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
if matches.mem2reg {
|
||||||
|
Mem2reg::default().optimize(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
if matches.deadcode {
|
||||||
|
Deadcode::default().optimize(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
if matches.gvn {
|
||||||
|
Gvn::default().optimize(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(path) = &matches.irviz {
|
if let Some(path) = &matches.irviz {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Path::new(&path).extension(),
|
Path::new(&path).extension(),
|
||||||
@@ -181,26 +201,6 @@ fn compile_ir(
|
|||||||
temp_dir.close().expect("temp dir deletion failed");
|
temp_dir.close().expect("temp dir deletion failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.optimize {
|
|
||||||
O1::default().optimize(input);
|
|
||||||
} else {
|
|
||||||
if matches.simplify_cfg {
|
|
||||||
SimplifyCfg::default().optimize(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
if matches.mem2reg {
|
|
||||||
Mem2reg::default().optimize(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
if matches.deadcode {
|
|
||||||
Deadcode::default().optimize(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
if matches.gvn {
|
|
||||||
Gvn::default().optimize(input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if matches.iroutput {
|
if matches.iroutput {
|
||||||
write(input, output).unwrap();
|
write(input, output).unwrap();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user