authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-07 14:04:30-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-15 15:11:35-08:00
log4a1447d1dbdc5638d94359d731379eba428a016d
tree118a9b60b35782de04f752366827f2348473bf4f
parente24f635c758242b9c8d8aacac668d31dead7623e

wasm codegen: switch on bool instead of int


1 files changed, 24 insertions(+), 39 deletions(-)

src/arch/wasm/CodeGen.zig+24-39
...@@ -64,6 +64,7 @@ arg_index: u32 = 0,...@@ -64,6 +64,7 @@ arg_index: u32 = 0,
64simd_immediates: std.ArrayListUnmanaged([16]u8) = .empty,64simd_immediates: std.ArrayListUnmanaged([16]u8) = .empty,
65/// The Target we're emitting (used to call intInfo)65/// The Target we're emitting (used to call intInfo)
66target: *const std.Target,66target: *const std.Target,
67ptr_size: enum { wasm32, wasm64 },
67wasm: *link.File.Wasm,68wasm: *link.File.Wasm,
68pt: Zcu.PerThread,69pt: Zcu.PerThread,
69/// List of MIR Instructions70/// List of MIR Instructions
...@@ -1310,6 +1311,11 @@ pub fn function(...@@ -1310,6 +1311,11 @@ pub fn function(
1310 .liveness = liveness,1311 .liveness = liveness,
1311 .owner_nav = func.owner_nav,1312 .owner_nav = func.owner_nav,
1312 .target = target,1313 .target = target,
1314 .ptr_size = switch (target.cpu.arch) {
1315 .wasm32 => .wasm32,
1316 .wasm64 => .wasm64,
1317 else => unreachable,
1318 },
1313 .wasm = wasm,1319 .wasm = wasm,
1314 .func_index = func_index,1320 .func_index = func_index,
1315 .args = cc_result.args,1321 .args = cc_result.args,
...@@ -1510,7 +1516,7 @@ fn lowerToStack(func: *CodeGen, value: WValue) !void {...@@ -1510,7 +1516,7 @@ fn lowerToStack(func: *CodeGen, value: WValue) !void {
1510 .stack_offset => |offset| {1516 .stack_offset => |offset| {
1511 try func.emitWValue(value);1517 try func.emitWValue(value);
1512 if (offset.value > 0) {1518 if (offset.value > 0) {
1513 switch (func.arch()) {1519 switch (func.ptr_size) {
1514 .wasm32 => {1520 .wasm32 => {
1515 try func.addImm32(offset.value);1521 try func.addImm32(offset.value);
1516 try func.addTag(.i32_add);1522 try func.addTag(.i32_add);
...@@ -1519,7 +1525,6 @@ fn lowerToStack(func: *CodeGen, value: WValue) !void {...@@ -1519,7 +1525,6 @@ fn lowerToStack(func: *CodeGen, value: WValue) !void {
1519 try func.addImm64(offset.value);1525 try func.addImm64(offset.value);
1520 try func.addTag(.i64_add);1526 try func.addTag(.i64_add);
1521 },1527 },
1522 else => unreachable,
1523 }1528 }
1524 }1529 }
1525 },1530 },
...@@ -1650,7 +1655,7 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {...@@ -1650,7 +1655,7 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {
1650 try func.emitWValue(dst);1655 try func.emitWValue(dst);
1651 // load byte from src's address1656 // load byte from src's address
1652 try func.emitWValue(src);1657 try func.emitWValue(src);
1653 switch (func.arch()) {1658 switch (func.ptr_size) {
1654 .wasm32 => {1659 .wasm32 => {
1655 try func.addMemArg(.i32_load8_u, .{ .offset = rhs_base + offset, .alignment = 1 });1660 try func.addMemArg(.i32_load8_u, .{ .offset = rhs_base + offset, .alignment = 1 });
1656 try func.addMemArg(.i32_store8, .{ .offset = lhs_base + offset, .alignment = 1 });1661 try func.addMemArg(.i32_store8, .{ .offset = lhs_base + offset, .alignment = 1 });
...@@ -1659,7 +1664,6 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {...@@ -1659,7 +1664,6 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {
1659 try func.addMemArg(.i64_load8_u, .{ .offset = rhs_base + offset, .alignment = 1 });1664 try func.addMemArg(.i64_load8_u, .{ .offset = rhs_base + offset, .alignment = 1 });
1660 try func.addMemArg(.i64_store8, .{ .offset = lhs_base + offset, .alignment = 1 });1665 try func.addMemArg(.i64_store8, .{ .offset = lhs_base + offset, .alignment = 1 });
1661 },1666 },
1662 else => unreachable,
1663 }1667 }
1664 }1668 }
1665 return;1669 return;
...@@ -1671,10 +1675,9 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {...@@ -1671,10 +1675,9 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {
1671 // This to ensure that inside loops we correctly re-set the counter.1675 // This to ensure that inside loops we correctly re-set the counter.
1672 var offset = try func.allocLocal(Type.usize); // local for counter1676 var offset = try func.allocLocal(Type.usize); // local for counter
1673 defer offset.free(func);1677 defer offset.free(func);
1674 switch (func.arch()) {1678 switch (func.ptr_size) {
1675 .wasm32 => try func.addImm32(0),1679 .wasm32 => try func.addImm32(0),
1676 .wasm64 => try func.addImm64(0),1680 .wasm64 => try func.addImm64(0),
1677 else => unreachable,
1678 }1681 }
1679 try func.addLabel(.local_set, offset.local.value);1682 try func.addLabel(.local_set, offset.local.value);
16801683
...@@ -1686,10 +1689,9 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {...@@ -1686,10 +1689,9 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {
1686 {1689 {
1687 try func.emitWValue(offset);1690 try func.emitWValue(offset);
1688 try func.emitWValue(len);1691 try func.emitWValue(len);
1689 switch (func.arch()) {1692 switch (func.ptr_size) {
1690 .wasm32 => try func.addTag(.i32_eq),1693 .wasm32 => try func.addTag(.i32_eq),
1691 .wasm64 => try func.addTag(.i64_eq),1694 .wasm64 => try func.addTag(.i64_eq),
1692 else => unreachable,
1693 }1695 }
1694 try func.addLabel(.br_if, 1); // jump out of loop into outer block (finished)1696 try func.addLabel(.br_if, 1); // jump out of loop into outer block (finished)
1695 }1697 }
...@@ -1698,10 +1700,9 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {...@@ -1698,10 +1700,9 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {
1698 {1700 {
1699 try func.emitWValue(dst);1701 try func.emitWValue(dst);
1700 try func.emitWValue(offset);1702 try func.emitWValue(offset);
1701 switch (func.arch()) {1703 switch (func.ptr_size) {
1702 .wasm32 => try func.addTag(.i32_add),1704 .wasm32 => try func.addTag(.i32_add),
1703 .wasm64 => try func.addTag(.i64_add),1705 .wasm64 => try func.addTag(.i64_add),
1704 else => unreachable,
1705 }1706 }
1706 }1707 }
17071708
...@@ -1709,7 +1710,7 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {...@@ -1709,7 +1710,7 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {
1709 {1710 {
1710 try func.emitWValue(src);1711 try func.emitWValue(src);
1711 try func.emitWValue(offset);1712 try func.emitWValue(offset);
1712 switch (func.arch()) {1713 switch (func.ptr_size) {
1713 .wasm32 => {1714 .wasm32 => {
1714 try func.addTag(.i32_add);1715 try func.addTag(.i32_add);
1715 try func.addMemArg(.i32_load8_u, .{ .offset = src.offset(), .alignment = 1 });1716 try func.addMemArg(.i32_load8_u, .{ .offset = src.offset(), .alignment = 1 });
...@@ -1720,14 +1721,13 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {...@@ -1720,14 +1721,13 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {
1720 try func.addMemArg(.i64_load8_u, .{ .offset = src.offset(), .alignment = 1 });1721 try func.addMemArg(.i64_load8_u, .{ .offset = src.offset(), .alignment = 1 });
1721 try func.addMemArg(.i64_store8, .{ .offset = dst.offset(), .alignment = 1 });1722 try func.addMemArg(.i64_store8, .{ .offset = dst.offset(), .alignment = 1 });
1722 },1723 },
1723 else => unreachable,
1724 }1724 }
1725 }1725 }
17261726
1727 // increment loop counter1727 // increment loop counter
1728 {1728 {
1729 try func.emitWValue(offset);1729 try func.emitWValue(offset);
1730 switch (func.arch()) {1730 switch (func.ptr_size) {
1731 .wasm32 => {1731 .wasm32 => {
1732 try func.addImm32(1);1732 try func.addImm32(1);
1733 try func.addTag(.i32_add);1733 try func.addTag(.i32_add);
...@@ -1736,7 +1736,6 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {...@@ -1736,7 +1736,6 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void {
1736 try func.addImm64(1);1736 try func.addImm64(1);
1737 try func.addTag(.i64_add);1737 try func.addTag(.i64_add);
1738 },1738 },
1739 else => unreachable,
1740 }1739 }
1741 try func.addLabel(.local_set, offset.local.value);1740 try func.addLabel(.local_set, offset.local.value);
1742 try func.addLabel(.br, 0); // jump to start of loop1741 try func.addLabel(.br, 0); // jump to start of loop
...@@ -1749,10 +1748,6 @@ fn ptrSize(func: *const CodeGen) u16 {...@@ -1749,10 +1748,6 @@ fn ptrSize(func: *const CodeGen) u16 {
1749 return @divExact(func.target.ptrBitWidth(), 8);1748 return @divExact(func.target.ptrBitWidth(), 8);
1750}1749}
17511750
1752fn arch(func: *const CodeGen) std.Target.Cpu.Arch {
1753 return func.target.cpu.arch;
1754}
1755
1756/// For a given `Type`, will return true when the type will be passed1751/// For a given `Type`, will return true when the type will be passed
1757/// by reference, rather than by value1752/// by reference, rather than by value
1758fn isByRef(ty: Type, pt: Zcu.PerThread, target: *const std.Target) bool {1753fn isByRef(ty: Type, pt: Zcu.PerThread, target: *const std.Target) bool {
...@@ -1851,7 +1846,7 @@ fn buildPointerOffset(func: *CodeGen, ptr_value: WValue, offset: u64, action: en...@@ -1851,7 +1846,7 @@ fn buildPointerOffset(func: *CodeGen, ptr_value: WValue, offset: u64, action: en
1851 };1846 };
1852 try func.emitWValue(ptr_value);1847 try func.emitWValue(ptr_value);
1853 if (offset + ptr_value.offset() > 0) {1848 if (offset + ptr_value.offset() > 0) {
1854 switch (func.arch()) {1849 switch (func.ptr_size) {
1855 .wasm32 => {1850 .wasm32 => {
1856 try func.addImm32(@intCast(offset + ptr_value.offset()));1851 try func.addImm32(@intCast(offset + ptr_value.offset()));
1857 try func.addTag(.i32_add);1852 try func.addTag(.i32_add);
...@@ -1860,7 +1855,6 @@ fn buildPointerOffset(func: *CodeGen, ptr_value: WValue, offset: u64, action: en...@@ -1860,7 +1855,6 @@ fn buildPointerOffset(func: *CodeGen, ptr_value: WValue, offset: u64, action: en
1860 try func.addImm64(offset + ptr_value.offset());1855 try func.addImm64(offset + ptr_value.offset());
1861 try func.addTag(.i64_add);1856 try func.addTag(.i64_add);
1862 },1857 },
1863 else => unreachable,
1864 }1858 }
1865 }1859 }
1866 try func.addLabel(.local_set, result_ptr.local.value);1860 try func.addLabel(.local_set, result_ptr.local.value);
...@@ -3350,10 +3344,9 @@ fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue {...@@ -3350,10 +3344,9 @@ fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue {
3350 64 => return .{ .float64 = @as(f64, @bitCast(@as(u64, 0xaaaaaaaaaaaaaaaa))) },3344 64 => return .{ .float64 = @as(f64, @bitCast(@as(u64, 0xaaaaaaaaaaaaaaaa))) },
3351 else => unreachable,3345 else => unreachable,
3352 },3346 },
3353 .pointer => switch (func.arch()) {3347 .pointer => switch (func.ptr_size) {
3354 .wasm32 => return .{ .imm32 = 0xaaaaaaaa },3348 .wasm32 => return .{ .imm32 = 0xaaaaaaaa },
3355 .wasm64 => return .{ .imm64 = 0xaaaaaaaaaaaaaaaa },3349 .wasm64 => return .{ .imm64 = 0xaaaaaaaaaaaaaaaa },
3356 else => unreachable,
3357 },3350 },
3358 .optional => {3351 .optional => {
3359 const pl_ty = ty.optionalChild(zcu);3352 const pl_ty = ty.optionalChild(zcu);
...@@ -4428,10 +4421,9 @@ fn isNull(func: *CodeGen, operand: WValue, optional_ty: Type, opcode: std.wasm.O...@@ -4428,10 +4421,9 @@ fn isNull(func: *CodeGen, operand: WValue, optional_ty: Type, opcode: std.wasm.O
4428 try func.addMemArg(.i32_load8_u, .{ .offset = operand.offset() + offset, .alignment = 1 });4421 try func.addMemArg(.i32_load8_u, .{ .offset = operand.offset() + offset, .alignment = 1 });
4429 }4422 }
4430 } else if (payload_ty.isSlice(zcu)) {4423 } else if (payload_ty.isSlice(zcu)) {
4431 switch (func.arch()) {4424 switch (func.ptr_size) {
4432 .wasm32 => try func.addMemArg(.i32_load, .{ .offset = operand.offset(), .alignment = 4 }),4425 .wasm32 => try func.addMemArg(.i32_load, .{ .offset = operand.offset(), .alignment = 4 }),
4433 .wasm64 => try func.addMemArg(.i64_load, .{ .offset = operand.offset(), .alignment = 8 }),4426 .wasm64 => try func.addMemArg(.i64_load, .{ .offset = operand.offset(), .alignment = 8 }),
4434 else => unreachable,
4435 }4427 }
4436 }4428 }
44374429
...@@ -4867,7 +4859,7 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue...@@ -4867,7 +4859,7 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue
4867 else => if (abi_size != 1) blk: {4859 else => if (abi_size != 1) blk: {
4868 const new_len = try func.ensureAllocLocal(Type.usize);4860 const new_len = try func.ensureAllocLocal(Type.usize);
4869 try func.emitWValue(len);4861 try func.emitWValue(len);
4870 switch (func.arch()) {4862 switch (func.ptr_size) {
4871 .wasm32 => {4863 .wasm32 => {
4872 try func.emitWValue(.{ .imm32 = abi_size });4864 try func.emitWValue(.{ .imm32 = abi_size });
4873 try func.addTag(.i32_mul);4865 try func.addTag(.i32_mul);
...@@ -4876,7 +4868,6 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue...@@ -4876,7 +4868,6 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue
4876 try func.emitWValue(.{ .imm64 = abi_size });4868 try func.emitWValue(.{ .imm64 = abi_size });
4877 try func.addTag(.i64_mul);4869 try func.addTag(.i64_mul);
4878 },4870 },
4879 else => unreachable,
4880 }4871 }
4881 try func.addLabel(.local_set, new_len.local.value);4872 try func.addLabel(.local_set, new_len.local.value);
4882 break :blk new_len;4873 break :blk new_len;
...@@ -4891,10 +4882,9 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue...@@ -4891,10 +4882,9 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue
4891 // get the loop conditional: if current pointer address equals final pointer's address4882 // get the loop conditional: if current pointer address equals final pointer's address
4892 try func.lowerToStack(ptr);4883 try func.lowerToStack(ptr);
4893 try func.emitWValue(final_len);4884 try func.emitWValue(final_len);
4894 switch (func.arch()) {4885 switch (func.ptr_size) {
4895 .wasm32 => try func.addTag(.i32_add),4886 .wasm32 => try func.addTag(.i32_add),
4896 .wasm64 => try func.addTag(.i64_add),4887 .wasm64 => try func.addTag(.i64_add),
4897 else => unreachable,
4898 }4888 }
4899 try func.addLabel(.local_set, end_ptr.local.value);4889 try func.addLabel(.local_set, end_ptr.local.value);
49004890
...@@ -4905,10 +4895,9 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue...@@ -4905,10 +4895,9 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue
4905 // check for condition for loop end4895 // check for condition for loop end
4906 try func.emitWValue(new_ptr);4896 try func.emitWValue(new_ptr);
4907 try func.emitWValue(end_ptr);4897 try func.emitWValue(end_ptr);
4908 switch (func.arch()) {4898 switch (func.ptr_size) {
4909 .wasm32 => try func.addTag(.i32_eq),4899 .wasm32 => try func.addTag(.i32_eq),
4910 .wasm64 => try func.addTag(.i64_eq),4900 .wasm64 => try func.addTag(.i64_eq),
4911 else => unreachable,
4912 }4901 }
4913 try func.addLabel(.br_if, 1); // jump out of loop into outer block (finished)4902 try func.addLabel(.br_if, 1); // jump out of loop into outer block (finished)
49144903
...@@ -4917,7 +4906,7 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue...@@ -4917,7 +4906,7 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue
49174906
4918 // move the pointer to the next element4907 // move the pointer to the next element
4919 try func.emitWValue(new_ptr);4908 try func.emitWValue(new_ptr);
4920 switch (func.arch()) {4909 switch (func.ptr_size) {
4921 .wasm32 => {4910 .wasm32 => {
4922 try func.emitWValue(.{ .imm32 = abi_size });4911 try func.emitWValue(.{ .imm32 = abi_size });
4923 try func.addTag(.i32_add);4912 try func.addTag(.i32_add);
...@@ -4926,7 +4915,6 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue...@@ -4926,7 +4915,6 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue
4926 try func.emitWValue(.{ .imm64 = abi_size });4915 try func.emitWValue(.{ .imm64 = abi_size });
4927 try func.addTag(.i64_add);4916 try func.addTag(.i64_add);
4928 },4917 },
4929 else => unreachable,
4930 }4918 }
4931 try func.addLabel(.local_set, new_ptr.local.value);4919 try func.addLabel(.local_set, new_ptr.local.value);
49324920
...@@ -5101,7 +5089,7 @@ fn airSplat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5101,7 +5089,7 @@ fn airSplat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5101 // when the operand lives in the linear memory section, we can directly5089 // when the operand lives in the linear memory section, we can directly
5102 // load and splat the value at once. Meaning we do not first have to load5090 // load and splat the value at once. Meaning we do not first have to load
5103 // the scalar value onto the stack.5091 // the scalar value onto the stack.
5104 .stack_offset, .memory, .memory_offset => {5092 .stack_offset, .nav_ref, .uav_ref => {
5105 const opcode = switch (elem_ty.bitSize(zcu)) {5093 const opcode = switch (elem_ty.bitSize(zcu)) {
5106 8 => @intFromEnum(std.wasm.SimdOpcode.v128_load8_splat),5094 8 => @intFromEnum(std.wasm.SimdOpcode.v128_load8_splat),
5107 16 => @intFromEnum(std.wasm.SimdOpcode.v128_load16_splat),5095 16 => @intFromEnum(std.wasm.SimdOpcode.v128_load16_splat),
...@@ -5110,8 +5098,7 @@ fn airSplat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5110,8 +5098,7 @@ fn airSplat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5110 else => break :blk, // Cannot make use of simd-instructions5098 else => break :blk, // Cannot make use of simd-instructions
5111 };5099 };
5112 try func.emitWValue(operand);5100 try func.emitWValue(operand);
5113 // TODO: Add helper functions for simd opcodes5101 const extra_index: u32 = @intCast(func.mir_extra.items.len);
5114 const extra_index = @as(u32, @intCast(func.mir_extra.items.len));
5115 // stores as := opcode, offset, alignment (opcode::memarg)5102 // stores as := opcode, offset, alignment (opcode::memarg)
5116 try func.mir_extra.appendSlice(func.gpa, &[_]u32{5103 try func.mir_extra.appendSlice(func.gpa, &[_]u32{
5117 opcode,5104 opcode,
...@@ -5759,10 +5746,9 @@ fn airMemcpy(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5759,10 +5746,9 @@ fn airMemcpy(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
57595746
5760fn airRetAddr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5747fn airRetAddr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5761 // TODO: Implement this properly once stack serialization is solved5748 // TODO: Implement this properly once stack serialization is solved
5762 return func.finishAir(inst, switch (func.arch()) {5749 return func.finishAir(inst, switch (func.ptr_size) {
5763 .wasm32 => .{ .imm32 = 0 },5750 .wasm32 => .{ .imm32 = 0 },
5764 .wasm64 => .{ .imm64 = 0 },5751 .wasm64 => .{ .imm64 = 0 },
5765 else => unreachable,
5766 }, &.{});5752 }, &.{});
5767}5753}
57685754
...@@ -5937,7 +5923,7 @@ fn airErrorName(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5937,7 +5923,7 @@ fn airErrorName(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5937 const error_name_value: WValue = .{ .memory = error_table_symbol }; // emitting this will create a relocation5923 const error_name_value: WValue = .{ .memory = error_table_symbol }; // emitting this will create a relocation
5938 try func.emitWValue(error_name_value);5924 try func.emitWValue(error_name_value);
5939 try func.emitWValue(operand);5925 try func.emitWValue(operand);
5940 switch (func.arch()) {5926 switch (func.ptr_size) {
5941 .wasm32 => {5927 .wasm32 => {
5942 try func.addImm32(@intCast(abi_size));5928 try func.addImm32(@intCast(abi_size));
5943 try func.addTag(.i32_mul);5929 try func.addTag(.i32_mul);
...@@ -5948,7 +5934,6 @@ fn airErrorName(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5948,7 +5934,6 @@ fn airErrorName(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5948 try func.addTag(.i64_mul);5934 try func.addTag(.i64_mul);
5949 try func.addTag(.i64_add);5935 try func.addTag(.i64_add);
5950 },5936 },
5951 else => unreachable,
5952 }5937 }
59535938
5954 return func.finishAir(inst, .stack, &.{un_op});5939 return func.finishAir(inst, .stack, &.{un_op});