| ... | @@ -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 | } |
| 3679 | | 3679 | |
| 3680 | fn 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 | | | |
| 3715 | fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void { | 3680 | fn 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) { |