summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-05-04 16:44:09 -0700
committerGitHub <noreply@github.com>2023-05-04 16:44:09 -0700
commit7f8e4cbf6273c9b13b3a1a42f5e2833ea0d0f686 (patch)
treecc0343495b994c67a01b5143e6345d45a1c3587d /src/passes/Print.cpp
parent09fe432c0d3cb7562767a8e06d4e918beb5990c2 (diff)
downloadbinaryen-7f8e4cbf6273c9b13b3a1a42f5e2833ea0d0f686.tar.gz
binaryen-7f8e4cbf6273c9b13b3a1a42f5e2833ea0d0f686.tar.bz2
binaryen-7f8e4cbf6273c9b13b3a1a42f5e2833ea0d0f686.zip
[NFC] Refactor each of ArrayNewSeg and ArrayInit into subclasses for Data/Elem (#5692)
ArrayNewSeg => ArrayNewSegData, ArrayNewSegElem ArrayInit => ArrayInitData, ArrayInitElem Basically we remove the opcode and use the class type to differentiate them. This adds some code but it makes the representation simpler and more compact in memory, and it will help with #5690
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 650a17203..76fd53759 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -2265,21 +2265,20 @@ struct PrintExpressionContents
o << ' ';
TypeNamePrinter(o, wasm).print(curr->type.getHeapType());
}
- void visitArrayNewSeg(ArrayNewSeg* curr) {
+ void visitArrayNewData(ArrayNewData* curr) {
if (printUnreachableReplacement(curr)) {
return;
}
- printMedium(o, "array.new_");
- switch (curr->op) {
- case NewData:
- printMedium(o, "data");
- break;
- case NewElem:
- printMedium(o, "elem");
- break;
- default:
- WASM_UNREACHABLE("unexpected op");
+ printMedium(o, "array.new_data");
+ o << ' ';
+ TypeNamePrinter(o, wasm).print(curr->type.getHeapType());
+ o << " $" << curr->segment;
+ }
+ void visitArrayNewElem(ArrayNewElem* curr) {
+ if (printUnreachableReplacement(curr)) {
+ return;
}
+ printMedium(o, "array.new_elem");
o << ' ';
TypeNamePrinter(o, wasm).print(curr->type.getHeapType());
o << " $" << curr->segment;
@@ -2333,20 +2332,19 @@ struct PrintExpressionContents
printMedium(o, "array.fill ");
TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType());
}
- void visitArrayInit(ArrayInit* curr) {
+ void visitArrayInitData(ArrayInitData* curr) {
if (printUnreachableOrNullReplacement(curr->ref)) {
return;
}
- switch (curr->op) {
- case InitData:
- printMedium(o, "array.init_data ");
- break;
- case InitElem:
- printMedium(o, "array.init_elem ");
- break;
- default:
- WASM_UNREACHABLE("unexpected op");
+ printMedium(o, "array.init_data ");
+ TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType());
+ o << " $" << curr->segment;
+ }
+ void visitArrayInitElem(ArrayInitElem* curr) {
+ if (printUnreachableOrNullReplacement(curr->ref)) {
+ return;
}
+ printMedium(o, "array.init_elem ");
TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType());
o << " $" << curr->segment;
}
@@ -2915,7 +2913,10 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
void visitArrayNew(ArrayNew* curr) {
maybePrintUnreachableReplacement(curr, curr->type);
}
- void visitArrayNewSeg(ArrayNewSeg* curr) {
+ void visitArrayNewData(ArrayNewData* curr) {
+ maybePrintUnreachableReplacement(curr, curr->type);
+ }
+ void visitArrayNewElem(ArrayNewElem* curr) {
maybePrintUnreachableReplacement(curr, curr->type);
}
void visitArrayNewFixed(ArrayNewFixed* curr) {