diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-09-30 17:04:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-30 17:04:25 -0700 |
commit | 58832ad0b8a197ece6165bfe163f634a21f8bd6d (patch) | |
tree | b6f56bb970a53996d5bd6fabf1187a7139997f9f /src/wasm-builder.h | |
parent | cbe71a99f3b53db81cfd23f7a12f2010daeff65d (diff) | |
download | binaryen-58832ad0b8a197ece6165bfe163f634a21f8bd6d.tar.gz binaryen-58832ad0b8a197ece6165bfe163f634a21f8bd6d.tar.bz2 binaryen-58832ad0b8a197ece6165bfe163f634a21f8bd6d.zip |
asm2wasm i64 support (#723)
* support i64 intrinsics from fastcomp, adding --wasm-only flag
* refactor callImport logic in asm2wasm to avoid recomputing wasm types again
* legalize illegal i64 params in exports and imports
* do safe i64 binary ops depending on precision
* fix addVar, only assert on names if we are using a name
Diffstat (limited to 'src/wasm-builder.h')
-rw-r--r-- | src/wasm-builder.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 7cb195d08..a8c7bc4d1 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -115,6 +115,22 @@ public: call->operands.set(args); return call; } + template<typename T> + Call* makeCall(Name target, const T& args, WasmType type) { + auto* call = allocator.alloc<Call>(); + call->type = type; // not all functions may exist yet, so type must be provided + call->target = target; + call->operands.set(args); + return call; + } + template<typename T> + CallImport* makeCallImport(Name target, const T& args, WasmType type) { + auto* call = allocator.alloc<CallImport>(); + call->type = type; // similar to makeCall, for consistency + call->target = target; + call->operands.set(args); + return call; + } CallIndirect* makeCallIndirect(FunctionType* type, Expression* target, const std::vector<Expression*>& args) { auto* call = allocator.alloc<CallIndirect>(); call->fullType = type->name; @@ -242,11 +258,14 @@ public: static Index addVar(Function* func, Name name, WasmType type) { // always ok to add a var, it does not affect other indices - assert(func->localIndices.size() == func->params.size() + func->vars.size()); + Index index = func->getNumLocals(); + if (name.is()) { + // if there is a name, apply it, but here we assume all the rest have names too FIXME + assert(func->localIndices.size() == func->params.size() + func->vars.size()); + func->localIndices[name] = index; + func->localNames.push_back(name); + } func->vars.emplace_back(type); - Index index = func->localNames.size(); - func->localIndices[name] = index; - func->localNames.push_back(name); return index; } |