aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2022-03-02 22:18:45 +0100
committerAndrew Kelley <andrew@ziglang.org>2022-03-03 16:33:46 -0700
commitec4c30ae483e6700a1fd1d5edaadbb042790c52e (patch)
tree72a0cc5ffcf656a1654cd3adbf7fd3d6f06aa525 /src/codegen
parent0ea51f7f494cd84a48fd997b60196d6c4254ccac (diff)
downloadzig-ec4c30ae483e6700a1fd1d5edaadbb042790c52e.tar.gz
zig-ec4c30ae483e6700a1fd1d5edaadbb042790c52e.zip
wasm: Implement `@wasmMemorySize()` builtin
This implements the `wasmMemorySize` builtin, in Sema and the Wasm backend. The Stage2 implementation differs from stage1 in the way that `index` must be a comptime value. The stage1 variant is incorrect, as the index is part of the instruction encoding, and therefore, cannot be a runtime value.
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/llvm.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 252d449fc2..a22d8e01b0 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -2314,6 +2314,8 @@ pub const FuncGen = struct {
.wrap_errunion_payload => try self.airWrapErrUnionPayload(inst),
.wrap_errunion_err => try self.airWrapErrUnionErr(inst),
+ .wasm_memory_size => try self.airWasmMemorySize(inst),
+
.constant => unreachable,
.const_ty => unreachable,
.unreach => self.airUnreach(inst),
@@ -3474,6 +3476,11 @@ pub const FuncGen = struct {
return partial;
}
+ fn airWasmMemorySize(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
+ _ = inst;
+ return self.todo("`@wasmMemorySize()`", .{});
+ }
+
fn airMin(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
if (self.liveness.isUnused(inst)) return null;