Skip to content

Commit

Permalink
refactor: re-structure the test flow of ir optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Solo-steven committed Sep 15, 2024
1 parent e7a4e71 commit 8e51abc
Show file tree
Hide file tree
Showing 78 changed files with 370 additions and 765 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

10 changes: 0 additions & 10 deletions assets/c/ir_convert/basic_type_expr.c

This file was deleted.

29 changes: 0 additions & 29 deletions assets/c/ir_convert/complex_struct_expr.c

This file was deleted.

13 changes: 0 additions & 13 deletions assets/c/ir_convert/fun-call/call_by_function_pointer.c

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions assets/c/ir_convert/fun-call/struct_type_return_with_pointer.c

This file was deleted.

2 changes: 0 additions & 2 deletions compilers/rustyc/frontend/src/parser/declar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ impl<'a> Parser<'a> {
}
}
_ => {
println!("{:?}, {:?}", value_type, self.get_token());
expect_token!(TokenKind::Semi, self);
ParserResult::Ok(Declaration::ValueType(value_type))
}
Expand Down Expand Up @@ -449,7 +448,6 @@ impl<'a> Parser<'a> {
fn parse_strute_declarator(&mut self) -> ParserResult<StructDeclarator<'a>> {
let mut value_type = self.parse_value_type(None)?;
value_type = self.parse_type_with_pointer_type(value_type);
println!("{:?}", value_type);
let id = match &value_type {
ValueType::FunctionPointer { id, .. } => id.clone(),
_ => self.parse_identifier()?,
Expand Down
6 changes: 1 addition & 5 deletions compilers/rustyc/frontend/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,10 @@ impl<'a> Parser<'a> {
value_type: self.cache_type_name.take(),
designators: self.parse_designator_list()?,
}));
println!("s:{:?}, next_token {:?}", s, self.get_token());
s
}
}
_ => {
println!("{:?}", self.get_token());
ParserResult::Err(String::from("there"))
}
_ => ParserResult::Err(String::from("there")),
}
}
pub(super) fn parse_designator_list(&mut self) -> ParserResult<Vec<Designator<'a>>> {
Expand Down
7 changes: 7 additions & 0 deletions compilers/rustyc/optimizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ edition = "2021"

[dependencies]
rustyc-frontend = {version = "*", path = "../frontend"}
serde = { version ="1.0.193", features = ["derive"] }
serde_json = "1.0.108"

[[test]]
name="rustyc-converter-test-runner"
path='tests/rustyc_converter_test_runner/main.rs'
harness= false
145 changes: 0 additions & 145 deletions compilers/rustyc/optimizer/file.table

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ fn print_out_idom(output: &mut String, table: &DomTable, max_len: usize) {
for (block_id, entry) in table {
idom_map.insert(block_id.clone(), entry.idom);
}
for (block, idom) in idom_map {
let sorted_dom = sort_block_ids(
idom_map
.keys()
.into_iter()
.map(|id| id.clone())
.collect::<Vec<_>>(),
);
for block in sorted_dom {
let idom = idom_map.get(&block).unwrap();
output.push_str(format!("| Block id: {} | BB{} |\n", block.0, idom.0).as_str());
output.push_str(print_divider(max_len).as_str());
}
Expand Down Expand Up @@ -80,7 +88,7 @@ generate_print_out_dom_set!(print_out_df, dom_frontier, "DF");
generate_print_out_dom_set!(print_out_dom_children, dom_tree_children, "Dom-Children");

impl DebuggerAnaylsis<DomTable> for DomAnaylsier {
fn debugger(function: &Function, table: &DomTable) -> String {
fn debugger(&mut self, function: &Function, table: &DomTable) -> String {
let max_id_len = get_max_block_id_len(function);
let row_header_len = " Block id: ".len() + max_id_len;
let row_body_len = " BB ".len() + max_id_len;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ pub trait OptimizerAnaylsis<T> {
}

pub trait DebuggerAnaylsis<T> {
fn debugger(function: &Function, table: &T) -> String;
fn debugger(&mut self, function: &Function, table: &T) -> String;
}
2 changes: 1 addition & 1 deletion compilers/rustyc/optimizer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() {
let mut func = create_gvn_graph_from_conrnell();
let mut dom_anaylsis = DomAnaylsier::new();
let table = dom_anaylsis.anaylsis(&func);
let out = DomAnaylsier::debugger(&func, &table);
let out = dom_anaylsis.debugger(&func, &table);
// let mut lcm_pass = LCMPass::new();
// lcm_pass.process(&mut func);
// let mut file = File::create("./test1.txt").unwrap();
Expand Down
Loading

0 comments on commit 8e51abc

Please sign in to comment.