authorgravatar for miguel.p.paradinha@gmail.commparadinha <miguel.p.paradinha@gmail.com> 2022-01-30 16:02:18+00:00
committergravatar for miguel.p.paradinha@gmail.commparadinha <miguel.p.paradinha@gmail.com> 2022-02-02 08:50:37+00:00
logb67b89025cc12785f78a7908e321f8ed0b83afc6
tree4dc82ae1b3f1d762fb80b4dba1d3c4f1f4a67a1d
parentcc16ac9314752681300c7e72a4989aeba2ba2579

implement store for 8 byte immediates


1 files changed, 18 insertions(+), 0 deletions(-)

src/arch/x86_64/CodeGen.zig+18
......@@ -1740,6 +1740,24 @@ fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type
17401740 .data = .{ .payload = payload },
17411741 });
17421742 },
1743 8 => {
1744 // TODO: optimization: if the imm is only using the lower
1745 // 4 bytes and can be sign extended we can use a normal mov
1746 // with indirect addressing (mov [reg64], imm32).
1747
1748 // movabs does not support indirect register addressing
1749 // so we need an extra register and an extra mov.
1750 const tmp_reg = try self.copyToTmpRegister(value_ty, value);
1751 _ = try self.addInst(.{
1752 .tag = .mov,
1753 .ops = (Mir.Ops{
1754 .reg1 = reg.to64(),
1755 .reg2 = tmp_reg.to64(),
1756 .flags = 0b10,
1757 }).encode(),
1758 .data = .{ .imm = 0 },
1759 });
1760 },
17431761 else => {
17441762 return self.fail("TODO implement set pointee with immediate of ABI size {d}", .{abi_size});
17451763 },