aboutsummaryrefslogtreecommitdiff
path: root/src/arch/wasm/CodeGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-11-01 20:20:11 -0400
committerGitHub <noreply@github.com>2023-11-01 20:20:11 -0400
commitd892665694bc437898c58631cc632bc93a528e97 (patch)
tree4aec2dd82c6ecb382a6601d8518cad2dc1ea6236 /src/arch/wasm/CodeGen.zig
parent3ead829de191daa0bb4047aa4dfde3b1902e5cd2 (diff)
parentdb1825e93159f753207f255ad6709074fece6dc5 (diff)
downloadzig-d892665694bc437898c58631cc632bc93a528e97.tar.gz
zig-d892665694bc437898c58631cc632bc93a528e97.zip
Merge pull request #17819 from Luukdegram/wasm-bitcast-fix
wasm - fix bitcasting between arrays and scalar types
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
-rw-r--r--src/arch/wasm/CodeGen.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig
index 9da4d3003b..21ddd91120 100644
--- a/src/arch/wasm/CodeGen.zig
+++ b/src/arch/wasm/CodeGen.zig
@@ -3814,6 +3814,16 @@ fn airBitcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const bitcast_result = try func.bitcast(wanted_ty, given_ty, operand);
break :result try bitcast_result.toLocal(func, wanted_ty);
}
+ const mod = func.bin_file.base.options.module.?;
+ if (isByRef(given_ty, mod) and !isByRef(wanted_ty, mod)) {
+ const loaded_memory = try func.load(operand, wanted_ty, 0);
+ break :result try loaded_memory.toLocal(func, wanted_ty);
+ }
+ if (!isByRef(given_ty, mod) and isByRef(wanted_ty, mod)) {
+ const stack_memory = try func.allocStack(wanted_ty);
+ try func.store(stack_memory, operand, given_ty, 0);
+ break :result stack_memory;
+ }
break :result func.reuseOperand(ty_op.operand, operand);
};
func.finishAir(inst, result, &.{ty_op.operand});