Fix game-of-life example inconsistencies; Fix ternary expression issues in void contexts and variable statements; Simplify HEAP_BASE handling

This commit is contained in:
dcodeIO
2018-04-18 15:12:33 +02:00
parent 4026c087fd
commit 5a2f834c0d
19 changed files with 654 additions and 559 deletions

View File

@ -17,8 +17,8 @@
)
(set_global $../../examples/game-of-life/assembly/game-of-life/s
(i32.mul
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
(get_local $0)
(get_local $1)
)
)
)
@ -31,13 +31,13 @@
(local $5 i32)
(local $6 i32)
(local $7 i32)
(set_local $6
(set_local $5
(i32.sub
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
(i32.const 1)
)
)
(set_local $7
(set_local $6
(i32.sub
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
(i32.const 1)
@ -45,22 +45,22 @@
)
(loop $continue|0
(if
(i32.lt_u
(i32.lt_s
(get_local $0)
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
)
(block
(set_local $4
(set_local $3
(select
(i32.sub
(get_local $0)
(i32.const 1)
)
(get_local $6)
(get_local $5)
(get_local $0)
)
)
(set_local $5
(set_local $4
(select
(i32.const 0)
(i32.add
@ -69,7 +69,7 @@
)
(i32.eq
(get_local $0)
(get_local $6)
(get_local $5)
)
)
)
@ -78,7 +78,7 @@
)
(loop $continue|1
(if
(i32.lt_u
(i32.lt_s
(get_local $1)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
@ -94,7 +94,7 @@
(i32.load8_u
(i32.add
(i32.mul
(get_local $4)
(get_local $3)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
(tee_local $2
@ -103,7 +103,7 @@
(get_local $1)
(i32.const 1)
)
(get_local $7)
(get_local $6)
(get_local $1)
)
)
@ -112,7 +112,7 @@
(i32.load8_u
(i32.add
(i32.mul
(get_local $4)
(get_local $3)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
(get_local $1)
@ -122,10 +122,10 @@
(i32.load8_u
(i32.add
(i32.mul
(get_local $4)
(get_local $3)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
(tee_local $3
(tee_local $7
(select
(i32.const 0)
(i32.add
@ -134,7 +134,7 @@
)
(i32.eq
(get_local $1)
(get_local $7)
(get_local $6)
)
)
)
@ -157,14 +157,14 @@
(get_local $0)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
(get_local $3)
(get_local $7)
)
)
)
(i32.load8_u
(i32.add
(i32.mul
(get_local $5)
(get_local $4)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
(get_local $2)
@ -174,7 +174,7 @@
(i32.load8_u
(i32.add
(i32.mul
(get_local $5)
(get_local $4)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
(get_local $1)
@ -184,10 +184,10 @@
(i32.load8_u
(i32.add
(i32.mul
(get_local $5)
(get_local $4)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
(get_local $3)
(get_local $7)
)
)
)
@ -203,21 +203,17 @@
)
)
(if
(i32.and
(if (result i32)
(tee_local $3
(i32.lt_s
(get_local $2)
(i32.const 2)
)
(i32.eqz
(i32.or
(i32.eq
(get_local $2)
(i32.const 2)
)
(get_local $3)
(i32.gt_s
(i32.eq
(get_local $2)
(i32.const 3)
)
)
(i32.const 1)
)
(i32.store8
(i32.add

View File

@ -18,8 +18,8 @@
)
(set_global $../../examples/game-of-life/assembly/game-of-life/s
(i32.mul
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
(get_local $0)
(get_local $1)
)
)
)
@ -34,6 +34,7 @@
(local $7 i32)
(local $8 i32)
(local $9 i32)
(local $10 i32)
(block
(set_local $0
(i32.sub
@ -54,7 +55,7 @@
)
(loop $continue|0
(if
(i32.lt_u
(i32.lt_s
(get_local $2)
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
)
@ -62,29 +63,29 @@
(block
(block
(set_local $3
(select
(if (result i32)
(i32.eq
(get_local $2)
(i32.const 0)
)
(get_local $0)
(i32.sub
(get_local $2)
(i32.const 1)
)
(i32.eq
(get_local $2)
(i32.const 0)
)
)
)
(set_local $4
(select
(if (result i32)
(i32.eq
(get_local $2)
(get_local $0)
)
(i32.const 0)
(i32.add
(get_local $2)
(i32.const 1)
)
(i32.eq
(get_local $2)
(get_local $0)
)
)
)
)
@ -94,7 +95,7 @@
)
(loop $continue|1
(if
(i32.lt_u
(i32.lt_s
(get_local $5)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
@ -102,29 +103,29 @@
(block
(block
(set_local $6
(select
(if (result i32)
(i32.eq
(get_local $5)
(i32.const 0)
)
(get_local $1)
(i32.sub
(get_local $5)
(i32.const 1)
)
(i32.eq
(get_local $5)
(i32.const 0)
)
)
)
(set_local $7
(select
(if (result i32)
(i32.eq
(get_local $5)
(get_local $1)
)
(i32.const 0)
(i32.add
(get_local $5)
(i32.const 1)
)
(i32.eq
(get_local $5)
(get_local $1)
)
)
)
)
@ -216,7 +217,7 @@
)
)
)
(if
(set_local $9
(i32.load8_u
(i32.add
(i32.mul
@ -226,54 +227,79 @@
(get_local $5)
)
)
(if
(i32.and
(if (result i32)
(tee_local $9
(i32.lt_s
)
(if
(get_local $9)
(block $break|2
(block $case2|2
(block $case1|2
(block $case0|2
(set_local $10
(get_local $8)
(i32.const 2)
)
(br_if $case1|2
(i32.eq
(get_local $10)
(i32.const 2)
)
)
(br_if $case2|2
(i32.eq
(get_local $10)
(i32.const 3)
)
)
(br $case0|2)
)
(get_local $9)
(i32.gt_s
(get_local $8)
(i32.const 3)
(block
(i32.store8
(i32.add
(i32.add
(get_global $../../examples/game-of-life/assembly/game-of-life/s)
(i32.mul
(get_local $2)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
)
(get_local $5)
)
(i32.const 0)
)
(br $break|2)
)
)
(i32.const 1)
)
(i32.store8
(i32.add
(i32.add
(get_global $../../examples/game-of-life/assembly/game-of-life/s)
(i32.mul
(get_local $2)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
)
(get_local $5)
)
(i32.const 0)
)
)
(if
(i32.eq
(get_local $8)
(i32.const 3)
)
(i32.store8
(i32.add
(i32.add
(get_global $../../examples/game-of-life/assembly/game-of-life/s)
(i32.mul
(get_local $2)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
(block $break|3
(block $case1|3
(block $case0|3
(set_local $10
(get_local $8)
)
(br_if $case0|3
(i32.eq
(get_local $10)
(i32.const 3)
)
)
(get_local $5)
(br $case1|3)
)
(block
(i32.store8
(i32.add
(i32.add
(get_global $../../examples/game-of-life/assembly/game-of-life/s)
(i32.mul
(get_local $2)
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
)
)
(get_local $5)
)
(i32.const 1)
)
(br $break|3)
)
(i32.const 1)
)
)
)

View File

@ -6,30 +6,30 @@
(export "memory" (memory $0))
(start $start)
(func $start (; 0 ;) (type $v)
(if
(i32.const 0)
(unreachable)
(drop
(i32.const 1)
)
)
(if
(i32.const 1)
(drop
(i32.const 1)
)
(unreachable)
)
(if
(drop
(if (result i32)
(i32.const 0)
(unreachable)
(i32.const 1)
)
(drop
)
(drop
(if (result i32)
(i32.const 1)
(i32.const 1)
(unreachable)
)
)
(drop
(if (result i32)
(if (result i32)
(i32.const 0)
(unreachable)
(i32.const 1)
)
(i32.const 1)
(unreachable)
)
(unreachable)
)
(set_global $ternary/a
(if (result i32)