diff options
author | Thomas Lively <tlively@google.com> | 2023-01-05 16:57:27 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-05 14:57:27 -0800 |
commit | ad38ddefb3728aaef0df69bd265412a38bcfd20d (patch) | |
tree | e7c0fff79ef26f425de3077f995150328524adf2 /src/passes/Print.cpp | |
parent | d623ba4b075aa1d70113fc41172a9ed248e0011d (diff) | |
download | binaryen-ad38ddefb3728aaef0df69bd265412a38bcfd20d.tar.gz binaryen-ad38ddefb3728aaef0df69bd265412a38bcfd20d.tar.bz2 binaryen-ad38ddefb3728aaef0df69bd265412a38bcfd20d.zip |
Support br_on_cast null (#5397)
As well as br_on_cast_fail null. Unlike the existing br_on_cast* instructions,
these new instructions treat the cast as succeeding when the input is a null.
Update the internal representation of the cast type in `BrOn` expressions to be
a `Type` rather than a `HeapType` so it will include nullability information.
Also update and improve `RemoveUnusedBrs` to handle the new instructions
correctly and optimize in more cases.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 81e3ae989..c1064b7db 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2143,13 +2143,19 @@ struct PrintExpressionContents printMedium(o, "br_on_cast "); printName(curr->name, o); o << ' '; - printHeapType(o, curr->intendedType, wasm); + if (curr->castType.isNullable()) { + printMedium(o, "null "); + } + printHeapType(o, curr->castType.getHeapType(), wasm); return; case BrOnCastFail: printMedium(o, "br_on_cast_fail "); printName(curr->name, o); o << ' '; - printHeapType(o, curr->intendedType, wasm); + if (curr->castType.isNullable()) { + printMedium(o, "null "); + } + printHeapType(o, curr->castType.getHeapType(), wasm); return; case BrOnFunc: printMedium(o, "br_on_func "); |