summaryrefslogtreecommitdiff
path: root/src/ir
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-11-06 12:29:19 -0800
committerGitHub <noreply@github.com>2023-11-06 12:29:19 -0800
commite3d27166370da202bef6c012014604beac41d43f (patch)
treef9e0515c0c6044e6c9b12f6d5d83f8ba99ab0fc3 /src/ir
parent4fba26a77ea344b8d2b49cc8e1afdc8fcda13e96 (diff)
downloadbinaryen-e3d27166370da202bef6c012014604beac41d43f.tar.gz
binaryen-e3d27166370da202bef6c012014604beac41d43f.tar.bz2
binaryen-e3d27166370da202bef6c012014604beac41d43f.zip
Implement table.copy (#6078)
Helps #5951
Diffstat (limited to 'src/ir')
-rw-r--r--src/ir/ReFinalize.cpp1
-rw-r--r--src/ir/cost.h3
-rw-r--r--src/ir/effects.h5
-rw-r--r--src/ir/possible-contents.cpp1
4 files changed, 10 insertions, 0 deletions
diff --git a/src/ir/ReFinalize.cpp b/src/ir/ReFinalize.cpp
index bfdcfe7a6..3d74b1422 100644
--- a/src/ir/ReFinalize.cpp
+++ b/src/ir/ReFinalize.cpp
@@ -125,6 +125,7 @@ void ReFinalize::visitTableSet(TableSet* curr) { curr->finalize(); }
void ReFinalize::visitTableSize(TableSize* curr) { curr->finalize(); }
void ReFinalize::visitTableGrow(TableGrow* curr) { curr->finalize(); }
void ReFinalize::visitTableFill(TableFill* curr) { curr->finalize(); }
+void ReFinalize::visitTableCopy(TableCopy* curr) { curr->finalize(); }
void ReFinalize::visitTry(Try* curr) { curr->finalize(); }
void ReFinalize::visitThrow(Throw* curr) { curr->finalize(); }
void ReFinalize::visitRethrow(Rethrow* curr) { curr->finalize(); }
diff --git a/src/ir/cost.h b/src/ir/cost.h
index efc50eb1b..d3a483535 100644
--- a/src/ir/cost.h
+++ b/src/ir/cost.h
@@ -577,6 +577,9 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, CostType> {
CostType visitTableFill(TableFill* curr) {
return 6 + visit(curr->dest) + visit(curr->value) + visit(curr->size);
}
+ CostType visitTableCopy(TableCopy* curr) {
+ return 6 + visit(curr->dest) + visit(curr->source) + visit(curr->size);
+ }
CostType visitTry(Try* curr) {
// We assume no exception will be thrown in most cases
return visit(curr->body);
diff --git a/src/ir/effects.h b/src/ir/effects.h
index 9bdf08c74..0e45ec70c 100644
--- a/src/ir/effects.h
+++ b/src/ir/effects.h
@@ -696,6 +696,11 @@ private:
parent.writesTable = true;
parent.implicitTrap = true;
}
+ void visitTableCopy(TableCopy* curr) {
+ parent.readsTable = true;
+ parent.writesTable = true;
+ parent.implicitTrap = true;
+ }
void visitTry(Try* curr) {
if (curr->delegateTarget.is()) {
parent.delegateTargets.insert(curr->delegateTarget);
diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp
index 06d380a95..7c9a4fc6b 100644
--- a/src/ir/possible-contents.cpp
+++ b/src/ir/possible-contents.cpp
@@ -662,6 +662,7 @@ struct InfoCollector
void visitTableSize(TableSize* curr) { addRoot(curr); }
void visitTableGrow(TableGrow* curr) { addRoot(curr); }
void visitTableFill(TableFill* curr) { addRoot(curr); }
+ void visitTableCopy(TableCopy* curr) { addRoot(curr); }
void visitNop(Nop* curr) {}
void visitUnreachable(Unreachable* curr) {}