diff options
author | Alex Crichton <alex@alexcrichton.com> | 2018-05-15 10:53:49 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2018-05-15 08:53:49 -0700 |
commit | 95990c43cc8a1af46af630841e6a430a71f6ea8a (patch) | |
tree | a591c1c7bf404da819e8c73da6b018b08d9bb868 /test/wasm2asm/float-ops.2asm.js | |
parent | 4615f00d6fdc314e6ca08ad3abbd42bfed60737c (diff) | |
download | binaryen-95990c43cc8a1af46af630841e6a430a71f6ea8a.tar.gz binaryen-95990c43cc8a1af46af630841e6a430a71f6ea8a.tar.bz2 binaryen-95990c43cc8a1af46af630841e6a430a71f6ea8a.zip |
wasm2asm: Implement f32/f64.copysign (#1551)
This commit implements the `copysign` instruction for the wasm2asm binary. The
implementation here is a new pass which wholesale replaces `copysign`
instructions with the equivalent bit ops and reinterpretation instructions. It's
intended that this matches Emscripten's implementation of lowering here.
Diffstat (limited to 'test/wasm2asm/float-ops.2asm.js')
-rw-r--r-- | test/wasm2asm/float-ops.2asm.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/wasm2asm/float-ops.2asm.js b/test/wasm2asm/float-ops.2asm.js index fceaa7985..bad4bae9d 100644 --- a/test/wasm2asm/float-ops.2asm.js +++ b/test/wasm2asm/float-ops.2asm.js @@ -206,6 +206,35 @@ function asmFunc(global, env, buffer) { return +Math_sqrt($0); } + function copysign64($0, $1) { + $0 = +$0; + $1 = +$1; + var i64toi32_i32$0 = 0, i64toi32_i32$2 = 0, i64toi32_i32$3 = 0, i64toi32_i32$1 = 0; + HEAPF64[0 >> 3] = $0; + i64toi32_i32$0 = HEAP32[(0 + 4 | 0) >> 2] | 0; + i64toi32_i32$2 = HEAP32[0 >> 2] | 0; + i64toi32_i32$1 = 2147483647; + i64toi32_i32$3 = 4294967295; + i64toi32_i32$1 = i64toi32_i32$0 & i64toi32_i32$1 | 0; + i64toi32_i32$3 = i64toi32_i32$2 & i64toi32_i32$3 | 0; + HEAPF64[0 >> 3] = $1; + i64toi32_i32$2 = HEAP32[(0 + 4 | 0) >> 2] | 0; + i64toi32_i32$3 = HEAP32[0 >> 2] | 0; + i64toi32_i32$0 = 2147483648; + i64toi32_i32$0 = i64toi32_i32$2 & i64toi32_i32$0 | 0; + i64toi32_i32$2 = i64toi32_i32$3 & 0 | 0; + i64toi32_i32$0 = i64toi32_i32$1 | i64toi32_i32$0 | 0; + HEAP32[0 >> 2] = i64toi32_i32$3 | i64toi32_i32$2 | 0; + HEAP32[(0 + 4 | 0) >> 2] = i64toi32_i32$0; + return +(+HEAPF64[0 >> 3]); + } + + function copysign32($0, $1) { + $0 = Math_fround($0); + $1 = Math_fround($1); + return Math_fround((HEAP32[0] = (HEAPF32[0] = $0, HEAP32[0]) & 2147483647 | 0 | ((HEAPF32[0] = $1, HEAP32[0]) & 2147483648 | 0) | 0, HEAPF32[0])); + } + function __wasm_ctz_i32(x) { x = x | 0; var $1 = 0; |