Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor pass infra #36

Merged
merged 9 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions scripts/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,18 @@ def dfs(curr_dir: str):
log_path = os.path.join(output_dir, f"{basename}.log")
log_file = open(log_path, "w")

command = (
f"clang --target=riscv64 -march=rv64imafdc_zba_zbb -w -xc -O3 -S {testcase}.sy"
f" -o {clang_asm_path}"
)

exec_result = execute(command, exec_timeout)
log(log_file, command, exec_result)

if exec_result["returncode"] is None or exec_result["stderr"] != "":
result_md_table += f"| `{testcase}` | 😢 CE |\n"
print(f"\033[33m[ ERROR ] (clang CE)\033[0m {testcase}, see: ", log_path)
continue
# command = (
# f"clang --target=riscv64 -march=rv64imafdc_zba_zbb -w -xc -Wno-implicit-function-declaration -O3 -S {testcase}.sy"
# f" -o {clang_asm_path}"
# )

# exec_result = execute(command, exec_timeout)
# log(log_file, command, exec_result)

# if exec_result["returncode"] is None or exec_result["stderr"] != "":
# result_md_table += f"| `{testcase}` | 😢 CE |\n"
# print(f"\033[33m[ ERROR ] (clang CE)\033[0m {testcase}, see: ", log_path)
# continue

command = (
f"{executable_path} -S "
Expand Down
10 changes: 7 additions & 3 deletions src/backend/riscv64/peephole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,18 +1035,22 @@ pub fn remove_redundant_labels(mctx: &mut MContext<RvInst>) -> bool {
changed
}

pub fn run_peephole(mctx: &mut MContext<RvInst>, config: &LowerConfig) -> bool {
pub fn run_peephole(mctx: &mut MContext<RvInst>, config: &LowerConfig, aggressive: bool) -> bool {
let mut runner1 = PeepholeRunner::new();
let mut runner2 = PeepholeRunner::new();
let mut runner3 = PeepholeRunner::new();

runner1.add_rule(li_dce());
runner1.add_rule(remove_identity_move());
runner1.add_rule(remove_redundant_move());
runner1.add_rule(remove_redundant_move_word()); // aggressive
if aggressive {
runner1.add_rule(remove_redundant_move_word());
}

runner2.add_rule(fuse_cmp_br());
runner2.add_rule(fuse_fmul_faddfsub()); // aggressive
if aggressive {
runner2.add_rule(fuse_fmul_faddfsub());
}
runner2.add_rule(fuse_sub_br());

runner3.add_rule(fuse_xori_cmp_br());
Expand Down
10 changes: 2 additions & 8 deletions src/backend/riscv64/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ use std::{

use super::inst::{AluOpRRR, FpuOpRR, FpuOpRRR, FpuOpRRRR, RvInst, RvInstKind};
use crate::{
backend::{
inst::{DisplayMInst, MInst},
LowerConfig,
MBlock,
MContext,
MFunc,
},
backend::{inst::MInst, LowerConfig, MBlock, MContext, MFunc},
collections::linked_list::{LinkedListContainerPtr, LinkedListNodePtr},
};

Expand Down Expand Up @@ -882,7 +876,7 @@ fn shedule_chunk(mctx: &mut MContext<RvInst>, start: RvInst, end: RvInst, config
s += 1;
}

println!("scheduling: {}, s: {}", n.display(mctx), s);
// println!("scheduling: {}, s: {}", n.display(mctx), s);

scheduled.insert(n, s);

Expand Down
Loading
Loading