summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2022-10-19 13:38:21 -0500
committerGitHub <noreply@github.com>2022-10-19 13:38:21 -0500
commitc672ba43321e9631a0bebf9974a06fdb2df5bf7a (patch)
tree9e7c9d02918b39b9d027169a7abf948b7d5a69bf /src
parent18273489e9433e399cc4f088e9352c08aec13369 (diff)
downloadbinaryen-c672ba43321e9631a0bebf9974a06fdb2df5bf7a.tar.gz
binaryen-c672ba43321e9631a0bebf9974a06fdb2df5bf7a.tar.bz2
binaryen-c672ba43321e9631a0bebf9974a06fdb2df5bf7a.zip
[Parser] Parse SIMD ternary expressions and shifts (#5158)
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wat-parser.cpp24
1 files changed, 22 insertions, 2 deletions
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<uint8_t, 16>&) { return Ok{}; }
+ InstrT makeSIMDTernary(Index, SIMDTernaryOp) { return Ok{}; }
+ InstrT makeSIMDShift(Index, SIMDShiftOp) { return Ok{}; }
template<typename HeapTypeT> InstrT makeRefNull(Index, HeapTypeT) {
return {};
@@ -1365,6 +1367,24 @@ struct ParseDefsCtx : InstrParserCtx<ParseDefsCtx> {
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<typename Ctx::InstrT> makeSIMDShuffle(Ctx& ctx, Index pos) {
template<typename Ctx>
Result<typename Ctx::InstrT>
makeSIMDTernary(Ctx& ctx, Index pos, SIMDTernaryOp op) {
- return ctx.in.err("unimplemented instruction");
+ return ctx.makeSIMDTernary(pos, op);
}
template<typename Ctx>
Result<typename Ctx::InstrT>
makeSIMDShift(Ctx& ctx, Index pos, SIMDShiftOp op) {
- return ctx.in.err("unimplemented instruction");
+ return ctx.makeSIMDShift(pos, op);
}
template<typename Ctx>