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.
This commit is contained in:
Luuk de Gram
2022-03-02 22:18:45 +01:00
committed by Andrew Kelley
parent 0ea51f7f49
commit ec4c30ae48
9 changed files with 54 additions and 5 deletions

View File

@@ -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;