From b18d4eaf83ff5488c4ce06d28d1823d7eebc21a2 Mon Sep 17 00:00:00 2001 From: Zhicheng HUI Date: Tue, 27 Aug 2024 10:29:15 +0200 Subject: [PATCH] add block type tests and promote --- example/opt/README.md | 1 - example/wasm2wat/README.md | 1 - test/fmt/print.t | 2 -- test/fmt/script.t | 3 --- test/opt/binop.t | 1 - test/opt/block_loop.t | 1 - test/opt/br.t | 1 - test/opt/convert.t | 1 - test/opt/debug.t | 1 - test/opt/demote_promote.t | 1 - test/opt/drop.t | 1 - test/opt/extend_wrap.t | 1 - test/opt/fbinop.t | 1 - test/opt/ibinop.t | 1 - test/opt/if.t | 2 -- test/opt/local.t | 1 - test/opt/ref_nop.t | 1 - test/opt/reinterpret.t | 1 - test/opt/relop_testop.t | 1 - test/opt/return.t | 2 -- test/opt/select.t | 1 - test/opt/tee.t | 1 - test/opt/trunc.t | 1 - test/opt/unop.t | 1 - test/wasm2wat/done.t | 2 -- test/wasm2wat/emit.t | 2 -- test/wasm2wat/locals.t | 2 -- test/wasm2wat/locals_drop.t | 2 -- test/wasm2wat/print.t | 2 -- test/wat2wasm/block_type1.t | 16 ++++++++++++++++ test/wat2wasm/block_type1.wat | 11 +++++++++++ test/wat2wasm/block_type2.t | 26 ++++++++++++++++++++++++++ test/wat2wasm/block_type2.wat | 21 +++++++++++++++++++++ test/wat2wasm/call_indirect.t | 2 -- test/wat2wasm/cmd_conc.t | 2 -- test/wat2wasm/cmd_sym.t | 2 -- test/wat2wasm/dune | 2 ++ test/wat2wasm/func.t | 2 -- test/wat2wasm/globals.t | 1 - test/wat2wasm/loop.t | 3 --- test/wat2wasm/mem.t | 5 ----- test/wat2wasm/rec.t | 2 -- 42 files changed, 76 insertions(+), 58 deletions(-) create mode 100644 test/wat2wasm/block_type1.t create mode 100644 test/wat2wasm/block_type1.wat create mode 100644 test/wat2wasm/block_type2.t create mode 100644 test/wat2wasm/block_type2.wat diff --git a/example/opt/README.md b/example/opt/README.md index 3e99ce29a..501b3150d 100644 --- a/example/opt/README.md +++ b/example/opt/README.md @@ -339,7 +339,6 @@ Owi is able to get rid of most of the code: ```sh $ owi opt useless.wat (module - (type (sub final (func))) (func $i32binop diff --git a/example/wasm2wat/README.md b/example/wasm2wat/README.md index 655f7ebc0..16ff8efd7 100644 --- a/example/wasm2wat/README.md +++ b/example/wasm2wat/README.md @@ -7,7 +7,6 @@ Given a file `42.wasm`: ```sh $ owi wasm2wat ./42.wasm (module - (type (sub final (func))) (func i32.const 20 diff --git a/test/fmt/print.t b/test/fmt/print.t index 0b8d75e39..02315233c 100644 --- a/test/fmt/print.t +++ b/test/fmt/print.t @@ -17,9 +17,7 @@ print symbolic: print simplified: $ dune exec -- ./print_simplified.exe m.wat (module - (type (sub final (func (param $x i32) (param $y i32) (result i32)))) - (type (sub final (func))) (func $f (param $x i32) (param $y i32) (result i32) local.get 0 diff --git a/test/fmt/script.t b/test/fmt/script.t index 99f54792d..75a213da0 100644 --- a/test/fmt/script.t +++ b/test/fmt/script.t @@ -697,7 +697,6 @@ print script: (func $f (param i32) (result i32) local.get 0 ) - (type $sig (sub final (func (param i32) (result i32)))) (table 1 1 (ref null func)) (elem (offset i32.const 0) (ref null func) (item ref.func $f)) @@ -1075,7 +1074,6 @@ print script: (func $f (param i32) (result i32) local.get 0 ) - (type $sig (sub final (func (param i32) (result i32)))) (table 1 1 (ref null func)) (elem (offset i32.const 0) (ref null func) (item ref.func $f)) @@ -1094,7 +1092,6 @@ print script: (func $f (param i32) (result i32) local.get 0 ) - (type $sig (sub final (func (param i32) (result i32)))) (table 1 1 (ref null func)) (elem (offset i32.const 0) (ref null func) (item ref.func $f)) diff --git a/test/opt/binop.t b/test/opt/binop.t index 25b55a21f..26804eb26 100644 --- a/test/opt/binop.t +++ b/test/opt/binop.t @@ -2,7 +2,6 @@ binary operations instructions: $ owi opt binop.wat > binop.opt.wat $ cat binop.opt.wat (module - (type (sub final (func))) (func $i32binop diff --git a/test/opt/block_loop.t b/test/opt/block_loop.t index 884d40af9..1d6438b8a 100644 --- a/test/opt/block_loop.t +++ b/test/opt/block_loop.t @@ -2,7 +2,6 @@ block loop instructions: $ owi opt block_loop.wat > block_loop.opt.wat $ cat block_loop.opt.wat (module - (type (sub final (func))) (func $start diff --git a/test/opt/br.t b/test/opt/br.t index f1e207f7d..d9d7bc921 100644 --- a/test/opt/br.t +++ b/test/opt/br.t @@ -2,7 +2,6 @@ br instructions: $ owi opt br.wat > br.opt.wat $ cat br.opt.wat (module - (type (sub final (func))) (func $br i32.const 42 diff --git a/test/opt/convert.t b/test/opt/convert.t index 6def7405d..1318b8b69 100644 --- a/test/opt/convert.t +++ b/test/opt/convert.t @@ -2,7 +2,6 @@ f**.convert_i** instructions: $ owi opt convert.wat > convert.opt.wat $ cat convert.opt.wat (module - (type (sub final (func))) (func $start diff --git a/test/opt/debug.t b/test/opt/debug.t index be822f59b..f8724e722 100644 --- a/test/opt/debug.t +++ b/test/opt/debug.t @@ -8,7 +8,6 @@ test debug printing: typechecking ... optimizing ... (module - (type (sub final (func))) (global $g i32 i32.const 0) (func $start diff --git a/test/opt/demote_promote.t b/test/opt/demote_promote.t index b12061425..048eb4eb5 100644 --- a/test/opt/demote_promote.t +++ b/test/opt/demote_promote.t @@ -2,7 +2,6 @@ f32.demote_f64 f64.promote_f32 instructions: $ owi opt demote_promote.wat > demote_promote.opt.wat $ cat demote_promote.opt.wat (module - (type (sub final (func))) (func $start diff --git a/test/opt/drop.t b/test/opt/drop.t index 1a5e2eca7..bdb97b91e 100644 --- a/test/opt/drop.t +++ b/test/opt/drop.t @@ -2,7 +2,6 @@ drop instruction: $ owi opt drop.wat > drop.opt.wat $ cat drop.opt.wat (module - (type (sub final (func))) (global $g i32 i32.const 0) (func $start diff --git a/test/opt/extend_wrap.t b/test/opt/extend_wrap.t index 0c706d8b2..206dfe8f8 100644 --- a/test/opt/extend_wrap.t +++ b/test/opt/extend_wrap.t @@ -2,7 +2,6 @@ i**.extend_** i32.wrap_i64 instructions: $ owi opt extend_wrap.wat > extend_wrap.opt.wat $ cat extend_wrap.opt.wat (module - (type (sub final (func))) (func $extend diff --git a/test/opt/fbinop.t b/test/opt/fbinop.t index c80c0b11b..49f2056eb 100644 --- a/test/opt/fbinop.t +++ b/test/opt/fbinop.t @@ -2,7 +2,6 @@ f32 / f64 binary operations: $ owi opt fbinop.wat > fbinop.opt.wat $ cat fbinop.opt.wat (module - (type (sub final (func))) (func $start diff --git a/test/opt/ibinop.t b/test/opt/ibinop.t index 137ed1723..878f313b6 100644 --- a/test/opt/ibinop.t +++ b/test/opt/ibinop.t @@ -2,7 +2,6 @@ i32 / i64 binary operations: $ owi opt ibinop.wat > ibinop.opt.wat $ cat ibinop.opt.wat (module - (type (sub final (func))) (func $start diff --git a/test/opt/if.t b/test/opt/if.t index a7a76dd9e..7b87c4203 100644 --- a/test/opt/if.t +++ b/test/opt/if.t @@ -2,9 +2,7 @@ if then else instruction: $ owi opt if.wat > if.opt.wat $ cat if.opt.wat (module - (type (sub final (func))) - (type (sub final (func (result i32)))) (func $start (block (result i32) diff --git a/test/opt/local.t b/test/opt/local.t index b96d9c531..23ce6b435 100644 --- a/test/opt/local.t +++ b/test/opt/local.t @@ -2,7 +2,6 @@ unused local variables: $ owi opt local.wat > local.opt.wat $ cat local.opt.wat (module - (type (sub final (func))) (func $f0 (local i32) i32.const 0 diff --git a/test/opt/ref_nop.t b/test/opt/ref_nop.t index 065c973a8..273e478d9 100644 --- a/test/opt/ref_nop.t +++ b/test/opt/ref_nop.t @@ -2,7 +2,6 @@ ref.null ref.is_null nop instructions: $ owi opt ref_nop.wat > ref_nop.opt.wat $ cat ref_nop.opt.wat (module - (type (sub final (func))) (func $start diff --git a/test/opt/reinterpret.t b/test/opt/reinterpret.t index ca5f711b9..cf90b6a76 100644 --- a/test/opt/reinterpret.t +++ b/test/opt/reinterpret.t @@ -2,7 +2,6 @@ f**.reinterpret_i** i**.reinterpret_f** instructions: $ owi opt reinterpret.wat > reinterpret.opt.wat $ cat reinterpret.opt.wat (module - (type (sub final (func))) (func $start diff --git a/test/opt/relop_testop.t b/test/opt/relop_testop.t index 1d9ee1d2a..a6921708c 100644 --- a/test/opt/relop_testop.t +++ b/test/opt/relop_testop.t @@ -2,7 +2,6 @@ $ owi opt relop_testop.wat > relop_testop.opt.wat $ cat relop_testop.opt.wat (module - (type (sub final (func))) (func $i32relop diff --git a/test/opt/return.t b/test/opt/return.t index 70d9969d1..4de77cd62 100644 --- a/test/opt/return.t +++ b/test/opt/return.t @@ -2,9 +2,7 @@ return instructions: $ owi opt return.wat > return.opt.wat $ cat return.opt.wat (module - (type (sub final (func (result i32)))) - (type (sub final (func))) (table $tab 1 1 (ref null func)) (func $return (result i32) diff --git a/test/opt/select.t b/test/opt/select.t index 8af957676..f03c920a8 100644 --- a/test/opt/select.t +++ b/test/opt/select.t @@ -2,7 +2,6 @@ select instruction: $ owi opt select.wat > select.opt.wat $ cat select.opt.wat (module - (type (sub final (func))) (func $start diff --git a/test/opt/tee.t b/test/opt/tee.t index aff865e69..a7ed45d07 100644 --- a/test/opt/tee.t +++ b/test/opt/tee.t @@ -2,7 +2,6 @@ set get tee simplification: $ owi opt tee.wat > tee.opt.wat $ cat tee.opt.wat (module - (type (sub final (func))) (func $start (local $x i32) i32.const 41 diff --git a/test/opt/trunc.t b/test/opt/trunc.t index 6ebadfee1..76f24bf9c 100644 --- a/test/opt/trunc.t +++ b/test/opt/trunc.t @@ -2,7 +2,6 @@ $ owi opt trunc.wat > trunc.opt.wat $ cat trunc.opt.wat (module - (type (sub final (func))) (func $trunc diff --git a/test/opt/unop.t b/test/opt/unop.t index 5395c9c20..168701d83 100644 --- a/test/opt/unop.t +++ b/test/opt/unop.t @@ -2,7 +2,6 @@ unop () instructions: $ owi opt unop.wat > unop.opt.wat $ cat unop.opt.wat (module - (type (sub final (func))) (func $iunop diff --git a/test/wasm2wat/done.t b/test/wasm2wat/done.t index 4b154995b..c94eeb281 100644 --- a/test/wasm2wat/done.t +++ b/test/wasm2wat/done.t @@ -1,8 +1,6 @@ $ owi wasm2wat done.wasm (module - (type (sub final (func (param i32) (param i32) (result i32)))) - (type (sub final (func))) (func (param i32) (param i32) (result i32) local.get 0 diff --git a/test/wasm2wat/emit.t b/test/wasm2wat/emit.t index 1783c8452..ffe169a48 100644 --- a/test/wasm2wat/emit.t +++ b/test/wasm2wat/emit.t @@ -2,9 +2,7 @@ test that we can emit to a file: $ owi wasm2wat m.wasm --emit-file $ cat m.wat (module - (type (sub final (func (param i32) (param i32) (result i32)))) - (type (sub final (func))) (func (param i32) (param i32) (result i32) local.get 0 diff --git a/test/wasm2wat/locals.t b/test/wasm2wat/locals.t index 5e4328487..047a60c85 100644 --- a/test/wasm2wat/locals.t +++ b/test/wasm2wat/locals.t @@ -1,8 +1,6 @@ $ owi wasm2wat locals.wasm (module - (type (sub final (func (param i32) (param i32) (param i32)))) - (type (sub final (func))) (func (param i32) (param i32) (param i32) (local i32) (local i32) local.get 3 diff --git a/test/wasm2wat/locals_drop.t b/test/wasm2wat/locals_drop.t index 02d999c5d..0d2bb0233 100644 --- a/test/wasm2wat/locals_drop.t +++ b/test/wasm2wat/locals_drop.t @@ -1,8 +1,6 @@ $ owi wasm2wat locals_drop.wasm (module - (type (sub final (func (param i32) (param i32) (param i32)))) - (type (sub final (func))) (func (param i32) (param i32) (param i32) (local i32) (local i32) local.get 3 diff --git a/test/wasm2wat/print.t b/test/wasm2wat/print.t index bc44a97fc..8fe73c3bb 100644 --- a/test/wasm2wat/print.t +++ b/test/wasm2wat/print.t @@ -1,9 +1,7 @@ print symbolic: $ owi wasm2wat m.wasm (module - (type (sub final (func (param i32) (param i32) (result i32)))) - (type (sub final (func))) (func (param i32) (param i32) (result i32) local.get 0 diff --git a/test/wat2wasm/block_type1.t b/test/wat2wasm/block_type1.t new file mode 100644 index 000000000..2d2aa0349 --- /dev/null +++ b/test/wat2wasm/block_type1.t @@ -0,0 +1,16 @@ + $ owi wat2wasm block_type1.wat + $ owi wasm2wat block_type1.wasm + (module + (type (sub final (func))) + (type (sub final (func (param i32) (result i32)))) + (func + i32.const 1 + (block (param i32) (result i32) + i32.const 1 + i32.add) + drop + ) + (start 0) + ) + $ owi sym block_type1.wasm + All OK diff --git a/test/wat2wasm/block_type1.wat b/test/wat2wasm/block_type1.wat new file mode 100644 index 000000000..fb7a0461b --- /dev/null +++ b/test/wat2wasm/block_type1.wat @@ -0,0 +1,11 @@ +(module + (func + i32.const 1 + (block (param i32) (result i32) + i32.const 1 + i32.add + ) + drop + ) + (start 0) +) diff --git a/test/wat2wasm/block_type2.t b/test/wat2wasm/block_type2.t new file mode 100644 index 000000000..7fd1ccfa9 --- /dev/null +++ b/test/wat2wasm/block_type2.t @@ -0,0 +1,26 @@ + $ owi wat2wasm block_type2.wat + $ owi wasm2wat block_type2.wasm + (module + (type (sub final (func (result i32)))) + (type (sub final (func (param i32) (result i32)))) + (type (sub final (func))) + (func (result i32) (local i32) + i32.const 0 + local.tee 0 + (loop (param i32) (result i32) + i32.const 1 + i32.add + local.tee 0 + local.get 0 + i32.const 10 + i32.le_s + br_if 0) + ) + (func + call 0 + drop + ) + (start 1) + ) + $ owi sym block_type2.wasm + All OK diff --git a/test/wat2wasm/block_type2.wat b/test/wat2wasm/block_type2.wat new file mode 100644 index 000000000..e06ba4023 --- /dev/null +++ b/test/wat2wasm/block_type2.wat @@ -0,0 +1,21 @@ +(module + (func (result i32) + (local i32) + i32.const 0 + local.tee 0 + (loop (param i32) (result i32) + i32.const 1 + i32.add + local.tee 0 + local.get 0 + i32.const 10 + i32.le_s + br_if 0 + ) + ) + (func + call 0 + drop + ) + (start 1) +) diff --git a/test/wat2wasm/call_indirect.t b/test/wat2wasm/call_indirect.t index f68677f75..08721ffd2 100644 --- a/test/wat2wasm/call_indirect.t +++ b/test/wat2wasm/call_indirect.t @@ -37,9 +37,7 @@ stack : [ ] $ owi wasm2wat call_indirect.wasm (module - (type (sub final (func (param i64) (result i64)))) - (type (sub final (func))) (table 1 10 (ref null func)) (func (param i64) (result i64) diff --git a/test/wat2wasm/cmd_conc.t b/test/wat2wasm/cmd_conc.t index 88d880fd4..d520a94f3 100644 --- a/test/wat2wasm/cmd_conc.t +++ b/test/wat2wasm/cmd_conc.t @@ -9,9 +9,7 @@ $ owi wasm2wat symbolic.wasm (module (import "symbolic" "i32_symbol" (func (result i32))) - (type (sub final (func (result i32)))) - (type (sub final (func))) (func (local i32) call 0 diff --git a/test/wat2wasm/cmd_sym.t b/test/wat2wasm/cmd_sym.t index 01e34ffd5..c1b334620 100644 --- a/test/wat2wasm/cmd_sym.t +++ b/test/wat2wasm/cmd_sym.t @@ -9,9 +9,7 @@ $ owi wasm2wat symbolic.wasm (module (import "symbolic" "i32_symbol" (func (result i32))) - (type (sub final (func (result i32)))) - (type (sub final (func))) (func (local i32) call 0 diff --git a/test/wat2wasm/dune b/test/wat2wasm/dune index d303e2189..b0572686f 100644 --- a/test/wat2wasm/dune +++ b/test/wat2wasm/dune @@ -2,6 +2,8 @@ (deps %{bin:owi} bad.ext + block_type1.wat + block_type2.wat call_indirect.wat func.wat globals.wat diff --git a/test/wat2wasm/func.t b/test/wat2wasm/func.t index 06e141867..020146768 100644 --- a/test/wat2wasm/func.t +++ b/test/wat2wasm/func.t @@ -26,9 +26,7 @@ stack : [ ] $ owi wasm2wat func.wasm (module - (type (sub final (func (param f32) (result f32)))) - (type (sub final (func))) (func (param f32) (result f32) (local f32) f32.const 2.019_999_980_926_513_7 diff --git a/test/wat2wasm/globals.t b/test/wat2wasm/globals.t index 5218a1e75..2b838aa25 100644 --- a/test/wat2wasm/globals.t +++ b/test/wat2wasm/globals.t @@ -22,7 +22,6 @@ stack : [ ] $ owi wasm2wat globals.wasm (module - (type (sub final (func))) (global i32 i32.const 42) (global (mut i64) i64.const 2) diff --git a/test/wat2wasm/loop.t b/test/wat2wasm/loop.t index 5028eafd0..93fb655e2 100644 --- a/test/wat2wasm/loop.t +++ b/test/wat2wasm/loop.t @@ -112,11 +112,8 @@ stack : [ ] $ owi wasm2wat loop.wasm (module - (type (sub final (func (param i32) (result i64)))) - (type (sub final (func (result i64)))) - (type (sub final (func))) (func (param i32) (result i64) (local i32) i32.const 0 diff --git a/test/wat2wasm/mem.t b/test/wat2wasm/mem.t index 5aa5d59f6..7e8548a58 100644 --- a/test/wat2wasm/mem.t +++ b/test/wat2wasm/mem.t @@ -2,15 +2,10 @@ $ owi run mem.wasm $ owi wasm2wat mem.wasm (module - (type (sub final (func))) - (type (sub final (func (param i32) (param i32)))) - (type (sub final (func (param i32) (param i64)))) - (type (sub final (func (param i32) (param f32)))) - (type (sub final (func (param i32) (param f64)))) (memory 1) (func diff --git a/test/wat2wasm/rec.t b/test/wat2wasm/rec.t index fc9b47c80..f225d885c 100644 --- a/test/wat2wasm/rec.t +++ b/test/wat2wasm/rec.t @@ -2,9 +2,7 @@ $ owi run rec.wasm $ owi wasm2wat rec.wasm (module - (type (sub final (func (param i32) (result i32)))) - (type (sub final (func))) (memory 1) (func (param i32) (result i32)