diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-12-04 21:00:16 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-12-04 21:00:16 -0800 |
commit | 1dc1d8a7958c85d4768afa1abcc4f2706510bee1 (patch) | |
tree | ca9bf1e585ed6cca05d48640d1b87e4bab220b13 | |
parent | 19109e4228c2687427257f06f80b19f3c95e1642 (diff) | |
download | binaryen-1dc1d8a7958c85d4768afa1abcc4f2706510bee1.tar.gz binaryen-1dc1d8a7958c85d4768afa1abcc4f2706510bee1.tar.bz2 binaryen-1dc1d8a7958c85d4768afa1abcc4f2706510bee1.zip |
wasm2asm fixes
-rw-r--r-- | src/emscripten-optimizer/simple_ast.h | 6 | ||||
-rw-r--r-- | src/wasm2asm.h | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/emscripten-optimizer/simple_ast.h b/src/emscripten-optimizer/simple_ast.h index 942121015..94cae9f2f 100644 --- a/src/emscripten-optimizer/simple_ast.h +++ b/src/emscripten-optimizer/simple_ast.h @@ -1615,6 +1615,12 @@ public: .push_back(target) .push_back(value); } + static Ref makeAssign(IString target, Ref value) { + return &makeRawArray(3)->push_back(makeRawString(ASSIGN)) + .push_back(&arena.alloc()->setBool(true)) + .push_back(makeName(target)) + .push_back(value); + } static Ref makeSub(Ref obj, Ref index) { return &makeRawArray(2)->push_back(makeRawString(SUB)) diff --git a/src/wasm2asm.h b/src/wasm2asm.h index b09d4ef7c..eabea83ea 100644 --- a/src/wasm2asm.h +++ b/src/wasm2asm.h @@ -453,7 +453,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { if (result != NO_RESULT) { ret[1]->push_back(ValueBuilder::makeStatement( ValueBuilder::makeAssign( - ValueBuilder::makeName(result), + result, visit(curr->list[size-1], result) ) )); @@ -648,7 +648,12 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { Unary fakeUnary = *curr; fakeUnary.value = &fakeLocal; Ref ret = blockify(visitAndAssign(curr->value, temp)); - ret[1]->push_back(visit(&fakeUnary, result)); + ret[1]->push_back(ValueBuilder::makeStatement( + ValueBuilder::makeAssign( + result, + visit(&fakeUnary, result) + ) + )); return ret; } // normal unary @@ -666,7 +671,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { case f64: { Ref ret; switch (curr->op) { - case Neg: ret = ValueBuilder::makeBinary(ValueBuilder::makeDouble(0), MINUS, value); break; + case Neg: ret = ValueBuilder::makeUnary(MINUS, value); break; case Abs: ret = ValueBuilder::makeCall(MATH_ABS, value); break; case Ceil: ret = ValueBuilder::makeCall(MATH_CEIL, value); break; case Floor: ret = ValueBuilder::makeCall(MATH_FLOOR, value); break; |