-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* a case shows that block can have inputs * now block instructions can accept input * tweak * more tests and fix If's evaluation * resolve some TODO and more consistent naming * block can only use the values that it declared to use * fix tidy issues * truncate redundant values when exiting a block * a problematic WIP implementation * leave usage of type use syntax as placeholder * try loop poly * still enable type use syntax, only ignore their index * tweak test case to align new exporting requirement * update test case * remove some line wrappings --------- Co-authored-by: ahuoguo <[email protected]> Co-authored-by: Guannan Wei <[email protected]>
- Loading branch information
1 parent
f295830
commit d13e106
Showing
9 changed files
with
1,213 additions
and
1,040 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
(module | ||
(func $test_block (param i32 i32 i32) (result i32) | ||
local.get 0 | ||
local.get 1 | ||
local.get 2 | ||
block (param i32 i32 i32) (result i32 i32) | ||
i32.add | ||
end | ||
i32.add | ||
) | ||
(func $real_main (result i32) | ||
i32.const 1 | ||
i32.const 3 | ||
i32.const 5 | ||
call $test_block | ||
) | ||
;; Sum from [0, 10] | ||
(func $test_loop_input (result i32) | ||
(local i32) | ||
i32.const 10 | ||
local.set 0 | ||
i32.const 0 | ||
loop (param i32) (result i32) | ||
local.get 0 | ||
i32.add | ||
local.get 0 | ||
i32.const 1 | ||
i32.sub | ||
local.set 0 | ||
i32.const 0 | ||
local.get 0 | ||
i32.ne | ||
br_if 0 | ||
end | ||
) | ||
(func $test_if_input (result i32) | ||
i32.const 10 | ||
i32.const 5 | ||
i32.const 1 | ||
if (param i32 i32) (result i32 i32) | ||
i32.const 10 | ||
i32.add | ||
else | ||
end | ||
i32.add | ||
) | ||
(func $test_poly_br (result i32) | ||
i32.const -30 | ||
i32.const 0 ;; unused | ||
i32.const 0 ;; unused | ||
i32.const 0 ;; unused | ||
block (param i32 i32 i32) (result i32 i32) | ||
i32.const 0 ;; truncated | ||
i32.const 10000 ;; truncated | ||
i32.const 10 | ||
i32.const 20 | ||
br 0 | ||
i32.add | ||
end | ||
i32.add | ||
i32.add ;; add value -30 and 30 | ||
;; i32.add | ||
;; We can't use i32.add instruction here, because the overflowed value has been truncted | ||
;; when block exited. | ||
) | ||
(export "real_main" (func 1)) | ||
(export "test_loop_input" (func 2)) | ||
(export "test_if_input" (func 3)) | ||
(export "test_poly_br" (func 4)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(module | ||
(type (;0;) (func)) | ||
(type (;1;) (func (param i32) (result i32))) | ||
(func $test_poly_loop (;0;) (type 0) | ||
i32.const 42 | ||
i32.const 0 | ||
block (param i32 i32) (result i32 i32) | ||
loop (type 1) (param i32) (result i32) ;; label = @1 | ||
i32.const 1 | ||
i32.const 2 | ||
br 1 (;@1;) | ||
end | ||
end | ||
;; this is not a valid wasm program due to the mismatch of stack shape, | ||
;; we only do this for testing purposes. | ||
;; i32.add | ||
;; drop | ||
) | ||
(start 0) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.