authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-04-12 10:36:28+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-04-13 11:47:51+02:00
logcf9ba2965eb90de994dd648950ad81041f90b755
tree699496fad3f422d8310fa051f9939d1b9497b3e5
parente07120d704fe931dd8f6952d20739dc1e1b194aa

x86_64: remove loadMemPtrIntoRegister() now redundant


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

src/arch/x86_64/CodeGen.zig-35
...@@ -3677,41 +3677,6 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {...@@ -3677,41 +3677,6 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
3677 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });3677 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
3678}3678}
36793679
3680fn loadMemPtrIntoRegister(self: *Self, reg: Register, ptr_ty: Type, ptr: MCValue) InnerError!void {
3681 switch (ptr) {
3682 .linker_load => |load_struct| {
3683 const abi_size = @intCast(u32, ptr_ty.abiSize(self.target.*));
3684 const atom_index = if (self.bin_file.cast(link.File.MachO)) |macho_file| blk: {
3685 const atom = try macho_file.getOrCreateAtomForDecl(self.mod_fn.owner_decl);
3686 break :blk macho_file.getAtom(atom).getSymbolIndex().?;
3687 } else if (self.bin_file.cast(link.File.Coff)) |coff_file| blk: {
3688 const atom = try coff_file.getOrCreateAtomForDecl(self.mod_fn.owner_decl);
3689 break :blk coff_file.getAtom(atom).getSymbolIndex().?;
3690 } else unreachable;
3691 const ops: Mir.Inst.Ops = switch (load_struct.type) {
3692 .got => .got_reloc,
3693 .direct => .direct_reloc,
3694 .import => .import_reloc,
3695 };
3696 _ = try self.addInst(.{
3697 .tag = .lea_linker,
3698 .ops = ops,
3699 .data = .{ .payload = try self.addExtra(Mir.LeaRegisterReloc{
3700 .reg = @enumToInt(registerAlias(reg, abi_size)),
3701 .atom_index = atom_index,
3702 .sym_index = load_struct.sym_index,
3703 }) },
3704 });
3705 },
3706 .memory => |addr| {
3707 // TODO: in case the address fits in an imm32 we can use [ds:imm32]
3708 // instead of wasting an instruction copying the address to a register
3709 try self.genSetReg(ptr_ty, reg, .{ .immediate = addr });
3710 },
3711 else => unreachable,
3712 }
3713}
3714
3715fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {3680fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {
3716 const abi_size = @intCast(u32, value_ty.abiSize(self.target.*));3681 const abi_size = @intCast(u32, value_ty.abiSize(self.target.*));
3717 switch (ptr) {3682 switch (ptr) {