aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-04-16 15:02:08 +0200
committerGitHub <noreply@github.com>2023-04-16 15:02:08 +0200
commitbc804eb8419156980ec920c1ccb502c257c679b4 (patch)
tree4edceb28aa81f8a07eba46097886c321d388ba3b /src/codegen.zig
parent23ac4dd87b740012ba33e8ab2ea6fb25c04b6268 (diff)
parentecc52d859f7f1e400c8bfc08aea971f4596649cf (diff)
downloadzig-bc804eb8419156980ec920c1ccb502c257c679b4.tar.gz
zig-bc804eb8419156980ec920c1ccb502c257c679b4.zip
Merge pull request #15291 from ziglang/x86_64-more-memory
x86_64: fix memory loads some more
Diffstat (limited to 'src/codegen.zig')
-rw-r--r--src/codegen.zig36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index 6939b750fd..6d6238ceda 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -931,11 +931,17 @@ pub const GenResult = union(enum) {
/// The bit-width of the immediate may be smaller than `u64`. For example, on 32-bit targets
/// such as ARM, the immediate will never exceed 32-bits.
immediate: u64,
- linker_load: LinkerLoad,
- /// Pointer to a threadlocal variable.
- /// The address resolution will be deferred until the linker allocates everything in virtual memory.
+ /// Threadlocal variable with address deferred until the linker allocates
+ /// everything in virtual memory.
/// Payload is a symbol index.
- tlv_reloc: u32,
+ load_tlv: u32,
+ /// Decl with address deferred until the linker allocates everything in virtual memory.
+ /// Payload is a symbol index.
+ load_direct: u32,
+ /// Decl referenced via GOT with address deferred until the linker allocates
+ /// everything in virtual memory.
+ /// Payload is a symbol index.
+ load_got: u32,
/// Direct by-address reference to memory location.
memory: u64,
};
@@ -1005,19 +1011,13 @@ fn genDeclRef(
const atom_index = try macho_file.getOrCreateAtomForDecl(decl_index);
const sym_index = macho_file.getAtom(atom_index).getSymbolIndex().?;
if (is_threadlocal) {
- return GenResult.mcv(.{ .tlv_reloc = sym_index });
+ return GenResult.mcv(.{ .load_tlv = sym_index });
}
- return GenResult.mcv(.{ .linker_load = .{
- .type = .got,
- .sym_index = sym_index,
- } });
+ return GenResult.mcv(.{ .load_got = sym_index });
} else if (bin_file.cast(link.File.Coff)) |coff_file| {
const atom_index = try coff_file.getOrCreateAtomForDecl(decl_index);
const sym_index = coff_file.getAtom(atom_index).getSymbolIndex().?;
- return GenResult.mcv(.{ .linker_load = .{
- .type = .got,
- .sym_index = sym_index,
- } });
+ return GenResult.mcv(.{ .load_got = sym_index });
} else if (bin_file.cast(link.File.Plan9)) |p9| {
const decl_block_index = try p9.seeDecl(decl_index);
const decl_block = p9.getDeclBlock(decl_block_index);
@@ -1044,15 +1044,9 @@ fn genUnnamedConst(
if (bin_file.cast(link.File.Elf)) |elf_file| {
return GenResult.mcv(.{ .memory = elf_file.getSymbol(local_sym_index).st_value });
} else if (bin_file.cast(link.File.MachO)) |_| {
- return GenResult.mcv(.{ .linker_load = .{
- .type = .direct,
- .sym_index = local_sym_index,
- } });
+ return GenResult.mcv(.{ .load_direct = local_sym_index });
} else if (bin_file.cast(link.File.Coff)) |_| {
- return GenResult.mcv(.{ .linker_load = .{
- .type = .direct,
- .sym_index = local_sym_index,
- } });
+ return GenResult.mcv(.{ .load_direct = local_sym_index });
} else if (bin_file.cast(link.File.Plan9)) |p9| {
const ptr_bits = target.cpu.arch.ptrBitWidth();
const ptr_bytes: u64 = @divExact(ptr_bits, 8);