aboutsummaryrefslogtreecommitdiff
path: root/src/AstGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-03 18:31:55 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-03 18:31:55 -0700
commite532b0c0b5d55d212d885c779ab9f2fa7443e56a (patch)
tree0a1e9b277c745518f2b64d8913fe5e065fe9cc1b /src/AstGen.zig
parent7fd32de0180c29dc4e3da72e9347f6f5ce167a38 (diff)
downloadzig-e532b0c0b5d55d212d885c779ab9f2fa7443e56a.tar.gz
zig-e532b0c0b5d55d212d885c779ab9f2fa7443e56a.zip
stage2: cleanups to wasm memory intrinsics
* AIR: use pl_op instead of ty_pl for wasm_memory_size. No need to store the type because the type is always `u32`. * AstGen: use coerced_ty for `@wasmMemorySize` and `@wasmMemoryGrow` and do the coercions in Sema. * Sema: use more accurate source locations for errors. * Provide more information in the compiler error message. * Codegen: use liveness data to avoid lowering unused `@wasmMemorySize`. * LLVM backend: add implementation - I wasn't able to test it because we are hitting a linker error for `-target wasm32-wasi -fLLVM`. * C backend: use `zig_unimplemented()` instead of silently doing wrong behavior for these builtins. * behavior tests: branch only on stage2_arch for inclusion of the wasm.zig file. We would change it to `builtin.cpu.arch` but that is causing a compiler crash on some backends.
Diffstat (limited to 'src/AstGen.zig')
-rw-r--r--src/AstGen.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig
index d6d29d4a54..3fe9630c75 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -7140,7 +7140,7 @@ fn builtinCall(
// zig fmt: on
.wasm_memory_size => {
- const operand = try comptimeExpr(gz, scope, .{ .ty = .u32_type }, params[0]);
+ const operand = try comptimeExpr(gz, scope, .{ .coerced_ty = .u32_type }, params[0]);
const result = try gz.addExtendedPayload(.wasm_memory_size, Zir.Inst.UnNode{
.node = gz.nodeIndexToRelative(node),
.operand = operand,
@@ -7148,8 +7148,8 @@ fn builtinCall(
return rvalue(gz, rl, result, node);
},
.wasm_memory_grow => {
- const index_arg = try comptimeExpr(gz, scope, .{ .ty = .u32_type }, params[0]);
- const delta_arg = try expr(gz, scope, .{ .ty = .u32_type }, params[1]);
+ const index_arg = try comptimeExpr(gz, scope, .{ .coerced_ty = .u32_type }, params[0]);
+ const delta_arg = try expr(gz, scope, .{ .coerced_ty = .u32_type }, params[1]);
const result = try gz.addExtendedPayload(.wasm_memory_grow, Zir.Inst.BinNode{
.node = gz.nodeIndexToRelative(node),
.lhs = index_arg,