diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2022-09-23 10:46:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-23 15:46:38 +0000 |
commit | e09fb5656d5e791051393bd08e6522f068ec7fe4 (patch) | |
tree | 4e332c0d970e106fdead031059e14946fd70cc6f /src/passes/Print.cpp | |
parent | e750809428e447396c1568139bf970ce5a1b5aed (diff) | |
download | binaryen-e09fb5656d5e791051393bd08e6522f068ec7fe4.tar.gz binaryen-e09fb5656d5e791051393bd08e6522f068ec7fe4.tar.bz2 binaryen-e09fb5656d5e791051393bd08e6522f068ec7fe4.zip |
Emit call_ref with a type annotation (#5079)
Emit call_ref instructions with type annotations and a temporary opcode. Also
implement support for parsing optional type annotations on call_ref in the text
and binary formats. This is part of a multi-part graceful update to switch
Binaryen and all of its users over to using the type-annotated version of
call_ref without there being any breakage.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 04d487c08..2a031ad01 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2060,23 +2060,17 @@ struct PrintExpressionContents } void visitCallRef(CallRef* curr) { - if (curr->isReturn) { - if (printUnreachableReplacement(curr->target)) { - return; - } - printMedium(o, "return_call_ref "); - assert(curr->target->type != Type::unreachable); - // TODO: Workaround if target has bottom type. - printHeapType(o, curr->target->type.getHeapType(), wasm); - } else { - printMedium(o, "call_ref"); + // TODO: Workaround if target has bottom type. + if (printUnreachableReplacement(curr->target)) { + return; } + printMedium(o, curr->isReturn ? "return_call_ref " : "call_ref "); + printHeapType(o, curr->target->type.getHeapType(), wasm); } void visitRefTest(RefTest* curr) { printMedium(o, "ref.test_static "); printHeapType(o, curr->intendedType, wasm); } - void visitRefCast(RefCast* curr) { if (curr->safety == RefCast::Unsafe) { printMedium(o, "ref.cast_nop_static "); @@ -2085,6 +2079,7 @@ struct PrintExpressionContents } printHeapType(o, curr->intendedType, wasm); } + void visitBrOn(BrOn* curr) { switch (curr->op) { case BrOnNull: @@ -2139,7 +2134,6 @@ struct PrintExpressionContents o << ' '; TypeNamePrinter(o, wasm).print(curr->type.getHeapType()); } - void printFieldName(HeapType type, Index index) { processFieldName(wasm, type, index, [&](Name name) { if (name.is()) { @@ -2755,11 +2749,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { decIndent(); } void visitCallRef(CallRef* curr) { - if (curr->isReturn) { - maybePrintUnreachableReplacement(curr, curr->target->type); - } else { - visitExpression(curr); - } + maybePrintUnreachableReplacement(curr, curr->target->type); } void visitStructNew(StructNew* curr) { maybePrintUnreachableReplacement(curr, curr->type); |