summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-11-24 12:36:11 -0800
committerGitHub <noreply@github.com>2020-11-24 12:36:11 -0800
commit78ccc1976bac069ae65b2ec227e8c2c515a02801 (patch)
treeb875343fa47a62a44db4370811080dc963a91233 /src/passes/Print.cpp
parentcecff82aff317c3132f80a764dba163bcd852a78 (diff)
downloadbinaryen-78ccc1976bac069ae65b2ec227e8c2c515a02801.tar.gz
binaryen-78ccc1976bac069ae65b2ec227e8c2c515a02801.tar.bz2
binaryen-78ccc1976bac069ae65b2ec227e8c2c515a02801.zip
[TypedFunctionReferences] Implement call_ref (#3396)
Includes minimal support in various passes. Also includes actual optimization work in Directize, which was easy to add. Almost has fuzzer support, but the actual makeCallRef is just a stub so far. Includes s-parser support for parsing typed function references types.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index e512d398f..864a46362 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -87,14 +87,35 @@ struct SigName {
};
std::ostream& operator<<(std::ostream& os, SigName sigName) {
- auto printType = [&](Type type) {
+ std::function<void(Type)> printType = [&](Type type) {
if (type == Type::none) {
os << "none";
} else {
auto sep = "";
for (const auto& t : type) {
- os << sep << t;
+ os << sep;
sep = "_";
+ if (t.isRef()) {
+ auto heapType = t.getHeapType();
+ if (heapType.isSignature()) {
+ auto sig = heapType.getSignature();
+ os << "ref";
+ if (t.isNullable()) {
+ os << "_null";
+ }
+ os << "<";
+ for (auto s : sig.params) {
+ printType(s);
+ }
+ os << "_->_";
+ for (auto s : sig.results) {
+ printType(s);
+ }
+ os << ">";
+ continue;
+ }
+ }
+ os << t;
}
}
};
@@ -1561,6 +1582,13 @@ struct PrintExpressionContents
void visitI31Get(I31Get* curr) {
printMedium(o, curr->signed_ ? "i31.get_s" : "i31.get_u");
}
+ void visitCallRef(CallRef* curr) {
+ if (curr->isReturn) {
+ printMedium(o, "return_call_ref");
+ } else {
+ printMedium(o, "call_ref");
+ }
+ }
void visitRefTest(RefTest* curr) {
printMedium(o, "ref.test");
WASM_UNREACHABLE("TODO (gc): ref.test");
@@ -2216,6 +2244,16 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
printFullLine(curr->i31);
decIndent();
}
+ void visitCallRef(CallRef* curr) {
+ o << '(';
+ PrintExpressionContents(currFunction, o).visit(curr);
+ incIndent();
+ for (auto operand : curr->operands) {
+ printFullLine(operand);
+ }
+ printFullLine(curr->target);
+ decIndent();
+ }
void visitRefTest(RefTest* curr) {
o << '(';
PrintExpressionContents(currFunction, o).visit(curr);