aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2022-03-03 22:12:53 +0100
committerAndrew Kelley <andrew@ziglang.org>2022-03-03 16:33:46 -0700
commit7fd32de0180c29dc4e3da72e9347f6f5ce167a38 (patch)
tree6c72da6895e5da86988f6ed606eb98eee85c39ab /src/Sema.zig
parent21f0503c0137b7bb59edd87e17e1649152d342ba (diff)
downloadzig-7fd32de0180c29dc4e3da72e9347f6f5ce167a38.tar.gz
zig-7fd32de0180c29dc4e3da72e9347f6f5ce167a38.zip
cbe: Implement wasm builtins
This implements the wasm builtins by lowering to builtins that are supported by c-compilers. In this case: Clang. This also simplifies the `AIR` instruction as it now uses the payload field of `ty_pl` and `pl_op` directly to store the index argument rather than storing it inside Extra. This saves us 4 bytes per builtin call.
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index a8dc872a99..65536cdbde 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -14034,7 +14034,7 @@ fn zirWasmMemorySize(
) CompileError!Air.Inst.Ref {
const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
const src: LazySrcLoc = .{ .node_offset = extra.node };
- if (!sema.mod.getTarget().isWasm()) {
+ if (!sema.mod.getTarget().isWasm() and sema.mod.comp.bin_file.options.object_format != .c) {
return sema.fail(block, src, "builtin '@wasmMemorySize' is a wasm feature only", .{});
}
@@ -14045,7 +14045,7 @@ fn zirWasmMemorySize(
.tag = .wasm_memory_size,
.data = .{ .ty_pl = .{
.ty = try sema.addType(Type.u32),
- .payload = try sema.addExtra(Air.WasmMemoryIndex{ .index = index }),
+ .payload = index,
} },
});
}
@@ -14057,7 +14057,7 @@ fn zirWasmMemoryGrow(
) CompileError!Air.Inst.Ref {
const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
const src: LazySrcLoc = .{ .node_offset = extra.node };
- if (!sema.mod.getTarget().isWasm()) {
+ if (!sema.mod.getTarget().isWasm() and sema.mod.comp.bin_file.options.object_format != .c) {
return sema.fail(block, src, "builtin '@wasmMemoryGrow' is a wasm feature only", .{});
}
@@ -14070,7 +14070,7 @@ fn zirWasmMemoryGrow(
.tag = .wasm_memory_grow,
.data = .{ .pl_op = .{
.operand = delta_arg,
- .payload = try sema.addExtra(Air.WasmMemoryIndex{ .index = index }),
+ .payload = index,
} },
});
}