authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-04-30 07:30:32-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-05-01 19:22:52-04:00
log19bd7d12b0186f0e45c77c564251d6355966b2ef
tree3baaa33fc62f7857b264e2ffea96dac616c5a57b
parent372bc960b8315ea1ff17b369b0b33485d5e34cfb

x86_64: factor out lazy_sym


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

src/arch/x86_64/CodeGen.zig+10-18
......@@ -6413,10 +6413,10 @@ fn airCmpLtErrorsLen(self: *Self, inst: Air.Inst.Index) !void {
64136413 const addr_lock = self.register_manager.lockRegAssumeUnused(addr_reg);
64146414 defer self.register_manager.unlockReg(addr_lock);
64156415
6416 const mod = self.bin_file.options.module.?;
6417 const lazy_sym = link.File.LazySymbol.initDecl(.const_data, null, mod);
64166418 if (self.bin_file.cast(link.File.Elf)) |elf_file| {
6417 const atom_index = try elf_file.getOrCreateAtomForLazySymbol(
6418 .{ .kind = .const_data, .ty = Type.anyerror },
6419 );
6419 const atom_index = try elf_file.getOrCreateAtomForLazySymbol(lazy_sym);
64206420 const atom = elf_file.getAtom(atom_index);
64216421 _ = try atom.getOrCreateOffsetTableEntry(elf_file);
64226422 const got_addr = atom.getOffsetTableAddress(elf_file);
......@@ -6426,15 +6426,11 @@ fn airCmpLtErrorsLen(self: *Self, inst: Air.Inst.Index) !void {
64266426 Memory.sib(.qword, .{ .base = .{ .reg = .ds }, .disp = @intCast(i32, got_addr) }),
64276427 );
64286428 } else if (self.bin_file.cast(link.File.Coff)) |coff_file| {
6429 const atom_index = try coff_file.getOrCreateAtomForLazySymbol(
6430 .{ .kind = .const_data, .ty = Type.anyerror },
6431 );
6429 const atom_index = try coff_file.getOrCreateAtomForLazySymbol(lazy_sym);
64326430 const sym_index = coff_file.getAtom(atom_index).getSymbolIndex().?;
64336431 try self.genSetReg(addr_reg, Type.usize, .{ .lea_got = sym_index });
64346432 } else if (self.bin_file.cast(link.File.MachO)) |macho_file| {
6435 const atom_index = try macho_file.getOrCreateAtomForLazySymbol(
6436 .{ .kind = .const_data, .ty = Type.anyerror },
6437 );
6433 const atom_index = try macho_file.getOrCreateAtomForLazySymbol(lazy_sym);
64386434 const sym_index = macho_file.getAtom(atom_index).getSymbolIndex().?;
64396435 try self.genSetReg(addr_reg, Type.usize, .{ .lea_got = sym_index });
64406436 } else {
......@@ -8498,10 +8494,10 @@ fn airErrorName(self: *Self, inst: Air.Inst.Index) !void {
84988494 const addr_lock = self.register_manager.lockRegAssumeUnused(addr_reg);
84998495 defer self.register_manager.unlockReg(addr_lock);
85008496
8497 const mod = self.bin_file.options.module.?;
8498 const lazy_sym = link.File.LazySymbol.initDecl(.const_data, null, mod);
85018499 if (self.bin_file.cast(link.File.Elf)) |elf_file| {
8502 const atom_index = try elf_file.getOrCreateAtomForLazySymbol(
8503 .{ .kind = .const_data, .ty = Type.anyerror },
8504 );
8500 const atom_index = try elf_file.getOrCreateAtomForLazySymbol(lazy_sym);
85058501 const atom = elf_file.getAtom(atom_index);
85068502 _ = try atom.getOrCreateOffsetTableEntry(elf_file);
85078503 const got_addr = atom.getOffsetTableAddress(elf_file);
......@@ -8511,15 +8507,11 @@ fn airErrorName(self: *Self, inst: Air.Inst.Index) !void {
85118507 Memory.sib(.qword, .{ .base = .{ .reg = .ds }, .disp = @intCast(i32, got_addr) }),
85128508 );
85138509 } else if (self.bin_file.cast(link.File.Coff)) |coff_file| {
8514 const atom_index = try coff_file.getOrCreateAtomForLazySymbol(
8515 .{ .kind = .const_data, .ty = Type.anyerror },
8516 );
8510 const atom_index = try coff_file.getOrCreateAtomForLazySymbol(lazy_sym);
85178511 const sym_index = coff_file.getAtom(atom_index).getSymbolIndex().?;
85188512 try self.genSetReg(addr_reg, Type.usize, .{ .lea_got = sym_index });
85198513 } else if (self.bin_file.cast(link.File.MachO)) |macho_file| {
8520 const atom_index = try macho_file.getOrCreateAtomForLazySymbol(
8521 .{ .kind = .const_data, .ty = Type.anyerror },
8522 );
8514 const atom_index = try macho_file.getOrCreateAtomForLazySymbol(lazy_sym);
85238515 const sym_index = macho_file.getAtom(atom_index).getSymbolIndex().?;
85248516 try self.genSetReg(addr_reg, Type.usize, .{ .lea_got = sym_index });
85258517 } else {