-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
276: Single-pass native code generation for x86-64 using dynasm. r=lachlansneff a=losfair Co-authored-by: losfair <zhy20000919@hotmail.com>
- Loading branch information
Showing
39 changed files
with
6,867 additions
and
66 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,37 @@ | ||
(module | ||
(func $main (export "main") | ||
(i32.eq (call $test (i32.const 0)) (i32.const 2)) | ||
(i32.eq (call $test (i32.const 1)) (i32.const 0)) | ||
(i32.eq (call $test (i32.const 2)) (i32.const 1)) | ||
(i32.eq (call $test (i32.const 3)) (i32.const 3)) | ||
(i32.eq (call $test (i32.const 4)) (i32.const 3)) | ||
(i32.and) | ||
(i32.and) | ||
(i32.and) | ||
(i32.and) | ||
(i32.const 1) | ||
(i32.eq) | ||
(br_if 0) | ||
(unreachable) | ||
) | ||
|
||
(func $test (param $p i32) (result i32) | ||
(block | ||
(block | ||
(block | ||
(block | ||
(block | ||
(get_local $p) | ||
(br_table 2 0 1 3) | ||
) | ||
(return (i32.const 0)) | ||
) | ||
(return (i32.const 1)) | ||
) | ||
(return (i32.const 2)) | ||
) | ||
(return (i32.const 3)) | ||
) | ||
(unreachable) | ||
) | ||
) |
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,23 @@ | ||
(module | ||
(func $main (export "main") | ||
(local $a i32) | ||
(block | ||
(set_local $a (i32.const 33)) | ||
(i32.const 11) | ||
(call $foo (get_local $a)) | ||
(i32.add) | ||
(i32.const 86) | ||
(i32.eq) | ||
(br_if 0) | ||
(unreachable) | ||
) | ||
) | ||
|
||
(func $foo (param $input i32) (result i32) | ||
(local $a i32) | ||
(set_local $a (i32.const 42)) | ||
(get_local $a) | ||
(get_local $input) | ||
(i32.add) | ||
) | ||
) |
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,25 @@ | ||
(module | ||
(type $binop (func (param i32 i32) (result i32))) | ||
(table 1 100 anyfunc) | ||
(elem (i32.const 5) $sub) | ||
(elem (i32.const 10) $add) | ||
|
||
(func $main (export "main") | ||
(if (i32.eq (call_indirect (type $binop) (i32.const 42) (i32.const 1) (i32.const 10)) (i32.const 43)) | ||
(then) | ||
(else unreachable) | ||
) | ||
(if (i32.eq (call_indirect (type $binop) (i32.const 42) (i32.const 1) (i32.const 5)) (i32.const 41)) | ||
(then) | ||
(else unreachable) | ||
) | ||
) | ||
|
||
(func $add (param i32) (param i32) (result i32) | ||
(i32.add (get_local 0) (get_local 1)) | ||
) | ||
|
||
(func $sub (param i32) (param i32) (result i32) | ||
(i32.sub (get_local 0) (get_local 1)) | ||
) | ||
) |
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,36 @@ | ||
(module | ||
(func $main (export "main") | ||
(i32.const 1) | ||
(if (i32.ne (i32.div_s (i32.const 2) (i32.const -1)) (i32.const -2)) | ||
(then unreachable) | ||
) | ||
(i32.const 2) | ||
(if (i32.ne (i32.div_u (i32.const 2) (i32.const -1)) (i32.const 0)) | ||
(then unreachable) | ||
) | ||
(i32.const 3) | ||
(if (i32.ne (i32.div_u (i32.const 10) (i32.const 5)) (i32.const 2)) | ||
(then unreachable) | ||
) | ||
(i32.const 4) | ||
(if (i64.ne (i64.div_s (i64.const 300000000000) (i64.const -1)) (i64.const -300000000000)) | ||
(then unreachable) | ||
) | ||
(i32.const 5) | ||
(if (i64.ne (i64.div_u (i64.const 300000000000) (i64.const -1)) (i64.const 0)) | ||
(then unreachable) | ||
) | ||
(i32.const 6) | ||
(if (i64.ne (i64.div_u (i64.const 300000000000) (i64.const 2)) (i64.const 150000000000)) | ||
(then unreachable) | ||
) | ||
(i32.add) | ||
(i32.add) | ||
(i32.add) | ||
(i32.add) | ||
(i32.add) | ||
(if (i32.ne (i32.const 21)) | ||
(then unreachable) | ||
) | ||
) | ||
) |
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,26 @@ | ||
(module | ||
(global $g1 (mut i32) (i32.const 0)) | ||
(global $g2 (mut i32) (i32.const 99)) | ||
(func $main (export "main") | ||
(if (i32.eq (get_global $g1) (i32.const 0)) | ||
(then) | ||
(else unreachable) | ||
) | ||
(if (i32.eq (get_global $g2) (i32.const 99)) | ||
(then) | ||
(else unreachable) | ||
) | ||
|
||
(set_global $g1 (i32.add (get_global $g1) (i32.const 1))) | ||
(set_global $g2 (i32.sub (get_global $g2) (i32.const 1))) | ||
|
||
(if (i32.eq (get_global $g1) (i32.const 1)) | ||
(then) | ||
(else unreachable) | ||
) | ||
(if (i32.eq (get_global $g2) (i32.const 98)) | ||
(then) | ||
(else unreachable) | ||
) | ||
) | ||
) |
Oops, something went wrong.