diff options
author | Thomas Lively <tlively@google.com> | 2023-01-06 15:47:19 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-06 13:47:19 -0800 |
commit | f719c3527512377657f72f16ee4ac5581843614f (patch) | |
tree | b082f8d5e80bb53a9d69e7c8197f6b7ada2939b6 /src/wasm-s-parser.h | |
parent | 73a1cfcacd028ed7aefe304c2e140cda4068dcb0 (diff) | |
download | binaryen-f719c3527512377657f72f16ee4ac5581843614f.tar.gz binaryen-f719c3527512377657f72f16ee4ac5581843614f.tar.bz2 binaryen-f719c3527512377657f72f16ee4ac5581843614f.zip |
Consolidate br_on* operations (#5399)
The `br_on{_non}_{data,i31,func}` operations are deprecated and directly
representable in terms of the new `br_on_cast` and `br_on_cast_fail`
instructions, so remove their dedicated IR opcodes in favor of representing them
as casts. `br_on_null` and `br_on_non_null` cannot be consolidated the same way
because their behavior is not directly representable in terms of `br_on_cast`
and `br_on_cast_fail`; when the cast to null bottom type succeeds, the null
check instructions implicitly drop the null value whereas the cast instructions
would propagate it.
Add special logic to the binary writer and printer to continue emitting the
deprecated instructions for now. This will allow us to update the test suite in
a separate future PR with no additional functional changes.
Some tests are updated because the validator no longer allows passing non-func
data to `br_on_func`. Doing so has not made sense since we separated the three
reference type hierarchies.
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r-- | src/wasm-s-parser.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 23eed7923..04c832869 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -286,7 +286,9 @@ private: Expression* makeRefTest(Element& s); Expression* makeRefCast(Element& s); Expression* makeRefCastNop(Element& s); - Expression* makeBrOn(Element& s, BrOnOp op); + Expression* makeBrOnNull(Element& s, bool onFail = false); + Expression* + makeBrOnCast(Element& s, std::optional<Type> castType, bool onFail = false); Expression* makeStructNew(Element& s, bool default_); Index getStructIndex(Element& type, Element& field); Expression* makeStructGet(Element& s, bool signed_ = false); |