From 9e3dbb1f668a14341e9aebae479537d4a26095a5 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Thu, 5 Mar 2020 15:52:44 -0800 Subject: 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 --- src/wasm/wasm.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/wasm/wasm.cpp') 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 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(); } -- cgit v1.2.3