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 {...@@ -14104,7 +14104,7 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
14104 .{ .reg = try self.copyToTmpRegister(Type.usize, .{ .lea_got = sym_index }) }14104 .{ .reg = try self.copyToTmpRegister(Type.usize, .{ .lea_got = sym_index }) }
14105 else14105 else
14106 return self.fail("invalid modifier: '{s}'", .{modifier}),14106 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"))
14108 .{ .reg = try self.copyToTmpRegister(Type.usize, .{ .lea_symbol = sym_off }) }14108 .{ .reg = try self.copyToTmpRegister(Type.usize, .{ .lea_symbol = sym_off }) }
14109 else14109 else
14110 return self.fail("invalid modifier: '{s}'", .{modifier}),14110 return self.fail("invalid modifier: '{s}'", .{modifier}),
...@@ -18798,6 +18798,7 @@ fn genTypedValue(self: *Self, val: Value) InnerError!MCValue {...@@ -18798,6 +18798,7 @@ fn genTypedValue(self: *Self, val: Value) InnerError!MCValue {
18798 .immediate => |imm| .{ .immediate = imm },18798 .immediate => |imm| .{ .immediate = imm },
18799 .memory => |addr| .{ .memory = addr },18799 .memory => |addr| .{ .memory = addr },
18800 .load_symbol => |sym_index| .{ .load_symbol = .{ .sym = sym_index } },18800 .load_symbol => |sym_index| .{ .load_symbol = .{ .sym = sym_index } },
18801 .lea_symbol => |sym_index| .{ .lea_symbol = .{ .sym = sym_index } },
18801 .load_direct => |sym_index| .{ .load_direct = sym_index },18802 .load_direct => |sym_index| .{ .load_direct = sym_index },
18802 .load_got => |sym_index| .{ .lea_got = sym_index },18803 .load_got => |sym_index| .{ .lea_got = sym_index },
18803 .load_tlv => |sym_index| .{ .lea_tlv = sym_index },18804 .load_tlv => |sym_index| .{ .lea_tlv = sym_index },
src/codegen.zig+4-1
...@@ -828,6 +828,9 @@ pub const GenResult = union(enum) {...@@ -828,6 +828,9 @@ pub const GenResult = union(enum) {
828 /// Reference to memory location but deferred until linker allocated the Decl in memory.828 /// Reference to memory location but deferred until linker allocated the Decl in memory.
829 /// Traditionally, this corresponds to emitting a relocation in a relocatable object file.829 /// Traditionally, this corresponds to emitting a relocation in a relocatable object file.
830 load_symbol: u32,830 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,
831 };834 };
832835
833 fn mcv(val: MCValue) GenResult {836 fn mcv(val: MCValue) GenResult {
...@@ -904,7 +907,7 @@ fn genNavRef(...@@ -904,7 +907,7 @@ fn genNavRef(
904 if (!single_threaded and is_threadlocal) {907 if (!single_threaded and is_threadlocal) {
905 return GenResult.mcv(.{ .load_tlv = sym_index });908 return GenResult.mcv(.{ .load_tlv = sym_index });
906 }909 }
907 return GenResult.mcv(.{ .load_symbol = sym_index });910 return GenResult.mcv(.{ .lea_symbol = sym_index });
908 } else if (lf.cast(.macho)) |macho_file| {911 } else if (lf.cast(.macho)) |macho_file| {
909 const zo = macho_file.getZigObject().?;912 const zo = macho_file.getZigObject().?;
910 if (is_extern) {913 if (is_extern) {