diff options
author | Alon Zakai <azakai@google.com> | 2021-09-20 10:47:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-20 17:47:14 +0000 |
commit | 737c22d30798c491eea3b401b948b9327ac979de (patch) | |
tree | f75a72adbd81a85eca19b732378837670c828b23 /src/wasm/wasm-s-parser.cpp | |
parent | b5e8c371001de20128453d5064ac0422d481020e (diff) | |
download | binaryen-737c22d30798c491eea3b401b948b9327ac979de.tar.gz binaryen-737c22d30798c491eea3b401b948b9327ac979de.tar.bz2 binaryen-737c22d30798c491eea3b401b948b9327ac979de.zip |
[Wasm GC] Add static variants of ref.test, ref.cast, and br_on_cast* (#4163)
These variants take a HeapType that is the type we intend to cast to,
and do not take an RTT.
These are intended to be more statically optimizable. For now though
this PR just implements the minimum to get them parsing and to get
through the optimizer without crashing.
Spec: https://docs.google.com/document/d/1afthjsL_B9UaMqCA5ekgVmOm75BVFu6duHNsN9-gnXw/edit#
See #4149
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 28028c459..3cfe90e26 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2574,12 +2574,24 @@ Expression* SExpressionWasmBuilder::makeRefTest(Element& s) { return Builder(wasm).makeRefTest(ref, rtt); } +Expression* SExpressionWasmBuilder::makeRefTestStatic(Element& s) { + auto heapType = parseHeapType(*s[1]); + auto* ref = parseExpression(*s[2]); + return Builder(wasm).makeRefTest(ref, heapType); +} + Expression* SExpressionWasmBuilder::makeRefCast(Element& s) { auto* ref = parseExpression(*s[1]); auto* rtt = parseExpression(*s[2]); return Builder(wasm).makeRefCast(ref, rtt); } +Expression* SExpressionWasmBuilder::makeRefCastStatic(Element& s) { + auto heapType = parseHeapType(*s[1]); + auto* ref = parseExpression(*s[2]); + return Builder(wasm).makeRefCast(ref, heapType); +} + Expression* SExpressionWasmBuilder::makeBrOn(Element& s, BrOnOp op) { auto name = getLabel(*s[1]); auto* ref = parseExpression(*s[2]); @@ -2591,6 +2603,13 @@ Expression* SExpressionWasmBuilder::makeBrOn(Element& s, BrOnOp op) { .validateAndMakeBrOn(op, name, ref, rtt); } +Expression* SExpressionWasmBuilder::makeBrOnStatic(Element& s, BrOnOp op) { + auto name = getLabel(*s[1]); + auto heapType = parseHeapType(*s[2]); + auto* ref = parseExpression(*s[3]); + return Builder(wasm).makeBrOn(op, name, ref, heapType); +} + Expression* SExpressionWasmBuilder::makeRttCanon(Element& s) { return Builder(wasm).makeRttCanon(parseHeapType(*s[1])); } |