authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-04-12 10:36:00+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-04-13 11:47:51+02:00
loge07120d704fe931dd8f6952d20739dc1e1b194aa
treeb7393e088a9cd9ae6f58d66819f8f8d9072cb51b
parent4e3573955fd912a6b2eee982f90743a939e8cbb1

x86_64: simplify genInlineMemset() when setting value in memory


1 files changed, 16 insertions(+), 2 deletions(-)

src/arch/x86_64/CodeGen.zig+16-2
...@@ -7564,11 +7564,25 @@ fn genInlineMemset(...@@ -7564,11 +7564,25 @@ fn genInlineMemset(
7564 try self.spillRegisters(&.{ .rdi, .al, .rcx });7564 try self.spillRegisters(&.{ .rdi, .al, .rcx });
75657565
7566 switch (dst_ptr) {7566 switch (dst_ptr) {
7567 .memory, .linker_load => {7567 .memory => |addr| {
7568 try self.loadMemPtrIntoRegister(.rdi, Type.usize, dst_ptr);7568 try self.genSetReg(Type.usize, .rdi, .{ .immediate = addr });
7569 // Load the pointer, which is stored in memory7569 // Load the pointer, which is stored in memory
7570 try self.asmRegisterMemory(.mov, .rdi, Memory.sib(.qword, .{ .base = .rdi }));7570 try self.asmRegisterMemory(.mov, .rdi, Memory.sib(.qword, .{ .base = .rdi }));
7571 },7571 },
7572 .linker_load => |load_struct| {
7573 const atom_index = if (self.bin_file.cast(link.File.MachO)) |macho_file| blk: {
7574 const atom = try macho_file.getOrCreateAtomForDecl(self.mod_fn.owner_decl);
7575 break :blk macho_file.getAtom(atom).getSymbolIndex().?;
7576 } else if (self.bin_file.cast(link.File.Coff)) |coff_file| blk: {
7577 const atom = try coff_file.getOrCreateAtomForDecl(self.mod_fn.owner_decl);
7578 break :blk coff_file.getAtom(atom).getSymbolIndex().?;
7579 } else unreachable;
7580
7581 switch (load_struct.type) {
7582 .import => unreachable,
7583 .got, .direct => try self.asmMovLinker(.rdi, atom_index, load_struct),
7584 }
7585 },
7572 .stack_offset, .ptr_stack_offset => |off| {7586 .stack_offset, .ptr_stack_offset => |off| {
7573 try self.asmRegisterMemory(switch (dst_ptr) {7587 try self.asmRegisterMemory(switch (dst_ptr) {
7574 .stack_offset => .mov,7588 .stack_offset => .mov,