mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-17 17:01:37 +00:00
Improve Math routines; Add Mathf-specific prng (#297)
This commit is contained in:
@ -100,19 +100,14 @@
|
||||
(local $4 i32)
|
||||
(block $folding-inner0
|
||||
(set_local $3
|
||||
(i32.eq
|
||||
(tee_local $2
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(tee_local $1
|
||||
(i32.reinterpret/f32
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 23)
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(tee_local $1
|
||||
(i32.reinterpret/f32
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.const 23)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
@ -123,9 +118,22 @@
|
||||
(i32.const -2147483648)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(tee_local $2
|
||||
(i32.eq
|
||||
(get_local $3)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
@ -137,19 +145,18 @@
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
(tee_local $2
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.const 2130706432)
|
||||
)
|
||||
(block
|
||||
(br_if $folding-inner0
|
||||
(i32.eq
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.const 2130706432)
|
||||
)
|
||||
)
|
||||
@ -160,7 +167,7 @@
|
||||
)
|
||||
(set_local $1
|
||||
(if (result i32)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
@ -168,58 +175,37 @@
|
||||
)
|
||||
(i32.const 8388608)
|
||||
)
|
||||
(block (result i32)
|
||||
(block $break|0
|
||||
(set_local $3
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
(loop $repeat|0
|
||||
(br_if $break|0
|
||||
(i32.shr_u
|
||||
(get_local $3)
|
||||
(i32.const 31)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.sub
|
||||
(i32.const 1)
|
||||
(tee_local $3
|
||||
(i32.sub
|
||||
(get_local $3)
|
||||
(i32.clz
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $repeat|0)
|
||||
)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.sub
|
||||
(i32.const 1)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|2
|
||||
(loop $repeat|2
|
||||
(br_if $break|2
|
||||
(block $break|0
|
||||
(loop $repeat|0
|
||||
(br_if $break|0
|
||||
(i32.le_s
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.const 127)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(tee_local $3
|
||||
(tee_local $2
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
(i32.const 8388608)
|
||||
@ -231,11 +217,11 @@
|
||||
(block
|
||||
(br_if $folding-inner0
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -245,19 +231,19 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $3
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $repeat|2)
|
||||
(br $repeat|0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(tee_local $3
|
||||
(tee_local $2
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
(i32.const 8388608)
|
||||
@ -269,35 +255,25 @@
|
||||
(block
|
||||
(br_if $folding-inner0
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|3
|
||||
(loop $repeat|3
|
||||
(br_if $break|3
|
||||
(i32.shr_u
|
||||
(get_local $1)
|
||||
(i32.const 23)
|
||||
(set_local $1
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(tee_local $2
|
||||
(i32.clz
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 8)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $repeat|3)
|
||||
)
|
||||
)
|
||||
(return
|
||||
@ -306,7 +282,12 @@
|
||||
(tee_local $1
|
||||
(if (result i32)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(tee_local $3
|
||||
(i32.sub
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.or
|
||||
@ -315,7 +296,7 @@
|
||||
(i32.const 8388608)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.const 23)
|
||||
)
|
||||
)
|
||||
@ -323,7 +304,7 @@
|
||||
(get_local $1)
|
||||
(i32.sub
|
||||
(i32.const 1)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -376,38 +357,45 @@
|
||||
)
|
||||
(func $~lib/math/NativeMath.mod (; 3 ;) (; has Stack IR ;) (type $FUNCSIG$dd) (param $0 f64) (result f64)
|
||||
(local $1 i64)
|
||||
(local $2 i32)
|
||||
(local $2 i64)
|
||||
(local $3 i64)
|
||||
(local $4 i32)
|
||||
(local $5 i64)
|
||||
(block $folding-inner0
|
||||
(set_local $2
|
||||
(i32.wrap/i64
|
||||
(i64.and
|
||||
(i64.shr_u
|
||||
(tee_local $1
|
||||
(i64.reinterpret/f64
|
||||
(get_local $0)
|
||||
)
|
||||
(i64.and
|
||||
(i64.shr_u
|
||||
(tee_local $1
|
||||
(i64.reinterpret/f64
|
||||
(get_local $0)
|
||||
)
|
||||
(i64.const 52)
|
||||
)
|
||||
(i64.const 2047)
|
||||
(i64.const 52)
|
||||
)
|
||||
(i64.const 2047)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.wrap/i64
|
||||
(i64.shr_u
|
||||
(get_local $1)
|
||||
(i64.const 63)
|
||||
)
|
||||
(set_local $5
|
||||
(i64.shr_u
|
||||
(get_local $1)
|
||||
(i64.const 63)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $2)
|
||||
(i32.const 2047)
|
||||
(i32.eqz
|
||||
(tee_local $4
|
||||
(i64.eq
|
||||
(get_local $2)
|
||||
(i64.const 2047)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(get_local $4)
|
||||
(return
|
||||
(f64.div
|
||||
(get_local $0)
|
||||
@ -417,19 +405,18 @@
|
||||
)
|
||||
(if
|
||||
(i64.le_u
|
||||
(i64.shl
|
||||
(get_local $1)
|
||||
(i64.const 1)
|
||||
(tee_local $3
|
||||
(i64.shl
|
||||
(get_local $1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(i64.const 9214364837600034816)
|
||||
)
|
||||
(block
|
||||
(br_if $folding-inner0
|
||||
(i64.eq
|
||||
(i64.shl
|
||||
(get_local $1)
|
||||
(i64.const 1)
|
||||
)
|
||||
(get_local $3)
|
||||
(i64.const 9214364837600034816)
|
||||
)
|
||||
)
|
||||
@ -440,7 +427,29 @@
|
||||
)
|
||||
(set_local $1
|
||||
(if (result i64)
|
||||
(get_local $2)
|
||||
(i64.eqz
|
||||
(get_local $2)
|
||||
)
|
||||
(i64.shl
|
||||
(get_local $1)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(tee_local $2
|
||||
(i64.sub
|
||||
(get_local $2)
|
||||
(i64.clz
|
||||
(i64.shl
|
||||
(get_local $1)
|
||||
(i64.const 12)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(i64.or
|
||||
(i64.and
|
||||
(get_local $1)
|
||||
@ -448,58 +457,14 @@
|
||||
)
|
||||
(i64.const 4503599627370496)
|
||||
)
|
||||
(block (result i64)
|
||||
(block $break|0
|
||||
(set_local $3
|
||||
(i64.shl
|
||||
(get_local $1)
|
||||
(i64.const 12)
|
||||
)
|
||||
)
|
||||
(loop $repeat|0
|
||||
(br_if $break|0
|
||||
(i32.eqz
|
||||
(i64.eqz
|
||||
(i64.shr_u
|
||||
(get_local $3)
|
||||
(i64.const 63)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i64.shl
|
||||
(get_local $3)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(br $repeat|0)
|
||||
)
|
||||
)
|
||||
(i64.shl
|
||||
(get_local $1)
|
||||
(i64.extend_s/i32
|
||||
(i32.sub
|
||||
(i32.const 1)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|2
|
||||
(loop $repeat|2
|
||||
(br_if $break|2
|
||||
(i32.le_s
|
||||
(block $break|0
|
||||
(loop $repeat|0
|
||||
(br_if $break|0
|
||||
(i64.le_s
|
||||
(get_local $2)
|
||||
(i32.const 1023)
|
||||
(i64.const 1023)
|
||||
)
|
||||
)
|
||||
(if
|
||||
@ -532,12 +497,12 @@
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(i64.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(br $repeat|2)
|
||||
(br $repeat|0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
@ -563,31 +528,17 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|3
|
||||
(loop $repeat|3
|
||||
(br_if $break|3
|
||||
(i32.eqz
|
||||
(i64.eqz
|
||||
(i64.shr_u
|
||||
(get_local $1)
|
||||
(i64.const 52)
|
||||
)
|
||||
(set_local $1
|
||||
(i64.shl
|
||||
(get_local $1)
|
||||
(tee_local $3
|
||||
(i64.clz
|
||||
(i64.shl
|
||||
(get_local $1)
|
||||
(i64.const 11)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(i64.shl
|
||||
(get_local $1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(br $repeat|3)
|
||||
)
|
||||
)
|
||||
(return
|
||||
@ -595,9 +546,14 @@
|
||||
(i64.or
|
||||
(tee_local $1
|
||||
(if (result i64)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(i32.const 0)
|
||||
(i64.gt_s
|
||||
(tee_local $2
|
||||
(i64.sub
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i64.const 0)
|
||||
)
|
||||
(i64.or
|
||||
(i64.sub
|
||||
@ -605,27 +561,24 @@
|
||||
(i64.const 4503599627370496)
|
||||
)
|
||||
(i64.shl
|
||||
(i64.extend_s/i32
|
||||
(get_local $2)
|
||||
)
|
||||
(get_local $2)
|
||||
(i64.const 52)
|
||||
)
|
||||
)
|
||||
(i64.shr_u
|
||||
(get_local $1)
|
||||
(i64.extend_s/i32
|
||||
(i32.sub
|
||||
(i32.const 1)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i64.shl
|
||||
(i64.extend_s/i32
|
||||
(get_local $4)
|
||||
)
|
||||
(get_local $5)
|
||||
(i64.const 63)
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user