diff options
author | jgravelle-google <jgravelle@google.com> | 2017-10-02 13:51:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-02 13:51:55 -0700 |
commit | a9f91b9774d117a13c231ef0f40861372456878f (patch) | |
tree | 1bda2f8fed8a3affe5538732f4ac11c6b8b2599a /src/asmjs | |
parent | 28d670ade33ab7a1d091bafee243a2c5ffc93bc9 (diff) | |
download | binaryen-a9f91b9774d117a13c231ef0f40861372456878f.tar.gz binaryen-a9f91b9774d117a13c231ef0f40861372456878f.tar.bz2 binaryen-a9f91b9774d117a13c231ef0f40861372456878f.zip |
Share trap mode between asm2wasm and s2wasm (#1168)
* Extract Asm2WasmBuilder::TrapMode to shared FloatTrapMode
* Extract makeTrappingI32Binary
* Extract makeTrappingI64Binary
* Extract asm2wasm test script into scripts/test/asm2wasm.py
This matches s2wasm.py, and makes iterating on asm2wasm slightly faster.
* Simplify callsites with an arg struct
* Combine func adding across i32 and i64
* Support f32-to-int in asm2wasm
* Add BinaryenTrapMode pass, run pass from s2wasm
* BinaryenTrapMode pass takes trap context as a parameter
* Pass fully supports non-trapping binary ops
* Defer adding functions until after iteration (hackily)
* Update asm2wasm to work with deferred function adding, rebuild tests
* Extract makeTrappingFloatToInt32
* Extract makeTrappingFloatToInt64
* Add unary conversions to trap pass
* Add functions in the pass itself
* Set s2wasm trap mode with command-line arguments
* Print BINARYEN_PASS_DEBUG state when testing
* Get asm2wasm using the BinaryenTrapMode pass instead of handling it inline
* Also handle f32 to int in asm2wasm
* Make BinaryenTrapMode only need a FloatTrapMode from the caller
* Just pass the current binary Expression directly
* Combine makeTrappingI32Binary with makeTrappingI64Binary
* Pass Unary expr to makeTrappingFloatToInt32
* Unify makeTrappingFloatToInt32 & 64
* Move makeTrapping* functions inside BinaryenTrapMode, make addedFunctions non-static
* Remove FloatTrapContext
* Minor cleanups
* Extract some smaller subfunctions
* Emit name switch/casing, rename is32Bit to isI64 for consistency
* Rename BinaryenTrapMode to FloatTrap, make trap mode a nested enum
* Add some comments explaining why FloatTrap is non-parallel
* Rename addedFunctions to generatedFunctions for precision
* Rename move and split float-clamp.h to passes/FloatTrap.(h|cpp)
* Use builder instead of allocator
* Instantiate trap handling passes via the pass manager
* Move passes/FloatTrap.h to ast/trapping.h
* Add helper function to add trap-handling passes
* Add trap mode pass tests
* Rename FloatTrap.cpp to TrapMode.cpp
* Add s2wasm trap mode tests. Force float->int conversion to be signed
* Add trapping_sint_div_s test to unit.asm.js
* Fix flake8 issues with test scripts
* Update pass description comment
* Extract building functions methods
* Make generate functions into top-level functions
* Add GeneratedTrappingFunctions class to manage function/import additions
* Move ensure/makeTrapping functions outside class scope
* Use GeneratedTrappingFunctions to add immediately in asm2wasm mode
* Remove trapping_sint_div_s test
We only added it to test that trapping divisions would get
constant-folded at the correct time. Now that we're not changing the
timing of trapping modes, the test is unneeded (and problematic).
* Review feedback, add validator/*.wasm to .gitignore
* Add support for unsigned float-to-int conversion
* Use opcode directly instead of bools
* Update s2wasm clamp test for unsigned ftoi
Diffstat (limited to 'src/asmjs')
-rw-r--r-- | src/asmjs/asm_v_wasm.cpp | 12 | ||||
-rw-r--r-- | src/asmjs/shared-constants.cpp | 6 | ||||
-rw-r--r-- | src/asmjs/shared-constants.h | 6 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/asmjs/asm_v_wasm.cpp b/src/asmjs/asm_v_wasm.cpp index ae7d320ca..bfb04a9fd 100644 --- a/src/asmjs/asm_v_wasm.cpp +++ b/src/asmjs/asm_v_wasm.cpp @@ -109,4 +109,16 @@ FunctionType* ensureFunctionType(std::string sig, Module* wasm) { return type; } +Expression* ensureDouble(Expression* expr, MixedArena& allocator) { + if (expr->type == f32) { + auto conv = allocator.alloc<Unary>(); + conv->op = PromoteFloat32; + conv->value = expr; + conv->type = WasmType::f64; + return conv; + } + assert(expr->type == f64); + return expr; +} + } // namespace wasm diff --git a/src/asmjs/shared-constants.cpp b/src/asmjs/shared-constants.cpp index 43c3d1065..f62be6168 100644 --- a/src/asmjs/shared-constants.cpp +++ b/src/asmjs/shared-constants.cpp @@ -42,7 +42,13 @@ cashew::IString GLOBAL("global"), ASM2WASM("asm2wasm"), F64_REM("f64-rem"), F64_TO_INT("f64-to-int"), + F64_TO_UINT("f64-to-uint"), F64_TO_INT64("f64-to-int64"), + F64_TO_UINT64("f64-to-uint64"), + F32_TO_INT("f32-to-int"), + F32_TO_UINT("f32-to-uint"), + F32_TO_INT64("f32-to-int64"), + F32_TO_UINT64("f32-to-uint64"), I32S_DIV("i32s-div"), I32U_DIV("i32u-div"), I32S_REM("i32s-rem"), diff --git a/src/asmjs/shared-constants.h b/src/asmjs/shared-constants.h index ce5cd95a6..7e4b27c85 100644 --- a/src/asmjs/shared-constants.h +++ b/src/asmjs/shared-constants.h @@ -45,7 +45,13 @@ extern cashew::IString GLOBAL, ASM2WASM, F64_REM, F64_TO_INT, + F64_TO_UINT, F64_TO_INT64, + F64_TO_UINT64, + F32_TO_INT, + F32_TO_UINT, + F32_TO_INT64, + F32_TO_UINT64, I32S_DIV, I32U_DIV, I32S_REM, |