diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-24 22:08:56 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-24 22:08:56 -0800 |
commit | 48823c099b0418b975c9a7c0c3ea042cd5077a94 (patch) | |
tree | 2b58c60f92747136864b84b25a56023cdf763daa /src/wasm2asm.h | |
parent | f981a0b24e53464762022ac052521f667b9f66dd (diff) | |
download | binaryen-48823c099b0418b975c9a7c0c3ea042cd5077a94.tar.gz binaryen-48823c099b0418b975c9a7c0c3ea042cd5077a94.tar.bz2 binaryen-48823c099b0418b975c9a7c0c3ea042cd5077a94.zip |
wasm2asm progress
Diffstat (limited to 'src/wasm2asm.h')
-rw-r--r-- | src/wasm2asm.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/wasm2asm.h b/src/wasm2asm.h index ff99add1a..09f492686 100644 --- a/src/wasm2asm.h +++ b/src/wasm2asm.h @@ -21,9 +21,6 @@ IString ASM_FUNC("asmFunc"); class Wasm2AsmBuilder { MixedArena& allocator; - // How many temp vars we need - int i32s = 0, f32s = 0, f64s = 0; - public: Asm2WasmBuilder(MixedArena& allocator) : allocator(allocator) {} @@ -65,6 +62,11 @@ public: } private: + // How many temp vars we need + int i32s = 0, f32s = 0, f64s = 0; + // Which are currently free to use + std::vector<int> i32sFree, f32sFree, f64sFree; + std::vector<Name> breakStack; std::vector<Name> continueStack; }; @@ -94,6 +96,9 @@ Ref Wasm2AsmBuilder::processFunction(Function* func) { // locals, including new temp locals XXX // checks assert(breakStack.empty() && continueStack.empty()); + assert(i32sFree.size() == i32s); // all temp vars should be free at the end + assert(f32sFree.size() == f32s); + assert(f64sFree.size() == f64s); return ret; } @@ -229,8 +234,22 @@ Ref Wasm2AsmBuilder::processExpression(Expression* curr) { return condition; } void visitSwitch(Switch *curr) override { + abort(); } void visitCall(Call *curr) override { + std::vector<Ref> operands; + bool hasStatement = false; + for (auto operand : curr->operands) { + Ref temp = processTypedExpression(curr->value); + temp = temp || isStatement(temp) + operands.push_back(temp); + } + // if any is statement, we must statementize them all + if (hasStatement) { + for (auto& operand : operands) { + operand = blockifyWithTemp(// XXX); + } + } } void visitCallImport(CallImport *curr) override { } |