| ... | @@ -1432,21 +1432,13 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: | ... | @@ -1432,21 +1432,13 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: |
| 1432 | } | 1432 | } |
| 1433 | assert(ty_classes[0] == .direct); | 1433 | assert(ty_classes[0] == .direct); |
| 1434 | const scalar_type = abi.scalarType(ty, mod); | 1434 | const scalar_type = abi.scalarType(ty, mod); |
| 1435 | const abi_size = scalar_type.abiSize(mod); | 1435 | switch (value) { |
| 1436 | try func.emitWValue(value); | 1436 | .memory, |
| 1437 | | 1437 | .memory_offset, |
| 1438 | // When the value lives in the virtual stack, we must load it onto the actual stack | 1438 | .stack_offset, |
| 1439 | if (value != .imm32 and value != .imm64) { | 1439 | => _ = try func.load(value, scalar_type, 0), |
| 1440 | const opcode = buildOpcode(.{ | 1440 | .dead => unreachable, |
| 1441 | .op = .load, | 1441 | else => try func.emitWValue(value), |
| 1442 | .width = @as(u8, @intCast(abi_size)), | | |
| 1443 | .signedness = if (scalar_type.isSignedInt(mod)) .signed else .unsigned, | | |
| 1444 | .valtype1 = typeToValtype(scalar_type, mod), | | |
| 1445 | }); | | |
| 1446 | try func.addMemArg(Mir.Inst.Tag.fromOpcode(opcode), .{ | | |
| 1447 | .offset = value.offset(), | | |
| 1448 | .alignment = @intCast(scalar_type.abiAlignment(mod).toByteUnitsOptional().?), | | |
| 1449 | }); | | |
| 1450 | } | 1442 | } |
| 1451 | }, | 1443 | }, |
| 1452 | .Int, .Float => { | 1444 | .Int, .Float => { |
| ... | @@ -2522,7 +2514,7 @@ fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValu | ... | @@ -2522,7 +2514,7 @@ fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValu |
| 2522 | return WValue{ .stack = {} }; | 2514 | return WValue{ .stack = {} }; |
| 2523 | } | 2515 | } |
| 2524 | | 2516 | |
| 2525 | const abi_size = @as(u8, @intCast(ty.abiSize(mod))); | 2517 | const abi_size: u8 = @intCast(ty.abiSize(mod)); |
| 2526 | const opcode = buildOpcode(.{ | 2518 | const opcode = buildOpcode(.{ |
| 2527 | .valtype1 = typeToValtype(ty, mod), | 2519 | .valtype1 = typeToValtype(ty, mod), |
| 2528 | .width = abi_size * 8, | 2520 | .width = abi_size * 8, |