authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-08-12 22:04:18+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-08-13 13:30:24+02:00
log16abf51ceef2ba2ebb38f27270af676387435f05
tree868f8623a5a8fb8f01b99f0bdc60044b4cf55704
parentf968dd0cb1fc9197fc6483ce235b037f6c86c8ce

x86_64: handle lea_symbol returned by genNavRef


2 files changed, 6 insertions(+), 2 deletions(-)

src/arch/x86_64/CodeGen.zig+2-1
......@@ -14104,7 +14104,7 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
1410414104 .{ .reg = try self.copyToTmpRegister(Type.usize, .{ .lea_got = sym_index }) }
1410514105 else
1410614106 return self.fail("invalid modifier: '{s}'", .{modifier}),
14107 .load_symbol => |sym_off| if (mem.eql(u8, modifier, "P"))
14107 .lea_symbol => |sym_off| if (mem.eql(u8, modifier, "P"))
1410814108 .{ .reg = try self.copyToTmpRegister(Type.usize, .{ .lea_symbol = sym_off }) }
1410914109 else
1411014110 return self.fail("invalid modifier: '{s}'", .{modifier}),
......@@ -18798,6 +18798,7 @@ fn genTypedValue(self: *Self, val: Value) InnerError!MCValue {
1879818798 .immediate => |imm| .{ .immediate = imm },
1879918799 .memory => |addr| .{ .memory = addr },
1880018800 .load_symbol => |sym_index| .{ .load_symbol = .{ .sym = sym_index } },
18801 .lea_symbol => |sym_index| .{ .lea_symbol = .{ .sym = sym_index } },
1880118802 .load_direct => |sym_index| .{ .load_direct = sym_index },
1880218803 .load_got => |sym_index| .{ .lea_got = sym_index },
1880318804 .load_tlv => |sym_index| .{ .lea_tlv = sym_index },
src/codegen.zig+4-1
......@@ -828,6 +828,9 @@ pub const GenResult = union(enum) {
828828 /// Reference to memory location but deferred until linker allocated the Decl in memory.
829829 /// Traditionally, this corresponds to emitting a relocation in a relocatable object file.
830830 load_symbol: u32,
831 /// Reference to memory location but deferred until linker allocated the Decl in memory.
832 /// Traditionally, this corresponds to emitting a relocation in a relocatable object file.
833 lea_symbol: u32,
831834 };
832835
833836 fn mcv(val: MCValue) GenResult {
......@@ -904,7 +907,7 @@ fn genNavRef(
904907 if (!single_threaded and is_threadlocal) {
905908 return GenResult.mcv(.{ .load_tlv = sym_index });
906909 }
907 return GenResult.mcv(.{ .load_symbol = sym_index });
910 return GenResult.mcv(.{ .lea_symbol = sym_index });
908911 } else if (lf.cast(.macho)) |macho_file| {
909912 const zo = macho_file.getZigObject().?;
910913 if (is_extern) {