summaryrefslogtreecommitdiff
path: root/src/parser/parsers.h
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-12-12 14:00:04 -0800
committerGitHub <noreply@github.com>2023-12-12 14:00:04 -0800
commita6c1165db639e505d68758b14256492ede57e362 (patch)
tree5ca315b2f39dad8a36ebeceb9f8b1deebc9f16e3 /src/parser/parsers.h
parenta2a59e96f8f18e00e8aea9627d3b15d894d5a825 (diff)
downloadbinaryen-a6c1165db639e505d68758b14256492ede57e362.tar.gz
binaryen-a6c1165db639e505d68758b14256492ede57e362.tar.bz2
binaryen-a6c1165db639e505d68758b14256492ede57e362.zip
Add a `tuple.drop` text pseudoinstruction (#6170)
We previously overloaded `drop` to mean both normal drops of single values and also drops of tuple values. That works fine in the legacy text parser since it can infer parent-child relationships directly from the s-expression structure of the input, so it knows that a drop should drop an entire tuple if the tuple-producing instruction is a child of the drop. The new text parser, however, is much more like the binary parser in that it uses instruction types to create parent-child instructions. The new parser always assumes that `drop` is meant to drop just a single value because that's what it does in WebAssembly. Since we want to continue to let `Drop` IR expressions consume tuples, and since we will need a way to write tests for that IR pattern that work with the new parser, introduce a new pseudoinstruction, `tuple.drop`, to represent drops of tuples. This pseudoinstruction only exists in the text format and it parses to normal `Drop` expressions. `tuple.drop` takes the arity of its operand as an immediate, which will let the new parser parse it correctly in the future.
Diffstat (limited to 'src/parser/parsers.h')
-rw-r--r--src/parser/parsers.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/parser/parsers.h b/src/parser/parsers.h
index fdcfd6d0f..281980108 100644
--- a/src/parser/parsers.h
+++ b/src/parser/parsers.h
@@ -119,6 +119,7 @@ template<typename Ctx> Result<> makeThrow(Ctx&, Index);
template<typename Ctx> Result<> makeRethrow(Ctx&, Index);
template<typename Ctx> Result<> makeTupleMake(Ctx&, Index);
template<typename Ctx> Result<> makeTupleExtract(Ctx&, Index);
+template<typename Ctx> Result<> makeTupleDrop(Ctx&, Index);
template<typename Ctx> Result<> makeCallRef(Ctx&, Index, bool isReturn);
template<typename Ctx> Result<> makeRefI31(Ctx&, Index);
template<typename Ctx> Result<> makeI31Get(Ctx&, Index, bool signed_);
@@ -1473,6 +1474,10 @@ template<typename Ctx> Result<> makeTupleExtract(Ctx& ctx, Index pos) {
return ctx.in.err("unimplemented instruction");
}
+template<typename Ctx> Result<> makeTupleDrop(Ctx& ctx, Index pos) {
+ return ctx.in.err("unimplemented instruction");
+}
+
template<typename Ctx>
Result<> makeCallRef(Ctx& ctx, Index pos, bool isReturn) {
auto type = typeidx(ctx);