aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2024-01-18 19:11:48 +0100
committerJakub Konka <kubkon@jakubkonka.com>2024-01-24 12:34:41 +0100
commita79a038e61541d6faffaab70c82a18a812c2e9df (patch)
treefa231a598afc9a1b8671ecd6095180ffa8603704 /src
parent96cc9fafbf0a382c0ed0b6142986cd8373cffaa3 (diff)
downloadzig-a79a038e61541d6faffaab70c82a18a812c2e9df.tar.gz
zig-a79a038e61541d6faffaab70c82a18a812c2e9df.zip
codegen: implement more missing bits
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86_64/CodeGen.zig41
-rw-r--r--src/codegen.zig7
2 files changed, 26 insertions, 22 deletions
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig
index 2b4932c5c2..2cc5fe267e 100644
--- a/src/arch/x86_64/CodeGen.zig
+++ b/src/arch/x86_64/CodeGen.zig
@@ -13507,24 +13507,27 @@ fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerEr
},
.lea_symbol => |sym_index| {
const atom_index = try self.owner.getSymbolIndex(self);
- if (self.bin_file.cast(link.File.Elf)) |_| {
- try self.asmRegisterMemory(
- .{ ._, .lea },
- dst_reg.to64(),
- .{
- .base = .{ .reloc = .{
- .atom_index = atom_index,
- .sym_index = sym_index.sym,
- } },
- .mod = .{ .rm = .{
- .size = .qword,
- .disp = sym_index.off,
- } },
- },
- );
- } else return self.fail("TODO emit symbol sequence on {s}", .{
- @tagName(self.bin_file.tag),
- });
+ switch (self.bin_file.tag) {
+ .elf, .macho => {
+ try self.asmRegisterMemory(
+ .{ ._, .lea },
+ dst_reg.to64(),
+ .{
+ .base = .{ .reloc = .{
+ .atom_index = atom_index,
+ .sym_index = sym_index.sym,
+ } },
+ .mod = .{ .rm = .{
+ .size = .qword,
+ .disp = sym_index.off,
+ } },
+ },
+ );
+ },
+ else => return self.fail("TODO emit symbol sequence on {s}", .{
+ @tagName(self.bin_file.tag),
+ }),
+ }
},
.lea_direct, .lea_got => |sym_index| {
const atom_index = try self.owner.getSymbolIndex(self);
@@ -16066,7 +16069,7 @@ fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {
);
break :init .{ .load_frame = .{ .index = frame_index } };
} else if (self.bin_file.cast(link.File.MachO)) |_| {
- return self.fail("TODO implement lowering TLV variable to stack", .{});
+ return self.fail("TODO implement saving TLV variable to stack", .{});
} else break :init const_mcv,
else => break :init const_mcv,
}
diff --git a/src/codegen.zig b/src/codegen.zig
index 8172e15c3e..c39c541235 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -998,9 +998,10 @@ fn genDeclRef(
}
const sym_index = try macho_file.getZigObject().?.getOrCreateMetadataForDecl(macho_file, decl_index);
const sym = macho_file.getSymbol(sym_index);
- if (is_threadlocal) {
- return GenResult.mcv(.{ .load_tlv = sym.nlist_idx });
- }
+ // TODO: tlv
+ // if (is_threadlocal) {
+ // return GenResult.mcv(.{ .load_tlv = sym.nlist_idx });
+ // }
return GenResult.mcv(.{ .load_symbol = sym.nlist_idx });
} else if (lf.cast(link.File.Coff)) |coff_file| {
if (is_extern) {