diff options
author | Alon Zakai <azakai@google.com> | 2021-09-23 12:36:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-23 12:36:17 -0700 |
commit | 675295888609a688ee81dc9ad2024169da5aa7ed (patch) | |
tree | 796dc5d72867300f97ab234e40729ae6b7db2875 /src/passes/Print.cpp | |
parent | 6d46b436b54bdae040a64bd9dafb01a7f53a8233 (diff) | |
download | binaryen-675295888609a688ee81dc9ad2024169da5aa7ed.tar.gz binaryen-675295888609a688ee81dc9ad2024169da5aa7ed.tar.bz2 binaryen-675295888609a688ee81dc9ad2024169da5aa7ed.zip |
[Wasm GC] Implement static (rtt-free) StructNew, ArrayNew, ArrayInit (#4172)
See #4149
This modifies the test added in #4163 which used static casts on
dynamically-created structs and arrays. That was technically not
valid (as we won't want users to "mix" the two forms). This makes that
test 100% static, which both fixes the test and gives test coverage
to the new instructions added here.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 6198218d8..6a41961a2 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1985,15 +1985,18 @@ struct PrintExpressionContents } void visitStructNew(StructNew* curr) { - if (printUnreachableReplacement(curr->rtt)) { + if (printUnreachableReplacement(curr)) { return; } - printMedium(o, "struct.new_"); + printMedium(o, "struct.new"); if (curr->isWithDefault()) { - o << "default_"; + printMedium(o, "_default"); } - o << "with_rtt "; - TypeNamePrinter(o, wasm).print(curr->rtt->type.getHeapType()); + if (curr->rtt) { + printMedium(o, "_with_rtt"); + } + o << ' '; + TypeNamePrinter(o, wasm).print(curr->type.getHeapType()); } void printFieldName(HeapType type, Index index) { @@ -2035,16 +2038,29 @@ struct PrintExpressionContents printFieldName(heapType, curr->index); } void visitArrayNew(ArrayNew* curr) { - printMedium(o, "array.new_"); + if (printUnreachableReplacement(curr)) { + return; + } + printMedium(o, "array.new"); if (curr->isWithDefault()) { - o << "default_"; + printMedium(o, "_default"); + } + if (curr->rtt) { + printMedium(o, "_with_rtt"); } - o << "with_rtt "; - TypeNamePrinter(o, wasm).print(curr->rtt->type.getHeapType()); + o << ' '; + TypeNamePrinter(o, wasm).print(curr->type.getHeapType()); } void visitArrayInit(ArrayInit* curr) { - printMedium(o, "array.init "); - TypeNamePrinter(o, wasm).print(curr->rtt->type.getHeapType()); + if (printUnreachableReplacement(curr)) { + return; + } + printMedium(o, "array.init"); + if (!curr->rtt) { + printMedium(o, "_static"); + } + o << ' '; + TypeNamePrinter(o, wasm).print(curr->type.getHeapType()); } void visitArrayGet(ArrayGet* curr) { if (printUnreachableReplacement(curr->ref)) { |