Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sbillig committed Jun 20, 2024
1 parent cec6a13 commit 4ddf5b7
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 101 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ members = [
"crates/ir",
"crates/codegen",
"crates/object",
"crates/parser",
"crates/parser2",
"crates/filecheck",
"crates/triple",
Expand Down
14 changes: 9 additions & 5 deletions crates/codegen/src/critical_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ mod tests {

assert_eq!(
dump_func(func),
"func public %test_func() -> void:
"func public %test_func() -> void {
block0:
br 1.i32 block3 block1;
Expand All @@ -163,6 +163,7 @@ mod tests {
block3:
jump block2;
}
"
);

Expand Down Expand Up @@ -208,7 +209,7 @@ mod tests {

assert_eq!(
dump_func(func),
"func public %test_func() -> void:
"func public %test_func() -> void {
block0:
br 1.i8 block5 block1;
Expand All @@ -230,6 +231,7 @@ mod tests {
block6:
jump block3;
}
"
);

Expand Down Expand Up @@ -269,7 +271,7 @@ mod tests {

assert_eq!(
dump_func(func),
"func public %test_func() -> void:
"func public %test_func() -> void {
block0:
jump block1;
Expand All @@ -284,6 +286,7 @@ mod tests {
block3:
jump block1;
}
"
);

Expand Down Expand Up @@ -331,9 +334,9 @@ mod tests {

assert_eq!(
dump_func(func),
"func public %test_func() -> void:
"func public %test_func() -> void {
block0:
br -1.i1 block5 block6;
br 1.i1 block5 block6;
block1:
br_table 0.i32 block2 (1.i32 block3) (2.i32 block7);
Expand All @@ -356,6 +359,7 @@ mod tests {
block7:
jump block4;
}
"
);

Expand Down
1 change: 0 additions & 1 deletion crates/filecheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ publish = false
filecheck = "0.5.0" # { path = "/Users/sean/src/filecheck" }
sonatina-ir = { path = "../ir" }
sonatina-codegen = { path = "../codegen" }
sonatina-parser = { path = "../parser" }
sonatina-parser2 = { path = "../parser2" }
termcolor = "1.1.2"
walkdir = "2"
10 changes: 2 additions & 8 deletions crates/filecheck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use std::{

use sonatina_ir::{ir_writer::FuncWriter, module::FuncRef, Function};

use sonatina_parser::parser::ParsedModule;
use sonatina_parser2::parse_module2;
use sonatina_parser2::{parse_module, ParsedModule};
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
use walkdir::WalkDir;

Expand Down Expand Up @@ -53,7 +52,6 @@ impl FileCheckRunner {
if ent.file_type().is_file()
&& ent.path().extension().map_or(false, |ext| ext == "sntn")
{
dbg!(ent.path());
Some(ent)
} else {
None
Expand Down Expand Up @@ -121,15 +119,13 @@ pub struct FileChecker<'a> {

impl<'a> FileChecker<'a> {
fn new(transformer: &'a mut dyn FuncTransform, file_path: &'a Path) -> Self {
dbg!(file_path);
Self {
transformer,
file_path,
}
}

fn check(&mut self) -> Vec<FileCheckResult> {
eprintln!("{}", self.file_path.to_string_lossy());
let mut parsed_module = match self.parse_file() {
Ok(module) => module,
Err(msg) => return vec![FileCheckResult::new(self.file_path.to_owned(), Err(msg))],
Expand All @@ -154,8 +150,6 @@ impl<'a> FileChecker<'a> {
self.transformer.transform(func);
let func_ir = FuncWriter::new(func).dump_string().unwrap();

eprintln!("{:?}", self.file_path);
eprintln!("{func_ir}");
let checker = self.build_checker(comments);

let result = match checker.explain(&func_ir, &()) {
Expand All @@ -172,7 +166,7 @@ impl<'a> FileChecker<'a> {
fn parse_file(&self) -> Result<ParsedModule, String> {
let input = fs::read_to_string(self.file_path).unwrap();

match parse_module2(&input) {
match parse_module(&input) {
Ok(module) => Ok(module),
Err(errs) => {
let mut v = vec![];
Expand Down
5 changes: 0 additions & 5 deletions crates/filecheck/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@ use sonatina_filecheck::{
};

fn main() {
eprintln!("SccpTransform");
let mut runner = FileCheckRunner::new(SccpTransform::default());
runner.run();

eprintln!("AdceTransform");
runner.attach_transformer(AdceTransform::default());
runner.run();

eprintln!("InsnSimplifyTransform");
runner.attach_transformer(InsnSimplifyTransform::default());
runner.run();

eprintln!("GvnTransform");
runner.attach_transformer(GvnTransform::default());
runner.run();

eprintln!("LicmTransformer");
runner.attach_transformer(LicmTransformer::default());
runner.run();

Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ cranelift-entity = "0.104"
sonatina-ir = { path = "../ir", version = "0.0.3-alpha" }

[dev-dependencies]
sonatina-parser = { path = "../parser", version = "0.0.3-alpha" }
sonatina-parser2 = { path = "../parser2" }
Loading

0 comments on commit 4ddf5b7

Please sign in to comment.