summaryrefslogtreecommitdiff
path: root/src/wasm-builder.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-09-23 12:36:17 -0700
committerGitHub <noreply@github.com>2021-09-23 12:36:17 -0700
commit675295888609a688ee81dc9ad2024169da5aa7ed (patch)
tree796dc5d72867300f97ab234e40729ae6b7db2875 /src/wasm-builder.h
parent6d46b436b54bdae040a64bd9dafb01a7f53a8233 (diff)
downloadbinaryen-675295888609a688ee81dc9ad2024169da5aa7ed.tar.gz
binaryen-675295888609a688ee81dc9ad2024169da5aa7ed.tar.bz2
binaryen-675295888609a688ee81dc9ad2024169da5aa7ed.zip
[Wasm GC] Implement static (rtt-free) StructNew, ArrayNew, ArrayInit (#4172)
See #4149 This modifies the test added in #4163 which used static casts on dynamically-created structs and arrays. That was technically not valid (as we won't want users to "mix" the two forms). This makes that test 100% static, which both fixes the test and gives test coverage to the new instructions added here.
Diffstat (limited to 'src/wasm-builder.h')
-rw-r--r--src/wasm-builder.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index 346f2f5ba..f992b1e03 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -836,6 +836,13 @@ public:
ret->finalize();
return ret;
}
+ template<typename T> StructNew* makeStructNew(HeapType type, const T& args) {
+ auto* ret = wasm.allocator.alloc<StructNew>();
+ ret->operands.set(args);
+ ret->type = Type(type, NonNullable);
+ ret->finalize();
+ return ret;
+ }
StructGet*
makeStructGet(Index index, Expression* ref, Type type, bool signed_ = false) {
auto* ret = wasm.allocator.alloc<StructGet>();
@@ -863,6 +870,15 @@ public:
ret->finalize();
return ret;
}
+ ArrayNew*
+ makeArrayNew(HeapType type, Expression* size, Expression* init = nullptr) {
+ auto* ret = wasm.allocator.alloc<ArrayNew>();
+ ret->size = size;
+ ret->init = init;
+ ret->type = Type(type, NonNullable);
+ ret->finalize();
+ return ret;
+ }
ArrayInit* makeArrayInit(Expression* rtt,
const std::vector<Expression*>& values) {
auto* ret = wasm.allocator.alloc<ArrayInit>();
@@ -871,6 +887,14 @@ public:
ret->finalize();
return ret;
}
+ ArrayInit* makeArrayInit(HeapType type,
+ const std::vector<Expression*>& values) {
+ auto* ret = wasm.allocator.alloc<ArrayInit>();
+ ret->values.set(values);
+ ret->type = Type(type, NonNullable);
+ ret->finalize();
+ return ret;
+ }
ArrayGet*
makeArrayGet(Expression* ref, Expression* index, bool signed_ = false) {
auto* ret = wasm.allocator.alloc<ArrayGet>();