summaryrefslogtreecommitdiff
path: root/src/wasm/wasm.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-03-05 15:52:44 -0800
committerGitHub <noreply@github.com>2020-03-05 15:52:44 -0800
commit9e3dbb1f668a14341e9aebae479537d4a26095a5 (patch)
tree9857d50c3373c3f6320ca3f2586bd499bc40b224 /src/wasm/wasm.cpp
parent3a275d0627da443cce93631a64d78e7b3f441416 (diff)
downloadbinaryen-9e3dbb1f668a14341e9aebae479537d4a26095a5.tar.gz
binaryen-9e3dbb1f668a14341e9aebae479537d4a26095a5.tar.bz2
binaryen-9e3dbb1f668a14341e9aebae479537d4a26095a5.zip
Initial multivalue support (#2675)
Implements parsing and emitting of tuple creation and extraction and tuple-typed control flow for both the text and binary formats. TODO: - Extend Precompute/interpreter to handle tuple values - C and JS API support/testing - Figure out how to lower in stack IR - Fuzzing
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r--src/wasm/wasm.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index f8874da01..64bc5615f 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -188,6 +188,10 @@ const char* getExpressionName(Expression* curr) {
return "rethrow";
case Expression::Id::BrOnExnId:
return "br_on_exn";
+ case Expression::Id::TupleMakeId:
+ return "tuple.make";
+ case Expression::Id::TupleExtractId:
+ return "tuple.extract";
case Expression::Id::NumExpressionIds:
WASM_UNREACHABLE("invalid expr id");
}
@@ -898,6 +902,20 @@ void Push::finalize() {
}
}
+void TupleMake::finalize() {
+ std::vector<Type> types;
+ for (auto* op : operands) {
+ if (op->type == Type::unreachable) {
+ type = Type::unreachable;
+ return;
+ }
+ types.push_back(op->type);
+ }
+ type = Type(types);
+}
+
+void TupleExtract::finalize() { type = tuple->type.expand()[index]; }
+
size_t Function::getNumParams() { return sig.params.size(); }
size_t Function::getNumVars() { return vars.size(); }