Skip to content

Commit

Permalink
add block type tests and promote
Browse files Browse the repository at this point in the history
  • Loading branch information
Laplace-Demon authored and zapashcanon committed Aug 27, 2024
1 parent 26eb8e9 commit 132995e
Show file tree
Hide file tree
Showing 42 changed files with 76 additions and 58 deletions.
1 change: 0 additions & 1 deletion example/opt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion example/wasm2wat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Given a file `42.wasm`:
```sh
$ owi wasm2wat ./42.wasm
(module

(type (sub final (func)))
(func
i32.const 20
Expand Down
2 changes: 0 additions & 2 deletions test/fmt/print.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions test/fmt/script.t
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down
1 change: 0 additions & 1 deletion test/opt/binop.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion test/opt/block_loop.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion test/opt/br.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/opt/convert.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion test/opt/debug.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ test debug printing:
typechecking ...
optimizing ...
(module

(type (sub final (func)))
(global $g i32 i32.const 0)
(func $start
Expand Down
1 change: 0 additions & 1 deletion test/opt/demote_promote.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion test/opt/drop.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/opt/extend_wrap.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion test/opt/fbinop.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion test/opt/ibinop.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions test/opt/if.t
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion test/opt/local.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/opt/ref_nop.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion test/opt/reinterpret.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion test/opt/relop_testop.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions test/opt/return.t
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion test/opt/select.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ select instruction:
$ owi opt select.wat > select.opt.wat
$ cat select.opt.wat
(module

(type (sub final (func)))
(func $start

Expand Down
1 change: 0 additions & 1 deletion test/opt/tee.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/opt/trunc.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
$ owi opt trunc.wat > trunc.opt.wat
$ cat trunc.opt.wat
(module

(type (sub final (func)))
(func $trunc

Expand Down
1 change: 0 additions & 1 deletion test/opt/unop.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ unop () instructions:
$ owi opt unop.wat > unop.opt.wat
$ cat unop.opt.wat
(module

(type (sub final (func)))
(func $iunop

Expand Down
2 changes: 0 additions & 2 deletions test/wasm2wat/done.t
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/wasm2wat/emit.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/wasm2wat/locals.t
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/wasm2wat/locals_drop.t
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/wasm2wat/print.t
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 16 additions & 0 deletions test/wat2wasm/block_type1.t
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions test/wat2wasm/block_type1.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(module
(func
i32.const 1
(block (param i32) (result i32)
i32.const 1
i32.add
)
drop
)
(start 0)
)
26 changes: 26 additions & 0 deletions test/wat2wasm/block_type2.t
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions test/wat2wasm/block_type2.wat
Original file line number Diff line number Diff line change
@@ -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)
)
2 changes: 0 additions & 2 deletions test/wat2wasm/call_indirect.t
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions test/wat2wasm/cmd_conc.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/wat2wasm/cmd_sym.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/wat2wasm/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
(deps
%{bin:owi}
bad.ext
block_type1.wat
block_type2.wat
call_indirect.wat
func.wat
globals.wat
Expand Down
2 changes: 0 additions & 2 deletions test/wat2wasm/func.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/wat2wasm/globals.t
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 132995e

Please sign in to comment.