From c672ba43321e9631a0bebf9974a06fdb2df5bf7a Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 19 Oct 2022 13:38:21 -0500 Subject: [Parser] Parse SIMD ternary expressions and shifts (#5158) --- src/wasm/wat-parser.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/wasm/wat-parser.cpp') diff --git a/src/wasm/wat-parser.cpp b/src/wasm/wat-parser.cpp index 10ca62de1..6fdffc33b 100644 --- a/src/wasm/wat-parser.cpp +++ b/src/wasm/wat-parser.cpp @@ -606,6 +606,8 @@ struct NullInstrParserCtx { InstrT makeSIMDExtract(Index, SIMDExtractOp, uint8_t) { return Ok{}; } InstrT makeSIMDReplace(Index, SIMDReplaceOp, uint8_t) { return Ok{}; } InstrT makeSIMDShuffle(Index, const std::array&) { return Ok{}; } + InstrT makeSIMDTernary(Index, SIMDTernaryOp) { return Ok{}; } + InstrT makeSIMDShift(Index, SIMDShiftOp) { return Ok{}; } template InstrT makeRefNull(Index, HeapTypeT) { return {}; @@ -1365,6 +1367,24 @@ struct ParseDefsCtx : InstrParserCtx { CHECK_ERR(lhs); return push(pos, builder.makeSIMDShuffle(*lhs, *rhs, lanes)); } + + Result<> makeSIMDTernary(Index pos, SIMDTernaryOp op) { + auto c = pop(pos); + CHECK_ERR(c); + auto b = pop(pos); + CHECK_ERR(b); + auto a = pop(pos); + CHECK_ERR(a); + return push(pos, builder.makeSIMDTernary(op, *a, *b, *c)); + } + + Result<> makeSIMDShift(Index pos, SIMDShiftOp op) { + auto shift = pop(pos); + CHECK_ERR(shift); + auto vec = pop(pos); + CHECK_ERR(vec); + return push(pos, builder.makeSIMDShift(op, *vec, *shift)); + } }; // ================ @@ -2139,13 +2159,13 @@ Result makeSIMDShuffle(Ctx& ctx, Index pos) { template Result makeSIMDTernary(Ctx& ctx, Index pos, SIMDTernaryOp op) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeSIMDTernary(pos, op); } template Result makeSIMDShift(Ctx& ctx, Index pos, SIMDShiftOp op) { - return ctx.in.err("unimplemented instruction"); + return ctx.makeSIMDShift(pos, op); } template -- cgit v1.2.3