diff options
author | Abbas Mashayekh <martianboy2005@gmail.com> | 2021-02-10 01:17:28 +0330 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-09 13:47:28 -0800 |
commit | 3da8b08ecd57f5662bebc69ea73bf59e1928341e (patch) | |
tree | 2902eedc161579eaf37a1aed463de95916eee703 /src/passes/Print.cpp | |
parent | a12a8250da24aa5b5787bf89562b243fdc514302 (diff) | |
download | binaryen-3da8b08ecd57f5662bebc69ea73bf59e1928341e.tar.gz binaryen-3da8b08ecd57f5662bebc69ea73bf59e1928341e.tar.bz2 binaryen-3da8b08ecd57f5662bebc69ea73bf59e1928341e.zip |
[reference-types] remove single table restriction in IR (#3517)
Adds support for modules with multiple tables. Adds a field for the table name to `CallIndirect` and updates the C/JS APIs accordingly.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index b7b7e1320..e49735af0 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -303,10 +303,18 @@ struct PrintExpressionContents } void visitCallIndirect(CallIndirect* curr) { if (curr->isReturn) { - printMedium(o, "return_call_indirect (type "); + printMedium(o, "return_call_indirect "); } else { - printMedium(o, "call_indirect (type "); + printMedium(o, "call_indirect "); } + + if (features.hasReferenceTypes()) { + printName(curr->table, o); + o << ' '; + } + + o << '('; + printMinor(o, "type "); printHeapTypeName(o, curr->sig); o << ')'; } @@ -1936,8 +1944,8 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { const char* maybeSpace; const char* maybeNewLine; - bool full = false; // whether to not elide nodes in output when possible - // (like implicit blocks) and to emit types + bool full = false; // whether to not elide nodes in output when possible + // (like implicit blocks) and to emit types bool stackIR = false; // whether to print stack IR if it is present // (if false, and Stack IR is there, we just // note it exists) @@ -2962,14 +2970,11 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { o << " funcref)"; } void visitTable(Table* curr) { - if (!curr->exists) { - return; - } if (curr->imported()) { doIndent(o, indent); o << '('; emitImportHeader(curr); - printTableHeader(&currModule->table); + printTableHeader(curr); o << ')' << maybeNewLine; } else { doIndent(o, indent); @@ -2983,8 +2988,23 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { } doIndent(o, indent); o << '('; - printMajor(o, "elem "); + printMedium(o, "elem "); + + // TODO(reference-types): check for old-style based on the complete spec + if (currModule->tables.size() > 1) { + // tableuse + o << '('; + printMedium(o, "table "); + printName(curr->name, o); + o << ") "; + } + visit(segment.offset); + + if (currModule->tables.size() > 1) { + o << " func"; + } + for (auto name : segment.data) { o << ' '; printName(name, o); @@ -3334,6 +3354,7 @@ printStackIR(StackIR* ir, std::ostream& o, Function* func) { if (inst->origin->is<Pop>()) { break; } + PrintExpressionContents(func, o).visit(inst->origin); break; } |