Built-in abs/min/max for integers; For-loop fixes

This commit is contained in:
dcodeIO
2017-12-05 22:47:20 +01:00
parent 81844a1fe7
commit f045975a4b
16 changed files with 1273 additions and 403 deletions

View File

@ -11,18 +11,38 @@
(export "memory" (memory $0))
(start $start)
(func $start (; 0 ;) (type $v)
(local $0 f32)
(local $1 f32)
(local $2 f32)
(local $3 f32)
(local $4 f64)
(local $5 f64)
(local $6 f64)
(local $7 f64)
(local $8 f32)
(local $9 f32)
(local $10 f32)
(local $11 f64)
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
(local $9 i32)
(local $10 i64)
(local $11 i64)
(local $12 i64)
(local $13 i64)
(local $14 i64)
(local $15 i64)
(local $16 f32)
(local $17 f32)
(local $18 f32)
(local $19 f32)
(local $20 f64)
(local $21 f64)
(local $22 f64)
(local $23 f64)
(local $24 f32)
(local $25 f64)
(local $26 f32)
(local $27 f32)
(local $28 f64)
(local $29 f64)
(local $30 f32)
(local $31 f64)
(drop
(i32.clz
(i32.const 1)
@ -50,154 +70,364 @@
(i32.const 1)
)
)
(set_global $builtins/i
(i32.clz
(i32.const 1)
)
)
(set_global $builtins/i
(i32.ctz
(i32.const 1)
)
)
(set_global $builtins/i
(i32.popcnt
(i32.const 1)
)
)
(set_global $builtins/i
(i32.rotl
(i32.const 1)
(i32.const 1)
)
)
(set_global $builtins/i
(i32.rotr
(i32.const 1)
(i32.const 1)
)
)
(drop
(i64.clz
(i64.const 1)
)
)
(drop
(i64.ctz
(i64.const 1)
)
)
(drop
(i64.popcnt
(i64.const 1)
)
)
(drop
(i64.rotl
(i64.const 1)
(i64.const 1)
)
)
(drop
(i64.rotr
(i64.const 1)
(i64.const 1)
)
)
(set_global $builtins/I
(i64.clz
(i64.const 1)
)
)
(set_global $builtins/I
(i64.ctz
(i64.const 1)
)
)
(set_global $builtins/I
(i64.popcnt
(i64.const 1)
)
)
(set_global $builtins/I
(i64.rotl
(i64.const 1)
(i64.const 1)
)
)
(set_global $builtins/I
(i64.rotr
(i64.const 1)
(i64.const 1)
)
)
(drop
(f32.const nan:0x400000)
)
(drop
(f32.const inf)
)
(drop
(f32.abs
(f32.const 1.25)
)
)
(drop
(f32.ceil
(f32.const 1.25)
)
)
(drop
(f32.copysign
(f32.const 1.25)
(f32.const 2.5)
)
)
(drop
(f32.floor
(f32.const 1.25)
)
)
(drop
(f32.max
(f32.const 1.25)
(f32.const 2.5)
)
)
(drop
(f32.min
(f32.const 1.25)
(f32.const 2.5)
)
)
(drop
(f32.nearest
(f32.const 1.25)
)
)
(drop
(f32.sqrt
(f32.const 1.25)
)
)
(drop
(f32.trunc
(f32.const 1.25)
)
)
(drop
(f32.ne
(tee_local $0
(f32.const 1.25)
(select
(i32.sub
(i32.const 0)
(tee_local $0
(i32.sub
(i32.const 0)
(i32.const 42)
)
)
)
(get_local $0)
(i32.lt_s
(get_local $0)
(i32.const 0)
)
)
)
(drop
(select
(tee_local $1
(i32.const 1)
)
(tee_local $2
(i32.const 2)
)
(i32.gt_s
(get_local $1)
(get_local $2)
)
)
)
(drop
(select
(tee_local $3
(i32.const 1)
)
(tee_local $4
(i32.const 2)
)
(i32.lt_s
(get_local $3)
(get_local $4)
)
)
)
(set_global $builtins/i
(i32.clz
(i32.const 1)
)
)
(set_global $builtins/i
(i32.ctz
(i32.const 1)
)
)
(set_global $builtins/i
(i32.popcnt
(i32.const 1)
)
)
(set_global $builtins/i
(i32.rotl
(i32.const 1)
(i32.const 1)
)
)
(set_global $builtins/i
(i32.rotr
(i32.const 1)
(i32.const 1)
)
)
(set_global $builtins/i
(select
(i32.sub
(i32.const 0)
(tee_local $5
(i32.sub
(i32.const 0)
(i32.const 42)
)
)
)
(get_local $5)
(i32.lt_s
(get_local $5)
(i32.const 0)
)
)
)
(if
(i32.eqz
(i32.eq
(get_global $builtins/i)
(i32.const 42)
)
)
(unreachable)
)
(set_global $builtins/i
(select
(tee_local $6
(i32.const 1)
)
(tee_local $7
(i32.const 2)
)
(i32.gt_s
(get_local $6)
(get_local $7)
)
)
)
(if
(i32.eqz
(i32.eq
(get_global $builtins/i)
(i32.const 2)
)
)
(unreachable)
)
(set_global $builtins/i
(select
(tee_local $8
(i32.const 1)
)
(tee_local $9
(i32.const 2)
)
(i32.lt_s
(get_local $8)
(get_local $9)
)
)
)
(if
(i32.eqz
(i32.eq
(get_global $builtins/i)
(i32.const 1)
)
)
(unreachable)
)
(drop
(i64.clz
(i64.const 1)
)
)
(drop
(i64.ctz
(i64.const 1)
)
)
(drop
(i64.popcnt
(i64.const 1)
)
)
(drop
(i64.rotl
(i64.const 1)
(i64.const 1)
)
)
(drop
(i64.rotr
(i64.const 1)
(i64.const 1)
)
)
(drop
(select
(i64.sub
(i64.const 0)
(tee_local $10
(i64.sub
(i64.const 0)
(i64.const 42)
)
)
)
(get_local $10)
(i64.lt_s
(get_local $10)
(i64.const 0)
)
)
)
(set_global $builtins/I
(i64.clz
(i64.const 1)
)
)
(set_global $builtins/I
(i64.ctz
(i64.const 1)
)
)
(set_global $builtins/I
(i64.popcnt
(i64.const 1)
)
)
(set_global $builtins/I
(i64.rotl
(i64.const 1)
(i64.const 1)
)
)
(set_global $builtins/I
(i64.rotr
(i64.const 1)
(i64.const 1)
)
)
(set_global $builtins/I
(select
(i64.sub
(i64.const 0)
(tee_local $11
(i64.sub
(i64.const 0)
(i64.const 42)
)
)
)
(get_local $11)
(i64.lt_s
(get_local $11)
(i64.const 0)
)
)
)
(if
(i32.eqz
(i64.eq
(get_global $builtins/I)
(i64.const 42)
)
)
(unreachable)
)
(set_global $builtins/I
(select
(tee_local $12
(i64.const 1)
)
(tee_local $13
(i64.const 2)
)
(i64.gt_s
(get_local $12)
(get_local $13)
)
)
)
(if
(i32.eqz
(i64.eq
(get_global $builtins/I)
(i64.const 2)
)
)
(unreachable)
)
(set_global $builtins/I
(select
(tee_local $14
(i64.const 1)
)
(tee_local $15
(i64.const 2)
)
(i64.lt_s
(get_local $14)
(get_local $15)
)
)
)
(if
(i32.eqz
(i32.eq
(get_global $builtins/i)
(i32.const 1)
)
)
(unreachable)
)
(drop
(f32.const nan:0x400000)
)
(drop
(f32.const inf)
)
(drop
(f32.abs
(f32.const 1.25)
)
)
(drop
(f32.ceil
(f32.const 1.25)
)
)
(drop
(f32.copysign
(f32.const 1.25)
(f32.const 2.5)
)
)
(drop
(f32.floor
(f32.const 1.25)
)
)
(drop
(f32.max
(f32.const 1.25)
(f32.const 2.5)
)
)
(drop
(f32.min
(f32.const 1.25)
(f32.const 2.5)
)
)
(drop
(f32.nearest
(f32.const 1.25)
)
)
(drop
(f32.sqrt
(f32.const 1.25)
)
)
(drop
(f32.trunc
(f32.const 1.25)
)
)
(drop
(f32.ne
(tee_local $16
(f32.const 1.25)
)
(get_local $16)
)
)
(drop
(select
(f32.ne
(f32.abs
(tee_local $1
(tee_local $17
(f32.const 1.25)
)
)
@ -205,8 +435,8 @@
)
(i32.const 0)
(f32.eq
(get_local $1)
(get_local $1)
(get_local $17)
(get_local $17)
)
)
)
@ -266,17 +496,17 @@
)
(set_global $builtins/b
(f32.ne
(tee_local $2
(tee_local $18
(f32.const 1.25)
)
(get_local $2)
(get_local $18)
)
)
(set_global $builtins/b
(select
(f32.ne
(f32.abs
(tee_local $3
(tee_local $19
(f32.const 1.25)
)
)
@ -284,8 +514,8 @@
)
(i32.const 0)
(f32.eq
(get_local $3)
(get_local $3)
(get_local $19)
(get_local $19)
)
)
)
@ -351,17 +581,17 @@
)
(drop
(f64.ne
(tee_local $4
(tee_local $20
(f64.const 1.25)
)
(get_local $4)
(get_local $20)
)
)
(drop
(select
(f64.ne
(f64.abs
(tee_local $5
(tee_local $21
(f64.const 1.25)
)
)
@ -369,8 +599,8 @@
)
(i32.const 0)
(f64.eq
(get_local $5)
(get_local $5)
(get_local $21)
(get_local $21)
)
)
)
@ -430,17 +660,17 @@
)
(set_global $builtins/b
(f64.ne
(tee_local $6
(tee_local $22
(f64.const 1.25)
)
(get_local $6)
(get_local $22)
)
)
(set_global $builtins/b
(select
(f64.ne
(f64.abs
(tee_local $7
(tee_local $23
(f64.const 1.25)
)
)
@ -448,8 +678,8 @@
)
(i32.const 0)
(f64.eq
(get_local $7)
(get_local $7)
(get_local $23)
(get_local $23)
)
)
)
@ -462,6 +692,12 @@
(i32.const 8)
(get_global $builtins/i)
)
(i32.store
(i32.const 8)
(i32.load
(i32.const 8)
)
)
(set_global $builtins/I
(i64.load
(i32.const 8)
@ -471,6 +707,12 @@
(i32.const 8)
(get_global $builtins/I)
)
(i64.store
(i32.const 8)
(i64.load
(i32.const 8)
)
)
(set_global $builtins/f
(f32.load
(i32.const 8)
@ -480,6 +722,12 @@
(i32.const 8)
(get_global $builtins/f)
)
(f32.store
(i32.const 8)
(f32.load
(i32.const 8)
)
)
(set_global $builtins/F
(f64.load
(i32.const 8)
@ -489,6 +737,12 @@
(i32.const 8)
(get_global $builtins/F)
)
(f64.store
(i32.const 8)
(f64.load
(i32.const 8)
)
)
(drop
(i32.reinterpret/f32
(f32.const 1.25)
@ -605,101 +859,180 @@
(i32.const 0)
(unreachable)
)
(drop
(i32.const 1)
)
(drop
(i32.const 2)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(drop
(i32.const 4)
)
(drop
(i32.const 1)
)
(drop
(i32.const 1)
)
(drop
(i32.const 2)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(drop
(i32.const 4)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(if
(i32.eqz
(i32.const 1)
)
(unreachable)
)
(drop
(i32.const 1)
)
(drop
(i32.const 2)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(drop
(i32.const 4)
)
(drop
(i32.const 1)
)
(drop
(i32.const 1)
)
(drop
(i32.const 2)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(drop
(i32.const 4)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(if
(f64.eq
(f64.const nan:0x8000000000000)
(f64.const nan:0x8000000000000)
(f64.ne
(f64.const nan:0x8000000000000)
(f64.const nan:0x8000000000000)
)
)
(unreachable)
)
(if
(i32.eqz
(f32.ne
(tee_local $8
(tee_local $24
(f32.const nan:0x400000)
)
(get_local $8)
(get_local $24)
)
)
(unreachable)
)
(if
(select
(f32.ne
(f32.abs
(tee_local $9
(f32.const nan:0x400000)
)
(i32.eqz
(f64.ne
(tee_local $25
(f64.const nan:0x8000000000000)
)
(f32.const inf)
)
(i32.const 0)
(f32.eq
(get_local $9)
(get_local $9)
(get_local $25)
)
)
(unreachable)
)
(if
(select
(f32.ne
(f32.abs
(tee_local $10
(i32.eqz
(i32.eqz
(select
(f32.ne
(f32.abs
(tee_local $26
(f32.const nan:0x400000)
)
)
(f32.const inf)
)
(i32.const 0)
(f32.eq
(get_local $26)
(get_local $26)
)
)
(f32.const inf)
)
(i32.const 0)
(f32.eq
(get_local $10)
(get_local $10)
)
(unreachable)
)
(if
(i32.eqz
(i32.eqz
(select
(f32.ne
(f32.abs
(tee_local $27
(f32.const inf)
)
)
(f32.const inf)
)
(i32.const 0)
(f32.eq
(get_local $27)
(get_local $27)
)
)
)
)
(unreachable)
)
(if
(i32.eqz
(i32.eqz
(select
(f64.ne
(f64.abs
(tee_local $28
(f64.const nan:0x8000000000000)
)
)
(f64.const inf)
)
(i32.const 0)
(f64.eq
(get_local $28)
(get_local $28)
)
)
)
)
(unreachable)
)
(if
(i32.eqz
(i32.eqz
(select
(f64.ne
(f64.abs
(tee_local $29
(f64.const inf)
)
)
(f64.const inf)
)
(i32.const 0)
(f64.eq
(get_local $29)
(get_local $29)
)
)
)
)
(unreachable)
)
(if
(i32.eqz
(select
(f32.ne
(f32.abs
(tee_local $30
(f32.const 0)
)
)
(f32.const inf)
)
(i32.const 0)
(f32.eq
(get_local $30)
(get_local $30)
)
)
)
(unreachable)
@ -709,7 +1042,7 @@
(select
(f64.ne
(f64.abs
(tee_local $11
(tee_local $31
(f64.const 0)
)
)
@ -717,8 +1050,8 @@
)
(i32.const 0)
(f64.eq
(get_local $11)
(get_local $11)
(get_local $31)
(get_local $31)
)
)
)