From e9e1b2ff00aeb05aaeb57af3811add267dc25323 Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Thu, 24 Sep 2020 12:02:09 +0200 Subject: GC: Add i31 instructions (#3154) Adds the `i31.new` and `i31.get_s/u` instructions for creating and working with `i31ref` typed values. Does not include fuzzer integration just yet because the fuzzer expects that trivial values it creates are suitable in global initializers, which is not the case for trivial `i31ref` expressions. --- src/wasm/wasm-s-parser.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/wasm/wasm-s-parser.cpp') diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 1bb83ec94..166fc88bb 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1979,6 +1979,21 @@ Expression* SExpressionWasmBuilder::makeTupleExtract(Element& s) { return ret; } +Expression* SExpressionWasmBuilder::makeI31New(Element& s) { + auto ret = allocator.alloc(); + ret->value = parseExpression(s[1]); + ret->finalize(); + return ret; +} + +Expression* SExpressionWasmBuilder::makeI31Get(Element& s, bool signed_) { + auto ret = allocator.alloc(); + ret->i31 = parseExpression(s[1]); + ret->signed_ = signed_; + ret->finalize(); + return ret; +} + // converts an s-expression string representing binary data into an output // sequence of raw bytes this appends to data, which may already contain // content. -- cgit v1.2.3