Skip to content

Commit 689ca6b

Browse files
dcodeIOkripken
authored andcommitted
wasm2asm: Add math aliases for floor, ceil and sqrt (WebAssembly#1549)
1 parent e086ef9 commit 689ca6b

22 files changed

Lines changed: 162 additions & 40 deletions

bin/binaryen.js

Lines changed: 23 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/wasm.js

Lines changed: 25 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/wasm2asm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ void Wasm2AsmBuilder::addBasics(Ref ast) {
475475
addMath(MATH_CLZ32, CLZ32);
476476
addMath(MATH_MIN, MIN);
477477
addMath(MATH_MAX, MAX);
478+
addMath(MATH_FLOOR, FLOOR);
479+
addMath(MATH_CEIL, CEIL);
480+
addMath(MATH_SQRT, SQRT);
478481
}
479482

480483
void Wasm2AsmBuilder::addImport(Ref ast, Import* import) {

test/binaryen.js/emit_asmjs.js.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function asmFunc(global, env, buffer) {
1414
var Math_clz32 = global.Math.clz32;
1515
var Math_min = global.Math.min;
1616
var Math_max = global.Math.max;
17+
var Math_floor = global.Math.floor;
18+
var Math_ceil = global.Math.ceil;
19+
var Math_sqrt = global.Math.sqrt;
1720
var i64toi32_i32$HIGH_BITS = 0;
1821
function main($0) {
1922
$0 = $0 | 0;

test/wasm2asm.asserts.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function asmFunc(global, env, buffer) {
1414
var Math_clz32 = global.Math.clz32;
1515
var Math_min = global.Math.min;
1616
var Math_max = global.Math.max;
17+
var Math_floor = global.Math.floor;
18+
var Math_ceil = global.Math.ceil;
19+
var Math_sqrt = global.Math.sqrt;
1720
var i64toi32_i32$HIGH_BITS = 0;
1821
function $0() {
1922

test/wasm2asm.traps.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function asmFunc(global, env, buffer) {
1414
var Math_clz32 = global.Math.clz32;
1515
var Math_min = global.Math.min;
1616
var Math_max = global.Math.max;
17+
var Math_floor = global.Math.floor;
18+
var Math_ceil = global.Math.ceil;
19+
var Math_sqrt = global.Math.sqrt;
1720
var i64toi32_i32$HIGH_BITS = 0;
1821
function $0() {
1922

test/wasm2asm/address.2asm.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function asmFunc(global, env, buffer) {
1414
var Math_clz32 = global.Math.clz32;
1515
var Math_min = global.Math.min;
1616
var Math_max = global.Math.max;
17+
var Math_floor = global.Math.floor;
18+
var Math_ceil = global.Math.ceil;
19+
var Math_sqrt = global.Math.sqrt;
1720
var print = env.print;
1821
var i64toi32_i32$HIGH_BITS = 0;
1922
function $0(i) {

test/wasm2asm/br_table_temp.2asm.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function asmFunc(global, env, buffer) {
1414
var Math_clz32 = global.Math.clz32;
1515
var Math_min = global.Math.min;
1616
var Math_max = global.Math.max;
17+
var Math_floor = global.Math.floor;
18+
var Math_ceil = global.Math.ceil;
19+
var Math_sqrt = global.Math.sqrt;
1720
var i64toi32_i32$HIGH_BITS = 0;
1821
function dummy() {
1922

test/wasm2asm/empty_imported_table.2asm.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function asmFunc(global, env, buffer) {
1414
var Math_clz32 = global.Math.clz32;
1515
var Math_min = global.Math.min;
1616
var Math_max = global.Math.max;
17+
var Math_floor = global.Math.floor;
18+
var Math_ceil = global.Math.ceil;
19+
var Math_sqrt = global.Math.sqrt;
1720
var import$table$0 = env.table;
1821
var i64toi32_i32$HIGH_BITS = 0;
1922
function __wasm_ctz_i32(x) {

test/wasm2asm/empty_table.2asm.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function asmFunc(global, env, buffer) {
1414
var Math_clz32 = global.Math.clz32;
1515
var Math_min = global.Math.min;
1616
var Math_max = global.Math.max;
17+
var Math_floor = global.Math.floor;
18+
var Math_ceil = global.Math.ceil;
19+
var Math_sqrt = global.Math.sqrt;
1720
var i64toi32_i32$HIGH_BITS = 0;
1821
function __wasm_ctz_i32(x) {
1922
x = x | 0;

0 commit comments

Comments
 (0)