Skip to content

Commit

Permalink
Merge branch 'main' into issue-122
Browse files Browse the repository at this point in the history
  • Loading branch information
myuon authored Sep 24, 2023
2 parents 802b4bc + 2d759b9 commit 24d49ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: dtolnay/rust-toolchain@stable

Expand Down
6 changes: 0 additions & 6 deletions quartz/generator.qz
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,6 @@ module Generator {

self.new_statement();
self.write(format("{}.load{}", Value::wasm_type(), suffix));
if expr.t_load!.raw_offset != 0 {
self.write("offset={}".format(expr.t_load!.raw_offset.to_string()));
}

if expr.t_load!.type_.t_byte != nil {
self.new_statement();
Expand Down Expand Up @@ -1054,9 +1051,6 @@ module Generator {

self.new_statement();
self.write(format("i64.store{}", suffix));
if expr.t_store!.raw_offset != 0 {
self.write("offset={}".format(expr.t_store!.raw_offset.to_string()));
}
} else if expr.t_sizeof != nil {
let size = expr.t_sizeof!.type_.sizeof();

Expand Down
25 changes: 17 additions & 8 deletions quartz/ir.qz
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ enum IrTerm {
address: IrTerm,
offset: IrTerm,
value: IrTerm,
raw_offset: i32,
},
t_load: struct {
type_: IrType,
address: IrTerm,
offset: IrTerm,
raw_offset: i32,
},
t_sizeof: struct {
type_: IrType,
Expand Down Expand Up @@ -116,7 +114,9 @@ module IrTerm {
};
}

fun find_locals(self): vec[struct {
fun find_locals(
self,
): vec[struct {
name: string,
type_: IrType,
}] {
Expand Down Expand Up @@ -417,7 +417,10 @@ module IrTermWriter {
self.end();
} else if term.t_global_let != nil {
self.start();
self.write("global-let ${} {}".format(term.t_global_let!.name, term.t_global_let!.type_.to_string()));
self.write("global-let ${} {}".format(
term.t_global_let!.name,
term.t_global_let!.type_.to_string(),
));
self.expression(term.t_global_let!.value);
self.end();
} else if term.t_module != nil {
Expand Down Expand Up @@ -462,15 +465,13 @@ module IrTermWriter {
self.expression(term.t_store!.address);
self.expression(term.t_store!.offset);
self.expression(term.t_store!.value);
self.write(term.t_store!.raw_offset.to_string());
self.end();
} else if term.t_load != nil {
self.start();
self.write("load");
self.write(term.t_load!.type_.to_string());
self.expression(term.t_load!.address);
self.expression(term.t_load!.offset);
self.write(term.t_load!.raw_offset.to_string());
self.end();
} else if term.t_sizeof != nil {
self.start();
Expand Down Expand Up @@ -555,12 +556,20 @@ module IrTermWriter {
self.start();
self.write("params");
for param in term.t_wasm_func!.params {
self.write("(param ${} {} {})".format(param.name, param.quartz_type.to_string(), param.wasm_type));
self.write("(param ${} {} {})".format(
param.name,
param.quartz_type.to_string(),
param.wasm_type,
));
}
self.write("(result ${} {})".format(term.t_wasm_func!.result_type.quartz_type.to_string(), term.t_wasm_func!.result_type.wasm_type));
self.write("(result ${} {})".format(
term.t_wasm_func!.result_type.quartz_type.to_string(),
term.t_wasm_func!.result_type.wasm_type,
));
self.end();

self.end();
}
}
}

9 changes: 0 additions & 9 deletions quartz/ir_code_gen.qz
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ module IrCodeGenerator {
offset: IrTerm {
t_i32: 0,
},
raw_offset: 0,
},
},
},
Expand Down Expand Up @@ -699,7 +698,6 @@ module IrCodeGenerator {
t_i32: rep_id,
},
),
raw_offset: 0,
},
};
body.push(self.assign(
Expand Down Expand Up @@ -801,7 +799,6 @@ module IrCodeGenerator {
t_i32: i,
},
),
raw_offset: 0,
},
};

Expand Down Expand Up @@ -1589,7 +1586,6 @@ module IrCodeGenerator {
type_: IrType::new(t_ptr_elem),
address: term,
offset: IrCodeGenerator::wrap_mult_sizeof(IrType::new(t_ptr_elem), offset),
raw_offset: 0,
},
};
} else if project.type_!.t_ptr != nil && project.field.data.equal("offset") {
Expand Down Expand Up @@ -2640,7 +2636,6 @@ module IrCodeGenerator {
},
),
value: term.term,
raw_offset: 0,
},
};

Expand Down Expand Up @@ -2811,7 +2806,6 @@ module IrCodeGenerator {
},
),
value: elements.at(index),
raw_offset: 0,
},
});
}
Expand Down Expand Up @@ -2852,7 +2846,6 @@ module IrCodeGenerator {
type_: IrType::new(elem_type),
address: arr,
offset: IrCodeGenerator::wrap_mult_sizeof(IrType::new(elem_type), index),
raw_offset: 0,
},
};
}
Expand Down Expand Up @@ -2898,7 +2891,6 @@ module IrCodeGenerator {
address: lhs.t_load!.address,
offset: lhs.t_load!.offset,
value: rhs,
raw_offset: lhs.t_load!.raw_offset,
},
};

Expand All @@ -2910,7 +2902,6 @@ module IrCodeGenerator {
address: lhs,
offset: IrTerm::i32(0),
value: rhs,
raw_offset: 0,
},
};
}
Expand Down

0 comments on commit 24d49ba

Please sign in to comment.