diff options
author | Thomas Lively <tlively@users.noreply.github.com> | 2017-08-07 13:42:49 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2017-08-07 13:42:49 -0700 |
commit | 62f6a12c4fa109522229526e9d89969d2fde7399 (patch) | |
tree | fa2023676c4e698d98c25d409556d9bbb08a89b9 /test/empty_table.2asm.js | |
parent | ffd9a72d28d36915fb173a6d52fbb6e43f7c15db (diff) | |
download | binaryen-62f6a12c4fa109522229526e9d89969d2fde7399.tar.gz binaryen-62f6a12c4fa109522229526e9d89969d2fde7399.tar.bz2 binaryen-62f6a12c4fa109522229526e9d89969d2fde7399.zip |
wasm2asm i32 arithmetic support (#1120)
* Rotations, popcnt, ctz, etc
Diffstat (limited to 'test/empty_table.2asm.js')
-rw-r--r-- | test/empty_table.2asm.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/empty_table.2asm.js b/test/empty_table.2asm.js index 30a200587..70e17ea9d 100644 --- a/test/empty_table.2asm.js +++ b/test/empty_table.2asm.js @@ -12,6 +12,44 @@ function asmFunc(global, env, buffer) { var Math_fround = global.Math.fround; var Math_abs = global.Math.abs; var Math_clz32 = global.Math.clz32; + function __wasm_ctz_i32(x) { + x = x | 0; + var wasm2asm_i32$0 = 0; + if ((x | 0) == (0 | 0)) wasm2asm_i32$0 = 32; else wasm2asm_i32$0 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0; + return wasm2asm_i32$0 | 0; + } + + function __wasm_popcnt_i32(x) { + x = x | 0; + var count = 0, wasm2asm_i32$0 = 0; + count = 0; + b : { + l : do { + if ((x | 0) == (0 | 0)) { + wasm2asm_i32$0 = count; + break b; + } + x = x & (x - 1 | 0) | 0; + count = count + 1 | 0; + continue l; + break l; + } while (1); + }; + return wasm2asm_i32$0 | 0; + } + + function __wasm_rotl_i32(x, k) { + x = x | 0; + k = k | 0; + return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0; + } + + function __wasm_rotr_i32(x, k) { + x = x | 0; + k = k | 0; + return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0; + } + return { }; |