From fdb07cbb6b16da35872185e5642faef13dd61094 Mon Sep 17 00:00:00 2001 From: myuon Date: Thu, 21 Sep 2023 00:19:57 +0900 Subject: [PATCH 1/9] refactor: remove raw_offset --- quartz/generator.qz | 6 ------ quartz/ir.qz | 25 +++++++++++++++++-------- quartz/ir_code_gen.qz | 9 --------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/quartz/generator.qz b/quartz/generator.qz index ac289be3..dabeb2d4 100644 --- a/quartz/generator.qz +++ b/quartz/generator.qz @@ -1008,9 +1008,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(); @@ -1060,9 +1057,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(); diff --git a/quartz/ir.qz b/quartz/ir.qz index e7fc1c55..47ec580b 100644 --- a/quartz/ir.qz +++ b/quartz/ir.qz @@ -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, @@ -116,7 +114,9 @@ module IrTerm { }; } - fun find_locals(self): vec[struct { + fun find_locals( + self, + ): vec[struct { name: string, type_: IrType, }] { @@ -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 { @@ -462,7 +465,6 @@ 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(); @@ -470,7 +472,6 @@ module IrTermWriter { 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(); @@ -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(); } } } + diff --git a/quartz/ir_code_gen.qz b/quartz/ir_code_gen.qz index 0c41c27f..063a4321 100644 --- a/quartz/ir_code_gen.qz +++ b/quartz/ir_code_gen.qz @@ -367,7 +367,6 @@ module IrCodeGenerator { offset: IrTerm { t_i32: 0, }, - raw_offset: 0, }, }, }, @@ -713,7 +712,6 @@ module IrCodeGenerator { t_i32: rep_id, }, ), - raw_offset: 0, }, }; body.push(self.assign( @@ -815,7 +813,6 @@ module IrCodeGenerator { t_i32: i, }, ), - raw_offset: 0, }, }; @@ -1603,7 +1600,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") { @@ -2654,7 +2650,6 @@ module IrCodeGenerator { }, ), value: term.term, - raw_offset: 0, }, }; @@ -2825,7 +2820,6 @@ module IrCodeGenerator { }, ), value: elements.at(index), - raw_offset: 0, }, }); } @@ -2866,7 +2860,6 @@ module IrCodeGenerator { type_: IrType::new(elem_type), address: arr, offset: IrCodeGenerator::wrap_mult_sizeof(IrType::new(elem_type), index), - raw_offset: 0, }, }; } @@ -2912,7 +2905,6 @@ module IrCodeGenerator { address: lhs.t_load!.address, offset: lhs.t_load!.offset, value: rhs, - raw_offset: lhs.t_load!.raw_offset, }, }; @@ -2924,7 +2916,6 @@ module IrCodeGenerator { address: lhs, offset: IrTerm::i32(0), value: rhs, - raw_offset: 0, }, }; } From 78fece8368190299e34ed6f86c05784b2de22a2f Mon Sep 17 00:00:00 2001 From: myuon Date: Thu, 21 Sep 2023 01:48:43 +0900 Subject: [PATCH 2/9] ci: add action-tmate --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 02b41cbe..74a5d8c5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,6 +30,9 @@ jobs: - name: Build a compiler run: just build_compiler $(just find_latest_version) current + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + - name: Run the test function run: | MODE=run-wat WAT_FILE=./build/quartz-current.wat cargo run --release -- compile --validate-address --test -o ./build/quartz-compiled.wat ./quartz/main.qz From c72c95055359c958fa3a5b7d4424795150e1f84c Mon Sep 17 00:00:00 2001 From: myuon Date: Thu, 21 Sep 2023 01:49:08 +0900 Subject: [PATCH 3/9] ci: order of steps --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 74a5d8c5..94b83bb8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,12 +27,12 @@ jobs: - name: Install Quartz run: just download $(just find_latest_version) - - name: Build a compiler - run: just build_compiler $(just find_latest_version) current - - name: Setup tmate session uses: mxschmitt/action-tmate@v3 + - name: Build a compiler + run: just build_compiler $(just find_latest_version) current + - name: Run the test function run: | MODE=run-wat WAT_FILE=./build/quartz-current.wat cargo run --release -- compile --validate-address --test -o ./build/quartz-compiled.wat ./quartz/main.qz From 6401e657f084a55daa7d3f8475746e1b771c0c4b Mon Sep 17 00:00:00 2001 From: myuon Date: Thu, 21 Sep 2023 01:58:45 +0900 Subject: [PATCH 4/9] ci: revert --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 94b83bb8..02b41cbe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,9 +27,6 @@ jobs: - name: Install Quartz run: just download $(just find_latest_version) - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - - name: Build a compiler run: just build_compiler $(just find_latest_version) current From a4af37a9237f4d7402fa025cc7773cab9da4c1be Mon Sep 17 00:00:00 2001 From: myuon Date: Thu, 21 Sep 2023 02:02:33 +0900 Subject: [PATCH 5/9] ci: setup upterm session --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 02b41cbe..e684030f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,9 @@ jobs: - name: Install Quartz run: just download $(just find_latest_version) + - name: Setup upterm session + uses: lhotari/action-upterm@v1 + - name: Build a compiler run: just build_compiler $(just find_latest_version) current From 6fd0305e381ba182c45c92339b250b1acff40120 Mon Sep 17 00:00:00 2001 From: myuon Date: Thu, 21 Sep 2023 02:24:59 +0900 Subject: [PATCH 6/9] ci: set fetch-tags=true --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e684030f..ec0d1c80 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-tags: true - uses: dtolnay/rust-toolchain@stable From a699088ac6794e1223c4307dd1b78b3e9ceab7da Mon Sep 17 00:00:00 2001 From: myuon Date: Thu, 21 Sep 2023 02:32:05 +0900 Subject: [PATCH 7/9] ci: fetch-depth=0 --- .github/workflows/test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ec0d1c80..473c547c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-tags: true + fetch-depth: 0 - uses: dtolnay/rust-toolchain@stable @@ -29,9 +29,6 @@ jobs: - name: Install Quartz run: just download $(just find_latest_version) - - name: Setup upterm session - uses: lhotari/action-upterm@v1 - - name: Build a compiler run: just build_compiler $(just find_latest_version) current From 089a62ec1366f4afcfdbf4c0028b3fe3e44eecba Mon Sep 17 00:00:00 2001 From: myuon Date: Thu, 21 Sep 2023 02:37:03 +0900 Subject: [PATCH 8/9] ci: add upterm --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 473c547c..dc408dca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,6 +29,9 @@ jobs: - name: Install Quartz run: just download $(just find_latest_version) + - name: Setup upterm session + uses: lhotari/action-upterm@v1 + - name: Build a compiler run: just build_compiler $(just find_latest_version) current From 1a2aff87baf8ec9ce65dd90ee77cc562b66ae364 Mon Sep 17 00:00:00 2001 From: myuon Date: Thu, 21 Sep 2023 02:53:20 +0900 Subject: [PATCH 9/9] ci: revert --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc408dca..473c547c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,9 +29,6 @@ jobs: - name: Install Quartz run: just download $(just find_latest_version) - - name: Setup upterm session - uses: lhotari/action-upterm@v1 - - name: Build a compiler run: just build_compiler $(just find_latest_version) current