aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2022-03-03 19:10:58 +0100
committerAndrew Kelley <andrew@ziglang.org>2022-03-03 16:33:46 -0700
commit43cb19ea4da63dcaa8a18a06e3ab23f1c822c1fe (patch)
treecb5cb5fd83ddb948f5d3fddc7819849fb2154006 /src/codegen
parentec4c30ae483e6700a1fd1d5edaadbb042790c52e (diff)
downloadzig-43cb19ea4da63dcaa8a18a06e3ab23f1c822c1fe.tar.gz
zig-43cb19ea4da63dcaa8a18a06e3ab23f1c822c1fe.zip
wasm: Implement `@wasmMemoryGrow` builtin
Similarly to the other wasm builtin, this implements the grow variation where the memory index is a comptime known value. The operand as well as the result are runtime values. This also verifies during semantic analysis the target we're building for is wasm, or else emits a compilation error. This means that other backends do not have to handle this AIR instruction, other than the wasm and LLVM backends.
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/c.zig3
-rw-r--r--src/codegen/llvm.zig7
2 files changed, 9 insertions, 1 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 3e47637c76..988576a6f1 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -1758,6 +1758,9 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO
.wrap_errunion_payload => try airWrapErrUnionPay(f, inst),
.wrap_errunion_err => try airWrapErrUnionErr(f, inst),
.errunion_payload_ptr_set => try airErrUnionPayloadPtrSet(f, inst),
+
+ .wasm_memory_size => unreachable,
+ .wasm_memory_grow => unreachable,
// zig fmt: on
};
switch (result_value) {
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index a22d8e01b0..3e1be05d55 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -3478,7 +3478,12 @@ pub const FuncGen = struct {
fn airWasmMemorySize(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
_ = inst;
- return self.todo("`@wasmMemorySize()`", .{});
+ return self.todo("implement builtin `@wasmMemorySize()`", .{});
+ }
+
+ fn airWasmMemoryGrow(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
+ _ = inst;
+ return self.todo("implement builtin `@wasmMemoryGrow()`", .{});
}
fn airMin(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {