diff --git a/src/parser/contexts.h b/src/parser/contexts.h index e8b89a5fed9..620d10d6093 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -104,6 +104,10 @@ struct NullTypeParserCtx { HeapTypeT makeI31() { return Ok{}; } HeapTypeT makeStructType() { return Ok{}; } HeapTypeT makeArrayType() { return Ok{}; } + HeapTypeT makeStringType() { return Ok{}; } + HeapTypeT makeStringViewWTF8Type() { return Ok{}; } + HeapTypeT makeStringViewWTF16Type() { return Ok{}; } + HeapTypeT makeStringViewIterType() { return Ok{}; } TypeT makeI32() { return Ok{}; } TypeT makeI64() { return Ok{}; } @@ -190,6 +194,10 @@ template struct TypeParserCtx { HeapTypeT makeI31() { return HeapType::i31; } HeapTypeT makeStructType() { return HeapType::struct_; } HeapTypeT makeArrayType() { return HeapType::array; } + HeapTypeT makeStringType() { return HeapType::string; } + HeapTypeT makeStringViewWTF8Type() { return HeapType::stringview_wtf8; } + HeapTypeT makeStringViewWTF16Type() { return HeapType::stringview_wtf16; } + HeapTypeT makeStringViewIterType() { return HeapType::stringview_iter; } TypeT makeI32() { return Type::i32; } TypeT makeI64() { return Type::i64; } @@ -491,6 +499,19 @@ struct NullInstrParserCtx { return Ok{}; } Result<> makeRefAs(Index, RefAsOp) { return Ok{}; } + Result<> makeStringNew(Index, StringNewOp, bool, MemoryIdxT*) { return Ok{}; } + Result<> makeStringConst(Index, std::string_view) { return Ok{}; } + Result<> makeStringMeasure(Index, StringMeasureOp) { return Ok{}; } + Result<> makeStringEncode(Index, StringEncodeOp, MemoryIdxT*) { return Ok{}; } + Result<> makeStringConcat(Index) { return Ok{}; } + Result<> makeStringEq(Index, StringEqOp) { return Ok{}; } + Result<> makeStringAs(Index, StringAsOp) { return Ok{}; } + Result<> makeStringWTF8Advance(Index) { return Ok{}; } + Result<> makeStringWTF16Get(Index) { return Ok{}; } + Result<> makeStringIterNext(Index) { return Ok{}; } + Result<> makeStringIterMove(Index, StringIterMoveOp) { return Ok{}; } + Result<> makeStringSliceWTF(Index, StringSliceWTFOp) { return Ok{}; } + Result<> makeStringSliceIter(Index) { return Ok{}; } }; // Phase 1: Parse definition spans for top-level module elements and determine @@ -1695,6 +1716,62 @@ struct ParseDefsCtx : TypeParserCtx { Result<> makeRefAs(Index pos, RefAsOp op) { return withLoc(pos, irBuilder.makeRefAs(op)); } + + Result<> makeStringNew(Index pos, StringNewOp op, bool try_, Name* mem) { + auto m = getMemory(pos, mem); + CHECK_ERR(m); + return withLoc(pos, irBuilder.makeStringNew(op, try_, *m)); + } + + Result<> makeStringConst(Index pos, std::string_view str) { + return withLoc(pos, irBuilder.makeStringConst(Name(str))); + } + + Result<> makeStringMeasure(Index pos, StringMeasureOp op) { + return withLoc(pos, irBuilder.makeStringMeasure(op)); + } + + Result<> makeStringEncode(Index pos, StringEncodeOp op, Name* mem) { + auto m = getMemory(pos, mem); + CHECK_ERR(m); + return withLoc(pos, irBuilder.makeStringEncode(op, *m)); + } + + Result<> makeStringConcat(Index pos) { + return withLoc(pos, irBuilder.makeStringConcat()); + } + + Result<> makeStringEq(Index pos, StringEqOp op) { + return withLoc(pos, irBuilder.makeStringEq(op)); + } + + Result<> makeStringAs(Index pos, StringAsOp op) { + return withLoc(pos, irBuilder.makeStringAs(op)); + } + + Result<> makeStringWTF8Advance(Index pos) { + return withLoc(pos, irBuilder.makeStringWTF8Advance()); + } + + Result<> makeStringWTF16Get(Index pos) { + return withLoc(pos, irBuilder.makeStringWTF16Get()); + } + + Result<> makeStringIterNext(Index pos) { + return withLoc(pos, irBuilder.makeStringIterNext()); + } + + Result<> makeStringIterMove(Index pos, StringIterMoveOp op) { + return withLoc(pos, irBuilder.makeStringIterMove(op)); + } + + Result<> makeStringSliceWTF(Index pos, StringSliceWTFOp op) { + return withLoc(pos, irBuilder.makeStringSliceWTF(op)); + } + + Result<> makeStringSliceIter(Index pos) { + return withLoc(pos, irBuilder.makeStringSliceIter()); + } }; } // namespace wasm::WATParser diff --git a/src/parser/input-impl.h b/src/parser/input-impl.h index 7ee358f128c..0f8fc2e86d4 100644 --- a/src/parser/input-impl.h +++ b/src/parser/input-impl.h @@ -226,11 +226,11 @@ inline std::optional ParseInput::takeF32() { return std::nullopt; } -inline std::optional ParseInput::takeString() { +inline std::optional ParseInput::takeString() { if (auto t = peek()) { if (auto s = t->getString()) { ++lexer; - return s; + return std::string(*s); } } return {}; diff --git a/src/parser/input.h b/src/parser/input.h index 5cb2bd4717f..dbf3e486857 100644 --- a/src/parser/input.h +++ b/src/parser/input.h @@ -59,7 +59,7 @@ struct ParseInput { std::optional takeU8(); std::optional takeF64(); std::optional takeF32(); - std::optional takeString(); + std::optional takeString(); std::optional takeName(); bool takeSExprStart(std::string_view expected); bool peekSExprStart(std::string_view expected); diff --git a/src/parser/parsers.h b/src/parser/parsers.h index 00a784033ae..78b49f02158 100644 --- a/src/parser/parsers.h +++ b/src/parser/parsers.h @@ -250,6 +250,18 @@ template Result heaptype(Ctx& ctx) { if (ctx.in.takeKeyword("array"sv)) { return ctx.makeArrayType(); } + if (ctx.in.takeKeyword("string"sv)) { + return ctx.makeStringType(); + } + if (ctx.in.takeKeyword("stringview_wtf8"sv)) { + return ctx.makeStringViewWTF8Type(); + } + if (ctx.in.takeKeyword("stringview_wtf16"sv)) { + return ctx.makeStringViewWTF16Type(); + } + if (ctx.in.takeKeyword("stringview_iter"sv)) { + return ctx.makeStringViewIterType(); + } auto type = typeidx(ctx); CHECK_ERR(type); return *type; @@ -283,7 +295,19 @@ template MaybeResult reftype(Ctx& ctx) { return ctx.makeRefType(ctx.makeStructType(), Nullable); } if (ctx.in.takeKeyword("arrayref"sv)) { - return ctx.in.err("arrayref not yet supported"); + return ctx.makeRefType(ctx.makeArrayType(), Nullable); + } + if (ctx.in.takeKeyword("stringref"sv)) { + return ctx.makeRefType(ctx.makeStringType(), Nullable); + } + if (ctx.in.takeKeyword("stringview_wtf8"sv)) { + return ctx.makeRefType(ctx.makeStringViewWTF8Type(), Nullable); + } + if (ctx.in.takeKeyword("stringview_wtf16"sv)) { + return ctx.makeRefType(ctx.makeStringViewWTF16Type(), Nullable); + } + if (ctx.in.takeKeyword("stringview_iter"sv)) { + return ctx.makeRefType(ctx.makeStringViewIterType(), Nullable); } if (!ctx.in.takeSExprStart("ref"sv)) { @@ -1650,61 +1674,69 @@ template Result<> makeRefAs(Ctx& ctx, Index pos, RefAsOp op) { template Result<> makeStringNew(Ctx& ctx, Index pos, StringNewOp op, bool try_) { - return ctx.in.err("unimplemented instruction"); + auto mem = maybeMemidx(ctx); + CHECK_ERR(mem); + return ctx.makeStringNew(pos, op, try_, mem.getPtr()); } template Result<> makeStringConst(Ctx& ctx, Index pos) { - return ctx.in.err("unimplemented instruction"); + auto str = ctx.in.takeString(); + if (!str) { + return ctx.in.err("expected string"); + } + return ctx.makeStringConst(pos, *str); } template Result<> makeStringMeasure(Ctx& ctx, Index pos, StringMeasureOp op) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeStringMeasure(pos, op); } template Result<> makeStringEncode(Ctx& ctx, Index pos, StringEncodeOp op) { - return ctx.in.err("unimplemented instruction"); + auto mem = maybeMemidx(ctx); + CHECK_ERR(mem); + return ctx.makeStringEncode(pos, op, mem.getPtr()); } template Result<> makeStringConcat(Ctx& ctx, Index pos) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeStringConcat(pos); } template Result<> makeStringEq(Ctx& ctx, Index pos, StringEqOp op) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeStringEq(pos, op); } template Result<> makeStringAs(Ctx& ctx, Index pos, StringAsOp op) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeStringAs(pos, op); } template Result<> makeStringWTF8Advance(Ctx& ctx, Index pos) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeStringWTF8Advance(pos); } template Result<> makeStringWTF16Get(Ctx& ctx, Index pos) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeStringWTF16Get(pos); } template Result<> makeStringIterNext(Ctx& ctx, Index pos) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeStringIterNext(pos); } template Result<> makeStringIterMove(Ctx& ctx, Index pos, StringIterMoveOp op) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeStringIterMove(pos, op); } template Result<> makeStringSliceWTF(Ctx& ctx, Index pos, StringSliceWTFOp op) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeStringSliceWTF(pos, op); } template Result<> makeStringSliceIter(Ctx& ctx, Index pos) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeStringSliceIter(pos); } // ======= diff --git a/src/wasm-ir-builder.h b/src/wasm-ir-builder.h index e6bea67cdf0..8b01977be3a 100644 --- a/src/wasm-ir-builder.h +++ b/src/wasm-ir-builder.h @@ -184,19 +184,19 @@ class IRBuilder : public UnifiedExpressionVisitor> { [[nodiscard]] Result<> makeArrayInitData(HeapType type, Name data); [[nodiscard]] Result<> makeArrayInitElem(HeapType type, Name elem); [[nodiscard]] Result<> makeRefAs(RefAsOp op); - // [[nodiscard]] Result<> makeStringNew(); - // [[nodiscard]] Result<> makeStringConst(); - // [[nodiscard]] Result<> makeStringMeasure(); - // [[nodiscard]] Result<> makeStringEncode(); - // [[nodiscard]] Result<> makeStringConcat(); - // [[nodiscard]] Result<> makeStringEq(); - // [[nodiscard]] Result<> makeStringAs(); - // [[nodiscard]] Result<> makeStringWTF8Advance(); - // [[nodiscard]] Result<> makeStringWTF16Get(); - // [[nodiscard]] Result<> makeStringIterNext(); - // [[nodiscard]] Result<> makeStringIterMove(); - // [[nodiscard]] Result<> makeStringSliceWTF(); - // [[nodiscard]] Result<> makeStringSliceIter(); + [[nodiscard]] Result<> makeStringNew(StringNewOp op, bool try_, Name mem); + [[nodiscard]] Result<> makeStringConst(Name string); + [[nodiscard]] Result<> makeStringMeasure(StringMeasureOp op); + [[nodiscard]] Result<> makeStringEncode(StringEncodeOp op, Name mem); + [[nodiscard]] Result<> makeStringConcat(); + [[nodiscard]] Result<> makeStringEq(StringEqOp op); + [[nodiscard]] Result<> makeStringAs(StringAsOp op); + [[nodiscard]] Result<> makeStringWTF8Advance(); + [[nodiscard]] Result<> makeStringWTF16Get(); + [[nodiscard]] Result<> makeStringIterNext(); + [[nodiscard]] Result<> makeStringIterMove(StringIterMoveOp op); + [[nodiscard]] Result<> makeStringSliceWTF(StringSliceWTFOp op); + [[nodiscard]] Result<> makeStringSliceIter(); // Private functions that must be public for technical reasons. [[nodiscard]] Result<> visitExpression(Expression*); @@ -213,6 +213,8 @@ class IRBuilder : public UnifiedExpressionVisitor> { [[nodiscard]] Result<> visitCallIndirect(CallIndirect*); [[nodiscard]] Result<> visitCallRef(CallRef*); [[nodiscard]] Result<> visitThrow(Throw*); + [[nodiscard]] Result<> visitStringNew(StringNew*); + [[nodiscard]] Result<> visitStringEncode(StringEncode*); private: Module& wasm; diff --git a/src/wasm.h b/src/wasm.h index c27dcb438f3..ce334773a2c 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -1776,6 +1776,7 @@ class RefAs : public SpecificExpression { class StringNew : public SpecificExpression { public: + StringNew() = default; StringNew(MixedArena& allocator) {} StringNewOp op; @@ -1800,6 +1801,7 @@ class StringNew : public SpecificExpression { class StringConst : public SpecificExpression { public: + StringConst() = default; StringConst(MixedArena& allocator) {} // TODO: Use a different type to allow null bytes in the middle - @@ -1812,6 +1814,7 @@ class StringConst : public SpecificExpression { class StringMeasure : public SpecificExpression { public: + StringMeasure() = default; StringMeasure(MixedArena& allocator) {} StringMeasureOp op; @@ -1823,6 +1826,7 @@ class StringMeasure : public SpecificExpression { class StringEncode : public SpecificExpression { public: + StringEncode() = default; StringEncode(MixedArena& allocator) {} StringEncodeOp op; @@ -1842,6 +1846,7 @@ class StringEncode : public SpecificExpression { class StringConcat : public SpecificExpression { public: + StringConcat() = default; StringConcat(MixedArena& allocator) {} Expression* left; @@ -1852,6 +1857,7 @@ class StringConcat : public SpecificExpression { class StringEq : public SpecificExpression { public: + StringEq() = default; StringEq(MixedArena& allocator) {} StringEqOp op; @@ -1864,6 +1870,7 @@ class StringEq : public SpecificExpression { class StringAs : public SpecificExpression { public: + StringAs() = default; StringAs(MixedArena& allocator) {} StringAsOp op; @@ -1876,6 +1883,7 @@ class StringAs : public SpecificExpression { class StringWTF8Advance : public SpecificExpression { public: + StringWTF8Advance() = default; StringWTF8Advance(MixedArena& allocator) {} Expression* ref; @@ -1887,6 +1895,7 @@ class StringWTF8Advance class StringWTF16Get : public SpecificExpression { public: + StringWTF16Get() = default; StringWTF16Get(MixedArena& allocator) {} Expression* ref; @@ -1897,6 +1906,7 @@ class StringWTF16Get : public SpecificExpression { class StringIterNext : public SpecificExpression { public: + StringIterNext() = default; StringIterNext(MixedArena& allocator) {} Expression* ref; @@ -1906,6 +1916,7 @@ class StringIterNext : public SpecificExpression { class StringIterMove : public SpecificExpression { public: + StringIterMove() = default; StringIterMove(MixedArena& allocator) {} // Whether the movement is to advance or reverse. @@ -1921,6 +1932,7 @@ class StringIterMove : public SpecificExpression { class StringSliceWTF : public SpecificExpression { public: + StringSliceWTF() = default; StringSliceWTF(MixedArena& allocator) {} StringSliceWTFOp op; @@ -1935,6 +1947,7 @@ class StringSliceWTF : public SpecificExpression { class StringSliceIter : public SpecificExpression { public: + StringSliceIter() = default; StringSliceIter(MixedArena& allocator) {} Expression* ref; diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp index 605a33a8eb7..d3f48b1c022 100644 --- a/src/wasm/wasm-ir-builder.cpp +++ b/src/wasm/wasm-ir-builder.cpp @@ -471,6 +471,65 @@ Result<> IRBuilder::visitThrow(Throw* curr) { return Ok{}; } +Result<> IRBuilder::visitStringNew(StringNew* curr) { + switch (curr->op) { + case StringNewUTF8: + case StringNewWTF8: + case StringNewLossyUTF8: + case StringNewWTF16: { + auto len = pop(); + CHECK_ERR(len); + curr->length = *len; + break; + } + case StringNewUTF8Array: + case StringNewWTF8Array: + case StringNewLossyUTF8Array: + case StringNewWTF16Array: { + auto end = pop(); + CHECK_ERR(end); + curr->end = *end; + auto start = pop(); + CHECK_ERR(start); + curr->start = *start; + break; + } + case StringNewFromCodePoint: + break; + } + auto ptr = pop(); + CHECK_ERR(ptr); + curr->ptr = *ptr; + return Ok{}; +} + +Result<> IRBuilder::visitStringEncode(StringEncode* curr) { + switch (curr->op) { + case StringEncodeUTF8Array: + case StringEncodeLossyUTF8Array: + case StringEncodeWTF8Array: + case StringEncodeWTF16Array: { + auto start = pop(); + CHECK_ERR(start); + curr->start = *start; + } + [[fallthrough]]; + case StringEncodeUTF8: + case StringEncodeLossyUTF8: + case StringEncodeWTF8: + case StringEncodeWTF16: { + auto ptr = pop(); + CHECK_ERR(ptr); + curr->ptr = *ptr; + auto ref = pop(); + CHECK_ERR(ref); + curr->ref = *ref; + return Ok{}; + } + } + WASM_UNREACHABLE("unexpected op"); +} + Result<> IRBuilder::visitFunctionStart(Function* func) { if (!scopeStack.empty()) { return Err{"unexpected start of function"}; @@ -1433,30 +1492,113 @@ Result<> IRBuilder::makeRefAs(RefAsOp op) { return Ok{}; } -// Result<> IRBuilder::makeStringNew() {} +Result<> IRBuilder::makeStringNew(StringNewOp op, bool try_, Name mem) { + StringNew curr; + curr.op = op; + CHECK_ERR(visitStringNew(&curr)); + // TODO: Store the memory in the IR. + switch (op) { + case StringNewUTF8: + case StringNewWTF8: + case StringNewLossyUTF8: + case StringNewWTF16: + push(builder.makeStringNew(op, curr.ptr, curr.length, try_)); + return Ok{}; + case StringNewUTF8Array: + case StringNewWTF8Array: + case StringNewLossyUTF8Array: + case StringNewWTF16Array: + push(builder.makeStringNew(op, curr.ptr, curr.start, curr.end, try_)); + return Ok{}; + case StringNewFromCodePoint: + push(builder.makeStringNew(op, curr.ptr, nullptr, try_)); + return Ok{}; + } + WASM_UNREACHABLE("unexpected op"); +} -// Result<> IRBuilder::makeStringConst() {} +Result<> IRBuilder::makeStringConst(Name string) { + push(builder.makeStringConst(string)); + return Ok{}; +} -// Result<> IRBuilder::makeStringMeasure() {} +Result<> IRBuilder::makeStringMeasure(StringMeasureOp op) { + StringMeasure curr; + CHECK_ERR(visitStringMeasure(&curr)); + push(builder.makeStringMeasure(op, curr.ref)); + return Ok{}; +} -// Result<> IRBuilder::makeStringEncode() {} +Result<> IRBuilder::makeStringEncode(StringEncodeOp op, Name mem) { + StringEncode curr; + curr.op = op; + CHECK_ERR(visitStringEncode(&curr)); + // TODO: Store the memory in the IR. + push(builder.makeStringEncode(op, curr.ref, curr.ptr, curr.start)); + return Ok{}; +} -// Result<> IRBuilder::makeStringConcat() {} +Result<> IRBuilder::makeStringConcat() { + StringConcat curr; + CHECK_ERR(visitStringConcat(&curr)); + push(builder.makeStringConcat(curr.left, curr.right)); + return Ok{}; +} -// Result<> IRBuilder::makeStringEq() {} +Result<> IRBuilder::makeStringEq(StringEqOp op) { + StringEq curr; + CHECK_ERR(visitStringEq(&curr)); + push(builder.makeStringEq(op, curr.left, curr.right)); + return Ok{}; +} -// Result<> IRBuilder::makeStringAs() {} +Result<> IRBuilder::makeStringAs(StringAsOp op) { + StringAs curr; + CHECK_ERR(visitStringAs(&curr)); + push(builder.makeStringAs(op, curr.ref)); + return Ok{}; +} -// Result<> IRBuilder::makeStringWTF8Advance() {} +Result<> IRBuilder::makeStringWTF8Advance() { + StringWTF8Advance curr; + CHECK_ERR(visitStringWTF8Advance(&curr)); + push(builder.makeStringWTF8Advance(curr.ref, curr.pos, curr.bytes)); + return Ok{}; +} -// Result<> IRBuilder::makeStringWTF16Get() {} +Result<> IRBuilder::makeStringWTF16Get() { + StringWTF16Get curr; + CHECK_ERR(visitStringWTF16Get(&curr)); + push(builder.makeStringWTF16Get(curr.ref, curr.pos)); + return Ok{}; +} -// Result<> IRBuilder::makeStringIterNext() {} +Result<> IRBuilder::makeStringIterNext() { + StringIterNext curr; + CHECK_ERR(visitStringIterNext(&curr)); + push(builder.makeStringIterNext(curr.ref)); + return Ok{}; +} -// Result<> IRBuilder::makeStringIterMove() {} +Result<> IRBuilder::makeStringIterMove(StringIterMoveOp op) { + StringIterMove curr; + CHECK_ERR(visitStringIterMove(&curr)); + push(builder.makeStringIterMove(op, curr.ref, curr.num)); + return Ok{}; +} -// Result<> IRBuilder::makeStringSliceWTF() {} +Result<> IRBuilder::makeStringSliceWTF(StringSliceWTFOp op) { + StringSliceWTF curr; + CHECK_ERR(visitStringSliceWTF(&curr)); + push(builder.makeStringSliceWTF(op, curr.ref, curr.start, curr.end)); + return Ok{}; +} -// Result<> IRBuilder::makeStringSliceIter() {} +Result<> IRBuilder::makeStringSliceIter() { + StringSliceIter curr; + CHECK_ERR(visitStringSliceIter(&curr)); + push(builder.makeStringSliceIter(curr.ref, curr.num)); + return Ok{}; +} } // namespace wasm diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast index 7718bc99777..40bac676deb 100644 --- a/test/lit/wat-kitchen-sink.wast +++ b/test/lit/wat-kitchen-sink.wast @@ -36,99 +36,139 @@ ;; CHECK: (type $any-array (array (mut anyref))) + ;; CHECK: (type $packed-i8 (array (mut i8))) + ;; CHECK: (type $many (sub (func (param i32 i64 f32 f64) (result anyref (ref func))))) - ;; CHECK: (type $13 (func)) + ;; CHECK: (type $14 (func)) - ;; CHECK: (type $14 (func (param i32))) + ;; CHECK: (type $15 (func (param i32))) - ;; CHECK: (type $15 (func (param i32 i64 v128))) + ;; CHECK: (type $16 (func (param i32 i64 v128))) ;; CHECK: (type $a0 (array i32)) - ;; CHECK: (type $17 (func (param i32 i32 i32))) + ;; CHECK: (type $18 (func (param i32 i32 i32))) - ;; CHECK: (type $18 (func (param v128 i32) (result v128))) - - ;; CHECK: (type $packed-i8 (array (mut i8))) + ;; CHECK: (type $19 (func (param v128 i32) (result v128))) ;; CHECK: (type $packed-i16 (array (mut i16))) - ;; CHECK: (type $21 (func (param i32 i64) (result f32))) + ;; CHECK: (type $21 (func (param stringref))) + + ;; CHECK: (type $22 (func (param stringref stringref) (result i32))) + + ;; CHECK: (type $23 (func (param i32 i64) (result f32))) + + ;; CHECK: (type $24 (func (param i32 i32))) + + ;; CHECK: (type $25 (func (param i32 i32 f64 f64))) + + ;; CHECK: (type $26 (func (param i64))) + + ;; CHECK: (type $27 (func (param v128) (result i32))) + + ;; CHECK: (type $28 (func (param v128 v128) (result v128))) + + ;; CHECK: (type $29 (func (param v128 v128 v128) (result v128))) + + ;; CHECK: (type $30 (func (param i32 i32 i64 i64))) + + ;; CHECK: (type $31 (func (param i32) (result i32))) + + ;; CHECK: (type $32 (func (param i32 i64) (result i32 i64))) + + ;; CHECK: (type $33 (func (param i64) (result i32 i64))) + + ;; CHECK: (type $34 (func (param i32) (result i32 i64))) + + ;; CHECK: (type $35 (func (param anyref) (result i32))) - ;; CHECK: (type $22 (func (param i32 i32))) + ;; CHECK: (type $36 (func (param eqref eqref) (result i32))) - ;; CHECK: (type $23 (func (param i32 i32 f64 f64))) + ;; CHECK: (type $37 (func (param i32) (result i31ref))) - ;; CHECK: (type $24 (func (param i64))) + ;; CHECK: (type $38 (func (param i31ref))) - ;; CHECK: (type $25 (func (param v128) (result i32))) + ;; CHECK: (type $39 (func (param i32 i64) (result (ref $pair)))) - ;; CHECK: (type $26 (func (param v128 v128) (result v128))) + ;; CHECK: (type $40 (func (result (ref $pair)))) - ;; CHECK: (type $27 (func (param v128 v128 v128) (result v128))) + ;; CHECK: (type $41 (func (param (ref $pair)) (result i32))) - ;; CHECK: (type $28 (func (param i32 i32 i64 i64))) + ;; CHECK: (type $42 (func (param (ref $pair)) (result i64))) - ;; CHECK: (type $29 (func (param i32) (result i32))) + ;; CHECK: (type $43 (func (param (ref $pair) i32))) - ;; CHECK: (type $30 (func (param i32 i64) (result i32 i64))) + ;; CHECK: (type $44 (func (param (ref $pair) i64))) - ;; CHECK: (type $31 (func (param i64) (result i32 i64))) + ;; CHECK: (type $45 (func (param i64 i32) (result (ref $a1)))) - ;; CHECK: (type $32 (func (param i32) (result i32 i64))) + ;; CHECK: (type $46 (func (param i32) (result (ref $a1)))) - ;; CHECK: (type $33 (func (param anyref) (result i32))) + ;; CHECK: (type $47 (func (param i32 i32) (result (ref $any-array)))) - ;; CHECK: (type $34 (func (param eqref eqref) (result i32))) + ;; CHECK: (type $48 (func (param i32 i32) (result (ref $a1)))) - ;; CHECK: (type $35 (func (param i32) (result i31ref))) + ;; CHECK: (type $49 (func (param (ref $a1) i32) (result i64))) - ;; CHECK: (type $36 (func (param i31ref))) + ;; CHECK: (type $50 (func (param (ref $packed-i8) i32) (result i32))) - ;; CHECK: (type $37 (func (param i32 i64) (result (ref $pair)))) + ;; CHECK: (type $51 (func (param (ref $packed-i16) i32) (result i32))) - ;; CHECK: (type $38 (func (result (ref $pair)))) + ;; CHECK: (type $52 (func (param (ref $a2) i32 f32))) - ;; CHECK: (type $39 (func (param (ref $pair)) (result i32))) + ;; CHECK: (type $53 (func (param arrayref) (result i32))) - ;; CHECK: (type $40 (func (param (ref $pair)) (result i64))) + ;; CHECK: (type $54 (func (param (ref $a2) i32 (ref $a2) i32 i32))) - ;; CHECK: (type $41 (func (param (ref $pair) i32))) + ;; CHECK: (type $55 (func (param (ref $a2) i32 f32 i32))) - ;; CHECK: (type $42 (func (param (ref $pair) i64))) + ;; CHECK: (type $56 (func (param (ref $a2) i32 i32 i32))) - ;; CHECK: (type $43 (func (param i64 i32) (result (ref $a1)))) + ;; CHECK: (type $57 (func (param (ref $any-array) i32 i32 i32))) - ;; CHECK: (type $44 (func (param i32) (result (ref $a1)))) + ;; CHECK: (type $58 (func (param externref))) - ;; CHECK: (type $45 (func (param i32 i32) (result (ref $any-array)))) + ;; CHECK: (type $59 (func (param i32 i32) (result stringref))) - ;; CHECK: (type $46 (func (param i32 i32) (result (ref $a1)))) + ;; CHECK: (type $60 (func (param (ref $packed-i8) i32 i32) (result stringref))) - ;; CHECK: (type $47 (func (param (ref $a1) i32) (result i64))) + ;; CHECK: (type $61 (func (param i32) (result stringref))) - ;; CHECK: (type $48 (func (param (ref $packed-i8) i32) (result i32))) + ;; CHECK: (type $62 (func (result (ref string)))) - ;; CHECK: (type $49 (func (param (ref $packed-i16) i32) (result i32))) + ;; CHECK: (type $63 (func (param stringref) (result i32))) - ;; CHECK: (type $50 (func (param (ref $a2) i32 f32))) + ;; CHECK: (type $64 (func (param stringview_wtf16) (result i32))) - ;; CHECK: (type $51 (func (param arrayref) (result i32))) + ;; CHECK: (type $65 (func (param stringref (ref $packed-i8) i32) (result i32))) - ;; CHECK: (type $52 (func (param (ref $a2) i32 (ref $a2) i32 i32))) + ;; CHECK: (type $66 (func (param stringref stringref) (result (ref string)))) - ;; CHECK: (type $53 (func (param (ref $a2) i32 f32 i32))) + ;; CHECK: (type $67 (func (param stringref) (result stringview_wtf8))) - ;; CHECK: (type $54 (func (param (ref $a2) i32 i32 i32))) + ;; CHECK: (type $68 (func (param stringref) (result (ref stringview_wtf16)))) - ;; CHECK: (type $55 (func (param (ref $any-array) i32 i32 i32))) + ;; CHECK: (type $69 (func (param stringref) (result stringview_iter))) - ;; CHECK: (type $56 (func (param externref))) + ;; CHECK: (type $70 (func (param (ref stringview_wtf8) i32 i32) (result i32))) - ;; CHECK: (type $57 (func (param i64 v128) (result v128))) + ;; CHECK: (type $71 (func (param stringview_wtf16 i32) (result i32))) - ;; CHECK: (type $58 (func (param i64 v128))) + ;; CHECK: (type $72 (func (param stringview_iter) (result i32))) + + ;; CHECK: (type $73 (func (param stringview_iter i32) (result i32))) + + ;; CHECK: (type $74 (func (param (ref stringview_iter) i32) (result i32))) + + ;; CHECK: (type $75 (func (param stringview_wtf8 stringview_wtf16 i32 i32))) + + ;; CHECK: (type $76 (func (param stringview_iter i32) (result (ref string)))) + + ;; CHECK: (type $77 (func (param i64 v128) (result v128))) + + ;; CHECK: (type $78 (func (param i64 v128))) ;; CHECK: (type $s2 (struct (field i32))) (type $s2 (struct i32)) @@ -193,7 +233,7 @@ ;; globals (global (mut i32) i32.const 0) - ;; CHECK: (type $69 (func (param (ref $s0) (ref $s1) (ref $s2) (ref $s3) (ref $s4) (ref $s5) (ref $s6) (ref $s7) (ref $s8) (ref $a0) (ref $a1) (ref $a2) (ref $a3) (ref $subvoid) (ref $submany)))) + ;; CHECK: (type $89 (func (param (ref $s0) (ref $s1) (ref $s2) (ref $s3) (ref $s4) (ref $s5) (ref $s6) (ref $s7) (ref $s8) (ref $a0) (ref $a1) (ref $a2) (ref $a3) (ref $subvoid) (ref $submany)))) ;; CHECK: (import "" "mem" (memory $mimport$0 0)) @@ -342,11 +382,11 @@ ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) - ;; CHECK: (func $f1 (type $14) (param $0 i32) + ;; CHECK: (func $f1 (type $15) (param $0 i32) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $f1 (param i32)) - ;; CHECK: (func $f2 (type $14) (param $x i32) + ;; CHECK: (func $f2 (type $15) (param $x i32) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $f2 (param $x i32)) @@ -789,7 +829,7 @@ drop ) - ;; CHECK: (func $locals (type $22) (param $0 i32) (param $x i32) + ;; CHECK: (func $locals (type $24) (param $0 i32) (param $x i32) ;; CHECK-NEXT: (local $2 i32) ;; CHECK-NEXT: (local $y i32) ;; CHECK-NEXT: (drop @@ -2421,7 +2461,7 @@ ) - ;; CHECK: (func $binary (type $23) (param $0 i32) (param $1 i32) (param $2 f64) (param $3 f64) + ;; CHECK: (func $binary (type $25) (param $0 i32) (param $1 i32) (param $2 f64) (param $3 f64) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (local.get $0) @@ -2446,7 +2486,7 @@ drop ) - ;; CHECK: (func $unary (type $24) (param $0 i64) + ;; CHECK: (func $unary (type $26) (param $0 i64) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i64.eqz ;; CHECK-NEXT: (local.get $0) @@ -2459,7 +2499,7 @@ drop ) - ;; CHECK: (func $select (type $17) (param $0 i32) (param $1 i32) (param $2 i32) + ;; CHECK: (func $select (type $18) (param $0 i32) (param $1 i32) (param $2 i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (select ;; CHECK-NEXT: (local.get $0) @@ -2741,7 +2781,7 @@ atomic.fence ) - ;; CHECK: (func $simd-extract (type $25) (param $0 v128) (result i32) + ;; CHECK: (func $simd-extract (type $27) (param $0 v128) (result i32) ;; CHECK-NEXT: (i32x4.extract_lane 3 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -2751,7 +2791,7 @@ i32x4.extract_lane 3 ) - ;; CHECK: (func $simd-replace (type $18) (param $0 v128) (param $1 i32) (result v128) + ;; CHECK: (func $simd-replace (type $19) (param $0 v128) (param $1 i32) (result v128) ;; CHECK-NEXT: (i32x4.replace_lane 2 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -2763,7 +2803,7 @@ i32x4.replace_lane 2 ) - ;; CHECK: (func $simd-shuffle (type $26) (param $0 v128) (param $1 v128) (result v128) + ;; CHECK: (func $simd-shuffle (type $28) (param $0 v128) (param $1 v128) (result v128) ;; CHECK-NEXT: (i8x16.shuffle 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -2775,7 +2815,7 @@ i8x16.shuffle 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23 ) - ;; CHECK: (func $simd-ternary (type $27) (param $0 v128) (param $1 v128) (param $2 v128) (result v128) + ;; CHECK: (func $simd-ternary (type $29) (param $0 v128) (param $1 v128) (param $2 v128) (result v128) ;; CHECK-NEXT: (v128.bitselect ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -2789,7 +2829,7 @@ v128.bitselect ) - ;; CHECK: (func $simd-shift (type $18) (param $0 v128) (param $1 i32) (result v128) + ;; CHECK: (func $simd-shift (type $19) (param $0 v128) (param $1 i32) (result v128) ;; CHECK-NEXT: (i8x16.shl ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -2822,7 +2862,7 @@ drop ) - ;; CHECK: (func $simd-load-store-lane (type $15) (param $0 i32) (param $1 i64) (param $2 v128) + ;; CHECK: (func $simd-load-store-lane (type $16) (param $0 i32) (param $1 i64) (param $2 v128) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (v128.load16_lane $mimport$0 7 ;; CHECK-NEXT: (local.get $0) @@ -2844,7 +2884,7 @@ v128.store64_lane 4 align=4 0 ) - ;; CHECK: (func $memory-init (type $17) (param $0 i32) (param $1 i32) (param $2 i32) + ;; CHECK: (func $memory-init (type $18) (param $0 i32) (param $1 i32) (param $2 i32) ;; CHECK-NEXT: (memory.init $mem-i32 $passive ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -2885,7 +2925,7 @@ data.drop $passive ) - ;; CHECK: (func $memory-copy (type $28) (param $0 i32) (param $1 i32) (param $2 i64) (param $3 i64) + ;; CHECK: (func $memory-copy (type $30) (param $0 i32) (param $1 i32) (param $2 i64) (param $3 i64) ;; CHECK-NEXT: (memory.copy $mimport$0 $mimport$0 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -2956,7 +2996,7 @@ return ) - ;; CHECK: (func $return-one (type $29) (param $0 i32) (result i32) + ;; CHECK: (func $return-one (type $31) (param $0 i32) (result i32) ;; CHECK-NEXT: (return ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -2966,7 +3006,7 @@ return ) - ;; CHECK: (func $return-two (type $30) (param $0 i32) (param $1 i64) (result i32 i64) + ;; CHECK: (func $return-two (type $32) (param $0 i32) (param $1 i64) (result i32 i64) ;; CHECK-NEXT: (return ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (local.get $0) @@ -2980,7 +3020,7 @@ return ) - ;; CHECK: (func $return-two-first-unreachable (type $31) (param $0 i64) (result i32 i64) + ;; CHECK: (func $return-two-first-unreachable (type $33) (param $0 i64) (result i32 i64) ;; CHECK-NEXT: (return ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (unreachable) @@ -2994,7 +3034,7 @@ return ) - ;; CHECK: (func $return-two-second-unreachable (type $32) (param $0 i32) (result i32 i64) + ;; CHECK: (func $return-two-second-unreachable (type $34) (param $0 i32) (result i32 i64) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -3011,7 +3051,7 @@ return ) - ;; CHECK: (func $ref-is-null (type $33) (param $0 anyref) (result i32) + ;; CHECK: (func $ref-is-null (type $35) (param $0 anyref) (result i32) ;; CHECK-NEXT: (ref.is_null ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -3055,7 +3095,7 @@ throw $tag-pair ) - ;; CHECK: (func $ref-eq (type $34) (param $0 eqref) (param $1 eqref) (result i32) + ;; CHECK: (func $ref-eq (type $36) (param $0 eqref) (param $1 eqref) (result i32) ;; CHECK-NEXT: (ref.eq ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3232,7 +3272,7 @@ table.copy 1 $funcs ) - ;; CHECK: (func $i31-new (type $35) (param $0 i32) (result i31ref) + ;; CHECK: (func $i31-new (type $37) (param $0 i32) (result i31ref) ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -3242,7 +3282,7 @@ ref.i31 ) - ;; CHECK: (func $i31-get (type $36) (param $0 i31ref) + ;; CHECK: (func $i31-get (type $38) (param $0 i31ref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i31.get_s ;; CHECK-NEXT: (local.get $0) @@ -3467,7 +3507,7 @@ drop ) - ;; CHECK: (func $struct-new (type $37) (param $0 i32) (param $1 i64) (result (ref $pair)) + ;; CHECK: (func $struct-new (type $39) (param $0 i32) (param $1 i64) (result (ref $pair)) ;; CHECK-NEXT: (struct.new $pair ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3479,14 +3519,14 @@ struct.new $pair ) - ;; CHECK: (func $struct-new-default (type $38) (result (ref $pair)) + ;; CHECK: (func $struct-new-default (type $40) (result (ref $pair)) ;; CHECK-NEXT: (struct.new_default $pair) ;; CHECK-NEXT: ) (func $struct-new-default (result (ref $pair)) struct.new_default 14 ) - ;; CHECK: (func $struct-get-0 (type $39) (param $0 (ref $pair)) (result i32) + ;; CHECK: (func $struct-get-0 (type $41) (param $0 (ref $pair)) (result i32) ;; CHECK-NEXT: (struct.get $pair 0 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -3496,7 +3536,7 @@ struct.get 14 0 ) - ;; CHECK: (func $struct-get-1 (type $40) (param $0 (ref $pair)) (result i64) + ;; CHECK: (func $struct-get-1 (type $42) (param $0 (ref $pair)) (result i64) ;; CHECK-NEXT: (struct.get $pair 1 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -3506,7 +3546,7 @@ struct.get $pair 1 ) - ;; CHECK: (func $struct-set-0 (type $41) (param $0 (ref $pair)) (param $1 i32) + ;; CHECK: (func $struct-set-0 (type $43) (param $0 (ref $pair)) (param $1 i32) ;; CHECK-NEXT: (struct.set $pair 0 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3518,7 +3558,7 @@ struct.set $pair 0 ) - ;; CHECK: (func $struct-set-1 (type $42) (param $0 (ref $pair)) (param $1 i64) + ;; CHECK: (func $struct-set-1 (type $44) (param $0 (ref $pair)) (param $1 i64) ;; CHECK-NEXT: (struct.set $pair 1 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3530,7 +3570,7 @@ struct.set 14 1 ) - ;; CHECK: (func $array-new (type $43) (param $0 i64) (param $1 i32) (result (ref $a1)) + ;; CHECK: (func $array-new (type $45) (param $0 i64) (param $1 i32) (result (ref $a1)) ;; CHECK-NEXT: (array.new $a1 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3542,7 +3582,7 @@ array.new $a1 ) - ;; CHECK: (func $array-new-default (type $44) (param $0 i32) (result (ref $a1)) + ;; CHECK: (func $array-new-default (type $46) (param $0 i32) (result (ref $a1)) ;; CHECK-NEXT: (array.new_default $a1 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -3552,7 +3592,7 @@ array.new_default 11 ) - ;; CHECK: (func $array-new-elem (type $45) (param $0 i32) (param $1 i32) (result (ref $any-array)) + ;; CHECK: (func $array-new-elem (type $47) (param $0 i32) (param $1 i32) (result (ref $any-array)) ;; CHECK-NEXT: (array.new_elem $any-array $passive-2 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3564,7 +3604,7 @@ array.new_elem $any-array $passive-2 ) - ;; CHECK: (func $array-new-data (type $46) (param $0 i32) (param $1 i32) (result (ref $a1)) + ;; CHECK: (func $array-new-data (type $48) (param $0 i32) (param $1 i32) (result (ref $a1)) ;; CHECK-NEXT: (array.new_data $a1 $implicit-data ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3598,7 +3638,7 @@ drop ) - ;; CHECK: (func $array-get (type $47) (param $0 (ref $a1)) (param $1 i32) (result i64) + ;; CHECK: (func $array-get (type $49) (param $0 (ref $a1)) (param $1 i32) (result i64) ;; CHECK-NEXT: (array.get $a1 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3610,7 +3650,7 @@ array.get $a1 ) - ;; CHECK: (func $array-get-s (type $48) (param $0 (ref $packed-i8)) (param $1 i32) (result i32) + ;; CHECK: (func $array-get-s (type $50) (param $0 (ref $packed-i8)) (param $1 i32) (result i32) ;; CHECK-NEXT: (array.get_s $packed-i8 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3622,7 +3662,7 @@ array.get_s 15 ) - ;; CHECK: (func $array-get-u (type $49) (param $0 (ref $packed-i16)) (param $1 i32) (result i32) + ;; CHECK: (func $array-get-u (type $51) (param $0 (ref $packed-i16)) (param $1 i32) (result i32) ;; CHECK-NEXT: (array.get_u $packed-i16 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3634,7 +3674,7 @@ array.get_u $packed-i16 ) - ;; CHECK: (func $array-set (type $50) (param $0 (ref $a2)) (param $1 i32) (param $2 f32) + ;; CHECK: (func $array-set (type $52) (param $0 (ref $a2)) (param $1 i32) (param $2 f32) ;; CHECK-NEXT: (array.set $a2 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3648,7 +3688,7 @@ array.set $a2 ) - ;; CHECK: (func $array-len (type $51) (param $0 arrayref) (result i32) + ;; CHECK: (func $array-len (type $53) (param $0 arrayref) (result i32) ;; CHECK-NEXT: (array.len ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -3658,7 +3698,7 @@ array.len ) - ;; CHECK: (func $array-copy (type $52) (param $0 (ref $a2)) (param $1 i32) (param $2 (ref $a2)) (param $3 i32) (param $4 i32) + ;; CHECK: (func $array-copy (type $54) (param $0 (ref $a2)) (param $1 i32) (param $2 (ref $a2)) (param $3 i32) (param $4 i32) ;; CHECK-NEXT: (array.copy $a2 $a2 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3676,7 +3716,7 @@ array.copy $a2 $a2 ) - ;; CHECK: (func $array-fill (type $53) (param $0 (ref $a2)) (param $1 i32) (param $2 f32) (param $3 i32) + ;; CHECK: (func $array-fill (type $55) (param $0 (ref $a2)) (param $1 i32) (param $2 f32) (param $3 i32) ;; CHECK-NEXT: (array.fill $a2 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3692,7 +3732,7 @@ array.fill $a2 ) - ;; CHECK: (func $array-init-data (type $54) (param $0 (ref $a2)) (param $1 i32) (param $2 i32) (param $3 i32) + ;; CHECK: (func $array-init-data (type $56) (param $0 (ref $a2)) (param $1 i32) (param $2 i32) (param $3 i32) ;; CHECK-NEXT: (array.init_data $a2 $implicit-data ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3708,7 +3748,7 @@ array.init_data $a2 0 ) - ;; CHECK: (func $array-init-elem (type $55) (param $0 (ref $any-array)) (param $1 i32) (param $2 i32) (param $3 i32) + ;; CHECK: (func $array-init-elem (type $57) (param $0 (ref $any-array)) (param $1 i32) (param $2 i32) (param $3 i32) ;; CHECK-NEXT: (array.init_elem $any-array $passive-2 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3737,7 +3777,7 @@ drop ) - ;; CHECK: (func $any-convert-extern (type $56) (param $0 externref) + ;; CHECK: (func $any-convert-extern (type $58) (param $0 externref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (extern.internalize ;; CHECK-NEXT: (local.get $0) @@ -3763,7 +3803,368 @@ drop ) - ;; CHECK: (func $call (type $21) (param $0 i32) (param $1 i64) (result f32) + ;; CHECK: (func $string-new (type $59) (param $0 i32) (param $1 i32) (result stringref) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.new_utf8_try + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.new_wtf8 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.new_lossy_utf8 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (string.new_wtf16 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-new (param i32 i32) (result stringref) + local.get 0 + local.get 1 + string.new_utf8_try + drop + local.get 0 + local.get 1 + string.new_wtf8 0 + drop + local.get 0 + local.get 1 + string.new_lossy_utf8 $mem + drop + local.get 0 + local.get 1 + string.new_wtf16 + ) + + ;; CHECK: (func $string-new-gc (type $60) (param $0 (ref $packed-i8)) (param $1 i32) (param $2 i32) (result stringref) + ;; CHECK-NEXT: (string.new_utf8_array + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: (local.get $2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-new-gc (param (ref $packed-i8) i32 i32) (result stringref) + local.get 0 + local.get 1 + local.get 2 + string.new_utf8_array + ) + + ;; CHECK: (func $string-new-code-point (type $61) (param $0 i32) (result stringref) + ;; CHECK-NEXT: (string.from_code_point + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-new-code-point (param i32) (result stringref) + local.get 0 + string.from_code_point + ) + + ;; CHECK: (func $string-const (type $62) (result (ref string)) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.const "foobar") + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (string.const "\00\00\00") + ;; CHECK-NEXT: ) + (func $string-const (result (ref string)) + string.const "foobar" + drop + string.const "\00\00\00" + ) + + ;; CHECK: (func $string-measure (type $21) (param $0 stringref) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.measure_wtf8 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.measure_utf8 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.measure_wtf16 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.is_usv_sequence + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-measure (param stringref) + local.get 0 + string.measure_wtf8 + drop + local.get 0 + string.measure_utf8 + drop + local.get 0 + string.measure_wtf16 + drop + local.get 0 + string.is_usv_sequence + drop + ) + + ;; CHECK: (func $string-hash (type $63) (param $0 stringref) (result i32) + ;; CHECK-NEXT: (string.hash + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-hash (param stringref) (result i32) + local.get 0 + string.hash + ) + + ;; CHECK: (func $stringview-length (type $64) (param $0 stringview_wtf16) (result i32) + ;; CHECK-NEXT: (stringview_wtf16.length + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $stringview-length (param stringview_wtf16) (result i32) + local.get 0 + stringview_wtf16.length + ) + + ;; CHECK: (func $string-encode (type $21) (param $0 stringref) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.encode_wtf8 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.encode_lossy_utf8 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.encode_utf8 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.encode_wtf16 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-encode (param stringref) + local.get 0 + i32.const 0 + string.encode_wtf8 + drop + local.get 0 + i32.const 1 + string.encode_lossy_utf8 0 + drop + local.get 0 + i32.const 2 + string.encode_utf8 $mem + drop + local.get 0 + i32.const 3 + string.encode_wtf16 + drop + ) + + ;; CHECK: (func $string-encode-gc (type $65) (param $0 stringref) (param $1 (ref $packed-i8)) (param $2 i32) (result i32) + ;; CHECK-NEXT: (string.encode_wtf8_array + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: (local.get $2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-encode-gc (param stringref (ref $packed-i8) i32) (result i32) + local.get 0 + local.get 1 + local.get 2 + string.encode_wtf8_array + ) + + ;; CHECK: (func $string-concat (type $66) (param $0 stringref) (param $1 stringref) (result (ref string)) + ;; CHECK-NEXT: (string.concat + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-concat (param stringref stringref) (result (ref string)) + local.get 0 + local.get 1 + string.concat + ) + + ;; CHECK: (func $string-eq (type $22) (param $0 stringref) (param $1 stringref) (result i32) + ;; CHECK-NEXT: (string.eq + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-eq (param stringref stringref) (result i32) + local.get 0 + local.get 1 + string.eq + ) + + ;; CHECK: (func $string-compare (type $22) (param $0 stringref) (param $1 stringref) (result i32) + ;; CHECK-NEXT: (string.compare + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-compare (param stringref stringref) (result i32) + local.get 0 + local.get 1 + string.compare + ) + + ;; CHECK: (func $string-as-wtf8 (type $67) (param $0 stringref) (result stringview_wtf8) + ;; CHECK-NEXT: (string.as_wtf8 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-as-wtf8 (param stringref) (result stringview_wtf8) + local.get 0 + string.as_wtf8 + ) + + ;; CHECK: (func $string-as-wtf16 (type $68) (param $0 stringref) (result (ref stringview_wtf16)) + ;; CHECK-NEXT: (string.as_wtf16 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-as-wtf16 (param stringref) (result (ref stringview_wtf16)) + local.get 0 + string.as_wtf16 + ) + + ;; CHECK: (func $string-as-iter (type $69) (param $0 stringref) (result stringview_iter) + ;; CHECK-NEXT: (string.as_iter + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-as-iter (param stringref) (result stringview_iter) + local.get 0 + string.as_iter + ) + + ;; CHECK: (func $string-advance (type $70) (param $0 (ref stringview_wtf8)) (param $1 i32) (param $2 i32) (result i32) + ;; CHECK-NEXT: (stringview_wtf8.advance + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: (local.get $2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-advance (param (ref stringview_wtf8) i32 i32) (result i32) + local.get 0 + local.get 1 + local.get 2 + stringview_wtf8.advance + ) + + ;; CHECK: (func $string-get (type $71) (param $0 stringview_wtf16) (param $1 i32) (result i32) + ;; CHECK-NEXT: (stringview_wtf16.get_codeunit + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-get (param stringview_wtf16 i32) (result i32) + local.get 0 + local.get 1 + stringview_wtf16.get_codeunit + ) + + ;; CHECK: (func $string-iter-next (type $72) (param $0 stringview_iter) (result i32) + ;; CHECK-NEXT: (stringview_iter.next + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-iter-next (param stringview_iter) (result i32) + local.get 0 + stringview_iter.next + ) + + ;; CHECK: (func $string-iter-advance (type $73) (param $0 stringview_iter) (param $1 i32) (result i32) + ;; CHECK-NEXT: (stringview_iter.advance + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-iter-advance (param (ref null stringview_iter) i32) (result i32) + local.get 0 + local.get 1 + stringview_iter.advance + ) + + ;; CHECK: (func $string-iter-rewind (type $74) (param $0 (ref stringview_iter)) (param $1 i32) (result i32) + ;; CHECK-NEXT: (stringview_iter.rewind + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-iter-rewind (param (ref stringview_iter) i32) (result i32) + local.get 0 + local.get 1 + stringview_iter.rewind + ) + + ;; CHECK: (func $string-slice (type $75) (param $0 stringview_wtf8) (param $1 stringview_wtf16) (param $2 i32) (param $3 i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (stringview_wtf8.slice + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $2) + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (stringview_wtf16.slice + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: (local.get $2) + ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-slice (param stringview_wtf8 stringview_wtf16 i32 i32) + local.get 0 + local.get 2 + local.get 3 + stringview_wtf8.slice + drop + local.get 1 + local.get 2 + local.get 3 + stringview_wtf16.slice + drop + ) + + ;; CHECK: (func $string-iter-slice (type $76) (param $0 stringview_iter) (param $1 i32) (result (ref string)) + ;; CHECK-NEXT: (stringview_iter.slice + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string-iter-slice (param stringview_iter i32) (result (ref string)) + local.get 0 + local.get 1 + stringview_iter.slice + ) + + ;; CHECK: (func $call (type $23) (param $0 i32) (param $1 i64) (result f32) ;; CHECK-NEXT: (call $call ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3775,7 +4176,7 @@ call $call ) - ;; CHECK: (func $return_call (type $21) (param $0 i32) (param $1 i64) (result f32) + ;; CHECK: (func $return_call (type $23) (param $0 i32) (param $1 i64) (result f32) ;; CHECK-NEXT: (return_call $return_call ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -3787,7 +4188,7 @@ return_call $return_call ) - ;; CHECK: (func $call-indirect (type $15) (param $0 i32) (param $1 i64) (param $2 v128) + ;; CHECK: (func $call-indirect (type $16) (param $0 i32) (param $1 i64) (param $2 v128) ;; CHECK-NEXT: (call_indirect $timport$0 (type $void) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -3816,7 +4217,7 @@ ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (call_indirect $timport$0 (type $57) + ;; CHECK-NEXT: (call_indirect $timport$0 (type $77) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: (local.get $0) @@ -3849,7 +4250,7 @@ drop ) - ;; CHECK: (func $return-call-indirect (type $15) (param $0 i32) (param $1 i64) (param $2 v128) + ;; CHECK: (func $return-call-indirect (type $16) (param $0 i32) (param $1 i64) (param $2 v128) ;; CHECK-NEXT: (return_call_indirect $timport$0 (type $void) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -3877,7 +4278,7 @@ ;; CHECK-NEXT: (return_call_indirect $funcs (type $void) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (return_call_indirect $timport$0 (type $58) + ;; CHECK-NEXT: (return_call_indirect $timport$0 (type $78) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: (local.get $0) @@ -3908,7 +4309,7 @@ return_call_indirect (param i64 v128) ) - ;; CHECK: (func $use-types (type $69) (param $0 (ref $s0)) (param $1 (ref $s1)) (param $2 (ref $s2)) (param $3 (ref $s3)) (param $4 (ref $s4)) (param $5 (ref $s5)) (param $6 (ref $s6)) (param $7 (ref $s7)) (param $8 (ref $s8)) (param $9 (ref $a0)) (param $10 (ref $a1)) (param $11 (ref $a2)) (param $12 (ref $a3)) (param $13 (ref $subvoid)) (param $14 (ref $submany)) + ;; CHECK: (func $use-types (type $89) (param $0 (ref $s0)) (param $1 (ref $s1)) (param $2 (ref $s2)) (param $3 (ref $s3)) (param $4 (ref $s4)) (param $5 (ref $s5)) (param $6 (ref $s6)) (param $7 (ref $s7)) (param $8 (ref $s8)) (param $9 (ref $a0)) (param $10 (ref $a1)) (param $11 (ref $a2)) (param $12 (ref $a3)) (param $13 (ref $subvoid)) (param $14 (ref $submany)) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $use-types