authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-18 19:11:48+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:41+01:00
loga79a038e61541d6faffaab70c82a18a812c2e9df
treefa231a598afc9a1b8671ecd6095180ffa8603704
parent96cc9fafbf0a382c0ed0b6142986cd8373cffaa3

codegen: implement more missing bits


2 files changed, 26 insertions(+), 22 deletions(-)

src/arch/x86_64/CodeGen.zig+22-19
......@@ -13507,24 +13507,27 @@ fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerEr
1350713507 },
1350813508 .lea_symbol => |sym_index| {
1350913509 const atom_index = try self.owner.getSymbolIndex(self);
13510 if (self.bin_file.cast(link.File.Elf)) |_| {
13511 try self.asmRegisterMemory(
13512 .{ ._, .lea },
13513 dst_reg.to64(),
13514 .{
13515 .base = .{ .reloc = .{
13516 .atom_index = atom_index,
13517 .sym_index = sym_index.sym,
13518 } },
13519 .mod = .{ .rm = .{
13520 .size = .qword,
13521 .disp = sym_index.off,
13522 } },
13523 },
13524 );
13525 } else return self.fail("TODO emit symbol sequence on {s}", .{
13526 @tagName(self.bin_file.tag),
13527 });
13510 switch (self.bin_file.tag) {
13511 .elf, .macho => {
13512 try self.asmRegisterMemory(
13513 .{ ._, .lea },
13514 dst_reg.to64(),
13515 .{
13516 .base = .{ .reloc = .{
13517 .atom_index = atom_index,
13518 .sym_index = sym_index.sym,
13519 } },
13520 .mod = .{ .rm = .{
13521 .size = .qword,
13522 .disp = sym_index.off,
13523 } },
13524 },
13525 );
13526 },
13527 else => return self.fail("TODO emit symbol sequence on {s}", .{
13528 @tagName(self.bin_file.tag),
13529 }),
13530 }
1352813531 },
1352913532 .lea_direct, .lea_got => |sym_index| {
1353013533 const atom_index = try self.owner.getSymbolIndex(self);
......@@ -16066,7 +16069,7 @@ fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {
1606616069 );
1606716070 break :init .{ .load_frame = .{ .index = frame_index } };
1606816071 } else if (self.bin_file.cast(link.File.MachO)) |_| {
16069 return self.fail("TODO implement lowering TLV variable to stack", .{});
16072 return self.fail("TODO implement saving TLV variable to stack", .{});
1607016073 } else break :init const_mcv,
1607116074 else => break :init const_mcv,
1607216075 }
src/codegen.zig+4-3
......@@ -998,9 +998,10 @@ fn genDeclRef(
998998 }
999999 const sym_index = try macho_file.getZigObject().?.getOrCreateMetadataForDecl(macho_file, decl_index);
10001000 const sym = macho_file.getSymbol(sym_index);
1001 if (is_threadlocal) {
1002 return GenResult.mcv(.{ .load_tlv = sym.nlist_idx });
1003 }
1001 // TODO: tlv
1002 // if (is_threadlocal) {
1003 // return GenResult.mcv(.{ .load_tlv = sym.nlist_idx });
1004 // }
10041005 return GenResult.mcv(.{ .load_symbol = sym.nlist_idx });
10051006 } else if (lf.cast(link.File.Coff)) |coff_file| {
10061007 if (is_extern) {