diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-12-18 20:07:54 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-01-15 15:11:36 -0800 |
| commit | 568d9936ab4401e53a96bb2b51d31d10861c5545 (patch) | |
| tree | f2b4ac467f6625cfb5f552c56b6ae6e62096d8e0 /src | |
| parent | 070b973c4a3c25e688e9b0b59ff449a294226a05 (diff) | |
| download | zig-568d9936ab4401e53a96bb2b51d31d10861c5545.tar.gz zig-568d9936ab4401e53a96bb2b51d31d10861c5545.zip | |
wasm codegen: fix call_indirect
Diffstat (limited to 'src')
| -rw-r--r-- | src/arch/wasm/CodeGen.zig | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index cd34b8d68b..6914ae1afd 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -235,7 +235,6 @@ const Op = enum { br_table, @"return", call, - call_indirect, drop, select, global_get, @@ -313,7 +312,6 @@ fn buildOpcode(args: OpcodeBuildArguments) std.wasm.Opcode { .br_table => unreachable, .@"return" => unreachable, .call => unreachable, - .call_indirect => unreachable, .drop => unreachable, .select => unreachable, .global_get => unreachable, @@ -873,6 +871,10 @@ fn addLocal(cg: *CodeGen, tag: Mir.Inst.Tag, local: u32) error{OutOfMemory}!void try cg.addInst(.{ .tag = tag, .data = .{ .local = local } }); } +fn addFuncTy(cg: *CodeGen, tag: Mir.Inst.Tag, i: Wasm.FunctionType.Index) error{OutOfMemory}!void { + try cg.addInst(.{ .tag = tag, .data = .{ .func_ty = i } }); +} + /// Accepts an unsigned 32bit integer rather than a signed integer to /// prevent us from having to bitcast multiple times as most values /// within codegen are represented as unsigned rather than signed. @@ -2211,7 +2213,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModifie try cg.emitWValue(operand); const fn_type_index = try wasm.internFunctionType(fn_info.cc, fn_info.param_types.get(ip), .fromInterned(fn_info.return_type), cg.target); - try cg.addLabel(.call_indirect, @intFromEnum(fn_type_index)); + try cg.addFuncTy(.call_indirect, fn_type_index); } const result_value = result_value: { |
