diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-18 16:06:12 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-18 16:07:42 -0800 |
commit | 262bf6fbddf19eb1b365de91aab36c7d4578c135 (patch) | |
tree | 60197ee22860b545c9601b6581a9c40e88c6b615 /src/asm2wasm.h | |
parent | a3c2d97c0d8c0f2d33ea9e381e98d9dec8172d63 (diff) | |
download | binaryen-262bf6fbddf19eb1b365de91aab36c7d4578c135.tar.gz binaryen-262bf6fbddf19eb1b365de91aab36c7d4578c135.tar.bz2 binaryen-262bf6fbddf19eb1b365de91aab36c7d4578c135.zip |
start to special-case asm math builtins
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 588754580..5614329d0 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -34,6 +34,8 @@ IString GLOBAL("global"), NAN_("NaN"), INFINITY_("Infinity"), ASM2WASM("asm2wasm"), F64_REM("f64-rem"), F64_TO_INT("f64-to-int"), + GLOBAL_MATH("global.Math"), + ABS("abs"), DEBUGGER("debugger"); @@ -534,6 +536,16 @@ void Asm2WasmBuilder::processAsm(Ref ast) { IString name = pair.first; Import& import = *pair.second; if (importedFunctionTypes.find(name) != importedFunctionTypes.end()) { + // special math builtins + if (import.module == GLOBAL_MATH) { + IString base = import.base; + if (base == ABS /* XXX, this should be overloaded */) { + import.type = FunctionType(); + import.type.params.push_back(f64); + import.type.result = f64; + continue; + } + } import.type = importedFunctionTypes[name]; } else if (import.module != ASM2WASM) { // special-case the special module // never actually used |