| ... | @@ -5295,11 +5295,23 @@ fn airMemcpy(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -5295,11 +5295,23 @@ fn airMemcpy(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5295 | const bin_op = func.air.instructions.items(.data)[inst].bin_op; | 5295 | const bin_op = func.air.instructions.items(.data)[inst].bin_op; |
| 5296 | const dst = try func.resolveInst(bin_op.lhs); | 5296 | const dst = try func.resolveInst(bin_op.lhs); |
| 5297 | const dst_ty = func.air.typeOf(bin_op.lhs); | 5297 | const dst_ty = func.air.typeOf(bin_op.lhs); |
| | 5298 | const ptr_elem_ty = dst_ty.childType(); |
| 5298 | const src = try func.resolveInst(bin_op.rhs); | 5299 | const src = try func.resolveInst(bin_op.rhs); |
| 5299 | const src_ty = func.air.typeOf(bin_op.rhs); | 5300 | const src_ty = func.air.typeOf(bin_op.rhs); |
| 5300 | const len = switch (dst_ty.ptrSize()) { | 5301 | const len = switch (dst_ty.ptrSize()) { |
| 5301 | .Slice => try func.sliceLen(dst), | 5302 | .Slice => blk: { |
| 5302 | .One => @as(WValue, .{ .imm32 = @intCast(u32, dst_ty.childType().arrayLen()) }), | 5303 | const slice_len = try func.sliceLen(dst); |
| | 5304 | if (ptr_elem_ty.abiSize(func.target) != 1) { |
| | 5305 | try func.emitWValue(slice_len); |
| | 5306 | try func.emitWValue(.{ .imm32 = @intCast(u32, ptr_elem_ty.abiSize(func.target)) }); |
| | 5307 | try func.addTag(.i32_mul); |
| | 5308 | try func.addLabel(.local_set, slice_len.local.value); |
| | 5309 | } |
| | 5310 | break :blk slice_len; |
| | 5311 | }, |
| | 5312 | .One => @as(WValue, .{ |
| | 5313 | .imm32 = @intCast(u32, ptr_elem_ty.arrayLen() * ptr_elem_ty.childType().abiSize(func.target)), |
| | 5314 | }), |
| 5303 | .C, .Many => unreachable, | 5315 | .C, .Many => unreachable, |
| 5304 | }; | 5316 | }; |
| 5305 | const dst_ptr = try func.sliceOrArrayPtr(dst, dst_ty); | 5317 | const dst_ptr = try func.sliceOrArrayPtr(dst, dst_ty); |