| ... | ... | @@ -1687,7 +1687,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1687 | 1687 | .register => |src_reg| { |
| 1688 | 1688 | // register, register use mr + 1 addressing mode: r/m16/32/64, r16/32/64 |
| 1689 | 1689 | try self.encodeX8664Instruction(src, Instruction{ |
| 1690 | | .operand_size_64 = dst_reg.size() == 64, |
| 1690 | .operand_size_64 = dst_ty.abiSize(self.target.*) == 64, |
| 1691 | 1691 | .primary_opcode_1b = mr + 1, |
| 1692 | 1692 | // TODO: Explicit optional wrap due to stage 1 miscompilation :( |
| 1693 | 1693 | // https://github.com/ziglang/zig/issues/6515 |
| ... | ... | @@ -1705,7 +1705,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1705 | 1705 | const imm32 = @intCast(u31, imm); // This case must be handled before calling genX8664BinMathCode. |
| 1706 | 1706 | if (imm32 <= math.maxInt(u7)) { |
| 1707 | 1707 | try self.encodeX8664Instruction(src, Instruction{ |
| 1708 | | .operand_size_64 = dst_reg.size() == 64, |
| 1708 | .operand_size_64 = dst_ty.abiSize(self.target.*) == 64, |
| 1709 | 1709 | .primary_opcode_1b = 0x83, |
| 1710 | 1710 | .opcode_extension = opx, |
| 1711 | 1711 | // TODO: Explicit optional wrap due to stage 1 miscompilation :( |
| ... | ... | @@ -1719,7 +1719,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1719 | 1719 | }); |
| 1720 | 1720 | } else { |
| 1721 | 1721 | try self.encodeX8664Instruction(src, Instruction{ |
| 1722 | | .operand_size_64 = dst_reg.size() == 64, |
| 1722 | .operand_size_64 = dst_ty.abiSize(self.target.*) == 64, |
| 1723 | 1723 | .primary_opcode_1b = 0x81, |
| 1724 | 1724 | .opcode_extension = opx, |
| 1725 | 1725 | // TODO: Explicit optional wrap due to stage 1 miscompilation :( |
| ... | ... | @@ -1743,7 +1743,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1743 | 1743 | return self.fail(src, "stack offset too large", .{}); |
| 1744 | 1744 | } |
| 1745 | 1745 | try self.encodeX8664Instruction(src, Instruction{ |
| 1746 | | .operand_size_64 = dst_reg.size() == 64, |
| 1746 | .operand_size_64 = abi_size == 64, |
| 1747 | 1747 | .primary_opcode_1b = mr + 0x3, |
| 1748 | 1748 | .reg = dst_reg, |
| 1749 | 1749 | // TODO: Explicit optional wrap due to stage 1 miscompilation :( |
| ... | ... | @@ -1802,7 +1802,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1802 | 1802 | return self.fail(src, "stack offset too large", .{}); |
| 1803 | 1803 | } |
| 1804 | 1804 | try self.encodeX8664Instruction(src, Instruction{ |
| 1805 | | .operand_size_64 = reg.size() == 64, |
| 1805 | .operand_size_64 = abi_size == 64, |
| 1806 | 1806 | .primary_opcode_1b = opcode, |
| 1807 | 1807 | .reg = reg, |
| 1808 | 1808 | // TODO: Explicit optional wrap due to stage 1 miscompilation :( |
| ... | ... | @@ -3707,7 +3707,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3707 | 3707 | |
| 3708 | 3708 | // This is a variant of 8B /r. |
| 3709 | 3709 | try self.encodeX8664Instruction(src, Instruction{ |
| 3710 | | .operand_size_64 = reg.size() == 64, |
| 3710 | .operand_size_64 = ty.abiSize(self.target.*) == 64, |
| 3711 | 3711 | |
| 3712 | 3712 | .primary_opcode_1b = 0x8B, |
| 3713 | 3713 | |
| ... | ... | @@ -3740,7 +3740,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3740 | 3740 | // LEA reg, [<offset>] |
| 3741 | 3741 | // manually do this instruction to make sure the offset into the disp32 field won't change. |
| 3742 | 3742 | try self.code.ensureCapacity(self.code.items.len + 7); |
| 3743 | | self.rex(.{ .w = reg.size() == 64, .r = reg.isExtended() }); |
| 3743 | self.rex(.{ .w = ty.abiSize(self.target.*) == 64, .r = reg.isExtended() }); |
| 3744 | 3744 | self.code.appendSliceAssumeCapacity(&[_]u8{ |
| 3745 | 3745 | 0x8D, |
| 3746 | 3746 | 0x05 | (@as(u8, reg.id() & 0b111) << 3), |
| ... | ... | @@ -3749,7 +3749,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3749 | 3749 | |
| 3750 | 3750 | // MOV reg, [reg] |
| 3751 | 3751 | try self.encodeX8664Instruction(src, Instruction{ |
| 3752 | | .operand_size_64 = reg.size() == 64, |
| 3752 | .operand_size_64 = ty.abiSize(self.target.*) == 64, |
| 3753 | 3753 | |
| 3754 | 3754 | .primary_opcode_1b = 0x8B, |
| 3755 | 3755 | |
| ... | ... | @@ -3771,7 +3771,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3771 | 3771 | // 0b00RRR100, where RRR is the lower three bits of the register ID. |
| 3772 | 3772 | // The instruction is thus eight bytes; REX 0x8B 0b00RRR100 0x25 followed by a four-byte disp32. |
| 3773 | 3773 | try self.code.ensureCapacity(self.code.items.len + 8); |
| 3774 | | self.rex(.{ .w = reg.size() == 64, .b = reg.isExtended() }); |
| 3774 | self.rex(.{ .w = ty.abiSize(self.target.*) == 64, .r = reg.isExtended() }); |
| 3775 | 3775 | self.code.appendSliceAssumeCapacity(&[_]u8{ |
| 3776 | 3776 | 0x8B, |
| 3777 | 3777 | 0x04 | (@as(u8, reg.id() & 0b111) << 3), // R |
| ... | ... | @@ -3809,7 +3809,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3809 | 3809 | // Currently, we're only allowing 64-bit registers, so we need the `REX.W 8B /r` variant. |
| 3810 | 3810 | // TODO: determine whether to allow other sized registers, and if so, handle them properly. |
| 3811 | 3811 | try self.encodeX8664Instruction(src, Instruction{ |
| 3812 | | .operand_size_64 = reg.size() == 64, |
| 3812 | .operand_size_64 = ty.abiSize(self.target.*) == 64, |
| 3813 | 3813 | .primary_opcode_1b = 0x8B, |
| 3814 | 3814 | .reg = reg, |
| 3815 | 3815 | // TODO: Explicit optional wrap due to stage 1 miscompilation :( |
| ... | ... | @@ -3823,14 +3823,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3823 | 3823 | } |
| 3824 | 3824 | }, |
| 3825 | 3825 | .stack_offset => |unadjusted_off| { |
| 3826 | | const size_bytes = @divExact(reg.size(), 8); |
| 3827 | | const off = unadjusted_off + size_bytes; |
| 3826 | const abi_size = ty.abiSize(self.target.*); |
| 3827 | const off = unadjusted_off + abi_size; |
| 3828 | 3828 | if (off < std.math.minInt(i32) or off > std.math.maxInt(i32)) { |
| 3829 | 3829 | return self.fail(src, "stack offset too large", .{}); |
| 3830 | 3830 | } |
| 3831 | 3831 | const ioff = -@intCast(i32, off); |
| 3832 | 3832 | try self.encodeX8664Instruction(src, Instruction{ |
| 3833 | | .operand_size_64 = reg.size() == 64, |
| 3833 | .operand_size_64 = ty.abiSize(self.target.*) == 64, |
| 3834 | 3834 | .primary_opcode_1b = 0x8B, |
| 3835 | 3835 | .reg = reg, |
| 3836 | 3836 | // TODO: Explicit optional wrap due to stage 1 miscompilation :( |