summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-02-09 22:53:11 +0000
committerGitHub <noreply@github.com>2021-02-09 14:53:11 -0800
commit2b63a468d84bd5b9d57f450ac5a8f4bf356ddee9 (patch)
treee34da32413b2c18cfc10e615ce2709c79fa2f9cb /src
parent9752196fd1357fbc129d1e4f53e8eb22cd6219f9 (diff)
downloadbinaryen-2b63a468d84bd5b9d57f450ac5a8f4bf356ddee9.tar.gz
binaryen-2b63a468d84bd5b9d57f450ac5a8f4bf356ddee9.tar.bz2
binaryen-2b63a468d84bd5b9d57f450ac5a8f4bf356ddee9.zip
[GC] Support RTT constants in Builder::makeConstantExpression (#3550)
This allows the reducer to operate on RTTs, but could help other things too.
Diffstat (limited to 'src')
-rw-r--r--src/tools/fuzzing.h8
-rw-r--r--src/wasm-builder.h15
2 files changed, 16 insertions, 7 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h
index 714e2c84b..f13b99c3d 100644
--- a/src/tools/fuzzing.h
+++ b/src/tools/fuzzing.h
@@ -2120,13 +2120,7 @@ private:
return builder.makeRefFunc(func->name, type);
}
if (type.isRtt()) {
- Expression* ret = builder.makeRttCanon(type.getHeapType());
- if (type.getRtt().hasDepth()) {
- for (Index i = 0; i < type.getRtt().depth; i++) {
- ret = builder.makeRttSub(type.getHeapType(), ret);
- }
- }
- return ret;
+ return builder.makeRtt(type);
}
if (type.isTuple()) {
std::vector<Expression*> operands;
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index 6fc5c4dda..3a4ae97c1 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -838,6 +838,9 @@ public:
if (type.isFunction()) {
return makeRefFunc(value.getFunc(), type);
}
+ if (type.isRtt()) {
+ return makeRtt(value.type);
+ }
TODO_SINGLE_COMPOUND(type);
switch (type.getBasic()) {
case Type::externref:
@@ -865,6 +868,18 @@ public:
}
}
+ // Given a type, creates an RTT expression of that type, using a combination
+ // of rtt.canon and rtt.subs.
+ Expression* makeRtt(Type type) {
+ Expression* ret = makeRttCanon(type.getHeapType());
+ if (type.getRtt().hasDepth()) {
+ for (Index i = 0; i < type.getRtt().depth; i++) {
+ ret = makeRttSub(type.getHeapType(), ret);
+ }
+ }
+ return ret;
+ }
+
// Additional utility functions for building on top of nodes
// Convenient to have these on Builder, as it has allocation built in