Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
if (type.isBasic()) {
return o << type;
}
return o << '$' << typePrinter.getNames(type).name;
return printName(typePrinter.getNames(type).name, o);
}

std::ostream& printPrefixedTypes(const char* prefix, Type type);
Expand Down Expand Up @@ -871,13 +871,15 @@ struct PrintExpressionContents
o << "memory.init";
restoreNormalColor(o);
printMemoryName(curr->memory, o, wasm);
o << " $" << curr->segment;
o << ' ';
printName(curr->segment, o);
}
void visitDataDrop(DataDrop* curr) {
prepareColor(o);
o << "data.drop";
restoreNormalColor(o);
o << " $" << curr->segment;
o << ' ';
printName(curr->segment, o);
}
void visitMemoryCopy(MemoryCopy* curr) {
prepareColor(o);
Expand Down Expand Up @@ -2126,7 +2128,7 @@ struct PrintExpressionContents
void printFieldName(HeapType type, Index index) {
auto names = parent.typePrinter.getNames(type).fieldNames;
if (auto it = names.find(index); it != names.end()) {
o << '$' << it->second;
printName(it->second, o);
} else {
o << index;
}
Expand Down Expand Up @@ -2178,7 +2180,8 @@ struct PrintExpressionContents
printMedium(o, "array.new_data");
o << ' ';
printHeapType(curr->type.getHeapType());
o << " $" << curr->segment;
o << ' ';
printName(curr->segment, o);
}
void visitArrayNewElem(ArrayNewElem* curr) {
if (printUnreachableReplacement(curr)) {
Expand All @@ -2187,7 +2190,8 @@ struct PrintExpressionContents
printMedium(o, "array.new_elem");
o << ' ';
printHeapType(curr->type.getHeapType());
o << " $" << curr->segment;
o << ' ';
printName(curr->segment, o);
}
void visitArrayNewFixed(ArrayNewFixed* curr) {
if (printUnreachableReplacement(curr)) {
Expand Down Expand Up @@ -2246,15 +2250,17 @@ struct PrintExpressionContents
}
printMedium(o, "array.init_data ");
printHeapType(curr->ref->type.getHeapType());
o << " $" << curr->segment;
o << ' ';
printName(curr->segment, o);
}
void visitArrayInitElem(ArrayInitElem* curr) {
if (printUnreachableOrNullReplacement(curr->ref)) {
return;
}
printMedium(o, "array.init_elem ");
printHeapType(curr->ref->type.getHeapType());
o << " $" << curr->segment;
o << ' ';
printName(curr->segment, o);
}
void visitRefAs(RefAs* curr) {
switch (curr->op) {
Expand Down Expand Up @@ -2866,7 +2872,8 @@ void PrintSExpression::handleSignature(HeapType curr, Name name) {
Signature sig = curr.getSignature();
o << "(func";
if (name.is()) {
o << " $" << name;
o << ' ';
printName(name, o);
if (currModule && currModule->features.hasGC()) {
o << " (type ";
printHeapType(curr) << ')';
Expand Down Expand Up @@ -3225,7 +3232,9 @@ void PrintSExpression::visitDataSegment(DataSegment* curr) {
if (!curr->isPassive) {
assert(!currModule || currModule->memories.size() > 0);
if (!currModule || curr->memory != currModule->memories[0]->name) {
o << "(memory $" << curr->memory << ") ";
o << "(memory ";
printName(curr->memory, o);
o << ") ";
}
visit(curr->offset);
o << ' ';
Expand Down
2 changes: 1 addition & 1 deletion test/lit/ctor-eval/array_new_data.wast
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

;; CHECK: (func $test (type $0)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (array.new_data $[i8] $1
;; CHECK-NEXT: (array.new_data $"[i8]" $1
;; CHECK-NEXT: (i32.const 16)
;; CHECK-NEXT: (i32.const 8)
;; CHECK-NEXT: )
Expand Down
12 changes: 6 additions & 6 deletions test/lit/passes/dae-gc-refine-params.wast
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
;; CHECK-NEXT: (local.get $y)
;; CHECK-NEXT: )
;; CHECK-NEXT: (local.set $2
;; CHECK-NEXT: (struct.new_default ${})
;; CHECK-NEXT: (struct.new_default $"{}")
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.get $2)
Expand Down Expand Up @@ -352,7 +352,7 @@

;; CHECK: (func $call-non-nullable-fixup (type $0)
;; CHECK-NEXT: (call $non-nullable-fixup
;; CHECK-NEXT: (struct.new_default ${})
;; CHECK-NEXT: (struct.new_default $"{}")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $call-non-nullable-fixup
Expand All @@ -366,7 +366,7 @@
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: )
;; CHECK-NEXT: (call $update-null
;; CHECK-NEXT: (struct.new_default ${})
;; CHECK-NEXT: (struct.new_default $"{}")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $call-update-null
Expand Down Expand Up @@ -395,7 +395,7 @@
;; CHECK: (func $"get_null_{i32}" (type $5) (result (ref null ${i32}))
;; CHECK-NEXT: (select (result (ref null ${i32}))
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: (struct.new_default ${i32})
;; CHECK-NEXT: (struct.new_default $"{i32}")
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand All @@ -412,7 +412,7 @@
;; CHECK: (func $"get_null_{i32_i64}" (type $16) (result (ref null ${i32_i64}))
;; CHECK-NEXT: (select (result (ref null ${i32_i64}))
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: (struct.new_default ${i32_i64})
;; CHECK-NEXT: (struct.new_default $"{i32_i64}")
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand All @@ -427,7 +427,7 @@
;; CHECK: (func $"get_null_{i32_f32}" (type $17) (result (ref null ${i32_f32}))
;; CHECK-NEXT: (select (result (ref null ${i32_f32}))
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: (struct.new_default ${i32_f32})
;; CHECK-NEXT: (struct.new_default $"{i32_f32}")
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand Down
24 changes: 12 additions & 12 deletions test/lit/passes/dae-gc-refine-return.wast
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@

;; Show that we can optimize the return type of a function that does a tail
;; call.
;; CHECK: (func $tail-callee (type $return_{}) (result (ref ${}))
;; CHECK: (func $tail-callee (type $"return_{}") (result (ref ${}))
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
(func $tail-callee (result (ref $"{}"))
(unreachable)
)
;; CHECK: (func $tail-caller-yes (type $return_{}) (result (ref ${}))
;; CHECK: (func $tail-caller-yes (type $"return_{}") (result (ref ${}))
;; CHECK-NEXT: (return_call $tail-callee)
;; CHECK-NEXT: )
(func $tail-caller-yes (result anyref)
Expand Down Expand Up @@ -367,14 +367,14 @@
)

;; As above, but with an indirect tail call.
;; CHECK: (func $tail-callee-indirect (type $return_{}) (result (ref ${}))
;; CHECK: (func $tail-callee-indirect (type $"return_{}") (result (ref ${}))
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
(func $tail-callee-indirect (result (ref $"{}"))
(unreachable)
)
;; CHECK: (func $tail-caller-indirect-yes (type $return_{}) (result (ref ${}))
;; CHECK-NEXT: (return_call_indirect $0 (type $return_{})
;; CHECK: (func $tail-caller-indirect-yes (type $"return_{}") (result (ref ${}))
;; CHECK-NEXT: (return_call_indirect $0 (type $"return_{}")
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand All @@ -391,7 +391,7 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (return_call_indirect $0 (type $return_{})
;; CHECK-NEXT: (return_call_indirect $0 (type $"return_{}")
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand Down Expand Up @@ -423,15 +423,15 @@
)

;; As above, but with a tail call by function reference.
;; CHECK: (func $tail-callee-call_ref (type $return_{}) (result (ref ${}))
;; CHECK: (func $tail-callee-call_ref (type $"return_{}") (result (ref ${}))
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
(func $tail-callee-call_ref (result (ref $"{}"))
(unreachable)
)
;; CHECK: (func $tail-caller-call_ref-yes (type $return_{}) (result (ref ${}))
;; CHECK: (func $tail-caller-call_ref-yes (type $"return_{}") (result (ref ${}))
;; CHECK-NEXT: (local $"return_{}" (ref null $return_{}))
;; CHECK-NEXT: (return_call_ref $return_{}
;; CHECK-NEXT: (return_call_ref $"return_{}"
;; CHECK-NEXT: (local.get $"return_{}")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand All @@ -451,7 +451,7 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (return_call_ref $return_{}
;; CHECK-NEXT: (return_call_ref $"return_{}"
;; CHECK-NEXT: (local.get $"return_{}")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand Down Expand Up @@ -510,7 +510,7 @@
;; CHECK-NEXT: (local.get $y)
;; CHECK-NEXT: (then
;; CHECK-NEXT: (return
;; CHECK-NEXT: (struct.new_default ${i32_f32})
;; CHECK-NEXT: (struct.new_default $"{i32_f32}")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (else
Expand All @@ -522,7 +522,7 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: (else
;; CHECK-NEXT: (return
;; CHECK-NEXT: (struct.new_default ${i32_i64})
;; CHECK-NEXT: (struct.new_default $"{i32_i64}")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand Down
4 changes: 2 additions & 2 deletions test/lit/passes/merge-similar-functions_all-features.wast
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: (call $take-ref-null-array
;; CHECK-NEXT: (array.new_fixed $[i8] 0)
;; CHECK-NEXT: (array.new_fixed $"[i8]" 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $no-call-subtyping-same-operand-0
Expand Down Expand Up @@ -82,7 +82,7 @@
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: (call $take-ref-eq
;; CHECK-NEXT: (array.new_fixed $[i8] 0)
;; CHECK-NEXT: (array.new_fixed $"[i8]" 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $no-call-subtyping-same-operand-1
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/signature-refining.wast
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@

;; CHECK: (func $0 (type $2)
;; CHECK-NEXT: (call $1
;; CHECK-NEXT: (array.new_fixed $[i8] 0)
;; CHECK-NEXT: (array.new_fixed $"[i8]" 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $0
Expand Down