aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
authorMeghan Denny <hello@nektro.net>2023-11-25 15:02:32 -0800
committerAndrew Kelley <andrew@ziglang.org>2023-11-26 02:24:40 -0500
commit2549de80b226cddd0664ce4ad8c40887101f302b (patch)
tree9674c446649114e88339256b24ef00660e1a168b /src/link
parent7103088e4a51d4362e6665d5949a9677e18fb74a (diff)
downloadzig-2549de80b226cddd0664ce4ad8c40887101f302b.tar.gz
zig-2549de80b226cddd0664ce4ad8c40887101f302b.zip
move Module.Decl.Index and Module.Namespace.Index to InternPool
Diffstat (limited to 'src/link')
-rw-r--r--src/link/C.zig8
-rw-r--r--src/link/Coff.zig26
-rw-r--r--src/link/Dwarf.zig18
-rw-r--r--src/link/Elf.zig12
-rw-r--r--src/link/Elf/ZigObject.zig26
-rw-r--r--src/link/MachO.zig28
-rw-r--r--src/link/NvPtx.zig4
-rw-r--r--src/link/Plan9.zig32
-rw-r--r--src/link/SpirV.zig4
-rw-r--r--src/link/Wasm.zig22
10 files changed, 90 insertions, 90 deletions
diff --git a/src/link/C.zig b/src/link/C.zig
index 3632029418..a8721a0c02 100644
--- a/src/link/C.zig
+++ b/src/link/C.zig
@@ -24,7 +24,7 @@ base: link.File,
/// This linker backend does not try to incrementally link output C source code.
/// Instead, it tracks all declarations in this table, and iterates over it
/// in the flush function, stitching pre-rendered pieces of C code together.
-decl_table: std.AutoArrayHashMapUnmanaged(Module.Decl.Index, DeclBlock) = .{},
+decl_table: std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, DeclBlock) = .{},
/// All the string bytes of rendered C code, all squished into one array.
/// While in progress, a separate buffer is used, and then when finished, the
/// buffer is copied into this one.
@@ -138,7 +138,7 @@ pub fn deinit(self: *C) void {
self.code_buf.deinit(gpa);
}
-pub fn freeDecl(self: *C, decl_index: Module.Decl.Index) void {
+pub fn freeDecl(self: *C, decl_index: InternPool.DeclIndex) void {
const gpa = self.base.allocator;
if (self.decl_table.fetchSwapRemove(decl_index)) |kv| {
var decl_block = kv.value;
@@ -279,7 +279,7 @@ fn updateAnonDecl(self: *C, module: *Module, i: usize) !void {
};
}
-pub fn updateDecl(self: *C, module: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDecl(self: *C, module: *Module, decl_index: InternPool.DeclIndex) !void {
const tracy = trace(@src());
defer tracy.end();
@@ -337,7 +337,7 @@ pub fn updateDecl(self: *C, module: *Module, decl_index: Module.Decl.Index) !voi
gop.value_ptr.fwd_decl = try self.addString(object.dg.fwd_decl.items);
}
-pub fn updateDeclLineNumber(self: *C, module: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDeclLineNumber(self: *C, module: *Module, decl_index: InternPool.DeclIndex) !void {
// The C backend does not have the ability to fix line numbers without re-generating
// the entire Decl.
_ = self;
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
index fc60fc6b48..44b329d5b9 100644
--- a/src/link/Coff.zig
+++ b/src/link/Coff.zig
@@ -109,11 +109,11 @@ const HotUpdateState = struct {
loaded_base_address: ?std.os.windows.HMODULE = null,
};
-const DeclTable = std.AutoArrayHashMapUnmanaged(Module.Decl.Index, DeclMetadata);
+const DeclTable = std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, DeclMetadata);
const AnonDeclTable = std.AutoHashMapUnmanaged(InternPool.Index, DeclMetadata);
const RelocTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(Relocation));
const BaseRelocationTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(u32));
-const UnnamedConstTable = std.AutoArrayHashMapUnmanaged(Module.Decl.Index, std.ArrayListUnmanaged(Atom.Index));
+const UnnamedConstTable = std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, std.ArrayListUnmanaged(Atom.Index));
const default_file_alignment: u16 = 0x200;
const default_size_of_stack_reserve: u32 = 0x1000000;
@@ -144,7 +144,7 @@ const Section = struct {
free_list: std.ArrayListUnmanaged(Atom.Index) = .{},
};
-const LazySymbolTable = std.AutoArrayHashMapUnmanaged(Module.Decl.OptionalIndex, LazySymbolMetadata);
+const LazySymbolTable = std.AutoArrayHashMapUnmanaged(InternPool.OptionalDeclIndex, LazySymbolMetadata);
const LazySymbolMetadata = struct {
const State = enum { unused, pending_flush, flushed };
@@ -1087,7 +1087,7 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air:
return self.updateExports(mod, .{ .decl_index = decl_index }, mod.getDeclExports(decl_index));
}
-pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: Module.Decl.Index) !u32 {
+pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: InternPool.DeclIndex) !u32 {
const gpa = self.base.allocator;
const mod = self.base.options.module.?;
const decl = mod.declPtr(decl_index);
@@ -1157,7 +1157,7 @@ fn lowerConst(self: *Coff, name: []const u8, tv: TypedValue, required_alignment:
pub fn updateDecl(
self: *Coff,
mod: *Module,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
) link.File.UpdateDeclError!void {
if (build_options.skip_non_native and builtin.object_format != .coff) {
@panic("Attempted to compile for object format that was disabled by build configuration");
@@ -1302,7 +1302,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *Coff, sym: link.File.LazySymbol) !Ato
return atom;
}
-pub fn getOrCreateAtomForDecl(self: *Coff, decl_index: Module.Decl.Index) !Atom.Index {
+pub fn getOrCreateAtomForDecl(self: *Coff, decl_index: InternPool.DeclIndex) !Atom.Index {
const gop = try self.decls.getOrPut(self.base.allocator, decl_index);
if (!gop.found_existing) {
gop.value_ptr.* = .{
@@ -1314,7 +1314,7 @@ pub fn getOrCreateAtomForDecl(self: *Coff, decl_index: Module.Decl.Index) !Atom.
return gop.value_ptr.atom;
}
-fn getDeclOutputSection(self: *Coff, decl_index: Module.Decl.Index) u16 {
+fn getDeclOutputSection(self: *Coff, decl_index: InternPool.DeclIndex) u16 {
const decl = self.base.options.module.?.declPtr(decl_index);
const ty = decl.ty;
const mod = self.base.options.module.?;
@@ -1340,7 +1340,7 @@ fn getDeclOutputSection(self: *Coff, decl_index: Module.Decl.Index) u16 {
return index;
}
-fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, complex_type: coff.ComplexType) !void {
+fn updateDeclCode(self: *Coff, decl_index: InternPool.DeclIndex, code: []u8, complex_type: coff.ComplexType) !void {
const mod = self.base.options.module.?;
const decl = mod.declPtr(decl_index);
@@ -1398,7 +1398,7 @@ fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, comple
try self.writeAtom(atom_index, code);
}
-fn freeUnnamedConsts(self: *Coff, decl_index: Module.Decl.Index) void {
+fn freeUnnamedConsts(self: *Coff, decl_index: InternPool.DeclIndex) void {
const gpa = self.base.allocator;
const unnamed_consts = self.unnamed_const_atoms.getPtr(decl_index) orelse return;
for (unnamed_consts.items) |atom_index| {
@@ -1407,7 +1407,7 @@ fn freeUnnamedConsts(self: *Coff, decl_index: Module.Decl.Index) void {
unnamed_consts.clearAndFree(gpa);
}
-pub fn freeDecl(self: *Coff, decl_index: Module.Decl.Index) void {
+pub fn freeDecl(self: *Coff, decl_index: InternPool.DeclIndex) void {
if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);
const mod = self.base.options.module.?;
@@ -1563,7 +1563,7 @@ pub fn updateExports(
pub fn deleteDeclExport(
self: *Coff,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
name_ip: InternPool.NullTerminatedString,
) void {
if (self.llvm_object) |_| return;
@@ -1766,7 +1766,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
assert(!self.imports_count_dirty);
}
-pub fn getDeclVAddr(self: *Coff, decl_index: Module.Decl.Index, reloc_info: link.File.RelocInfo) !u64 {
+pub fn getDeclVAddr(self: *Coff, decl_index: InternPool.DeclIndex, reloc_info: link.File.RelocInfo) !u64 {
assert(self.llvm_object == null);
const this_atom_index = try self.getOrCreateAtomForDecl(decl_index);
@@ -1882,7 +1882,7 @@ pub fn getGlobalSymbol(self: *Coff, name: []const u8, lib_name_name: ?[]const u8
return global_index;
}
-pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl_index: InternPool.DeclIndex) !void {
_ = self;
_ = module;
_ = decl_index;
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
index f9fe41c029..ef803a45f1 100644
--- a/src/link/Dwarf.zig
+++ b/src/link/Dwarf.zig
@@ -35,7 +35,7 @@ di_files: std.AutoArrayHashMapUnmanaged(*const Module.File, void) = .{},
global_abbrev_relocs: std.ArrayListUnmanaged(AbbrevRelocation) = .{},
-const AtomTable = std.AutoHashMapUnmanaged(Module.Decl.Index, Atom.Index);
+const AtomTable = std.AutoHashMapUnmanaged(InternPool.DeclIndex, Atom.Index);
const Atom = struct {
/// Offset into .debug_info pointing to the tag for this Decl, or
@@ -555,7 +555,7 @@ pub const DeclState = struct {
self: *DeclState,
name: [:0]const u8,
ty: Type,
- owner_decl: Module.Decl.Index,
+ owner_decl: InternPool.DeclIndex,
loc: DbgInfoLoc,
) error{OutOfMemory}!void {
const dbg_info = &self.dbg_info;
@@ -669,7 +669,7 @@ pub const DeclState = struct {
self: *DeclState,
name: [:0]const u8,
ty: Type,
- owner_decl: Module.Decl.Index,
+ owner_decl: InternPool.DeclIndex,
is_ptr: bool,
loc: DbgInfoLoc,
) error{OutOfMemory}!void {
@@ -1073,7 +1073,7 @@ pub fn deinit(self: *Dwarf) void {
/// Initializes Decl's state and its matching output buffers.
/// Call this before `commitDeclState`.
-pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) !DeclState {
+pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclIndex) !DeclState {
const tracy = trace(@src());
defer tracy.end();
@@ -1191,7 +1191,7 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index)
pub fn commitDeclState(
self: *Dwarf,
mod: *Module,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
sym_addr: u64,
sym_size: u64,
decl_state: *DeclState,
@@ -1640,7 +1640,7 @@ fn writeDeclDebugInfo(self: *Dwarf, atom_index: Atom.Index, dbg_info_buf: []cons
}
}
-pub fn updateDeclLineNumber(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDeclLineNumber(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclIndex) !void {
const tracy = trace(@src());
defer tracy.end();
@@ -1682,7 +1682,7 @@ pub fn updateDeclLineNumber(self: *Dwarf, mod: *Module, decl_index: Module.Decl.
}
}
-pub fn freeDecl(self: *Dwarf, decl_index: Module.Decl.Index) void {
+pub fn freeDecl(self: *Dwarf, decl_index: InternPool.DeclIndex) void {
const gpa = self.allocator;
// Free SrcFn atom
@@ -2627,7 +2627,7 @@ pub fn flushModule(self: *Dwarf, module: *Module) !void {
}
}
-fn addDIFile(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) !u28 {
+fn addDIFile(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclIndex) !u28 {
const decl = mod.declPtr(decl_index);
const file_scope = decl.getFileScope(mod);
const gop = try self.di_files.getOrPut(self.allocator, file_scope);
@@ -2771,7 +2771,7 @@ fn createAtom(self: *Dwarf, comptime kind: Kind) !Atom.Index {
return index;
}
-fn getOrCreateAtomForDecl(self: *Dwarf, comptime kind: Kind, decl_index: Module.Decl.Index) !Atom.Index {
+fn getOrCreateAtomForDecl(self: *Dwarf, comptime kind: Kind, decl_index: InternPool.DeclIndex) !Atom.Index {
switch (kind) {
.src_fn => {
const gop = try self.src_fn_decls.getOrPut(self.allocator, decl_index);
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index e64ad222ad..7c1e46dd89 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -400,7 +400,7 @@ pub fn deinit(self: *Elf) void {
self.comdat_group_sections.deinit(gpa);
}
-pub fn getDeclVAddr(self: *Elf, decl_index: Module.Decl.Index, reloc_info: link.File.RelocInfo) !u64 {
+pub fn getDeclVAddr(self: *Elf, decl_index: InternPool.DeclIndex, reloc_info: link.File.RelocInfo) !u64 {
assert(self.llvm_object == null);
return self.zigObjectPtr().?.getDeclVAddr(self, decl_index, reloc_info);
}
@@ -3127,7 +3127,7 @@ fn writeElfHeader(self: *Elf) !void {
try self.base.file.?.pwriteAll(hdr_buf[0..index], 0);
}
-pub fn freeDecl(self: *Elf, decl_index: Module.Decl.Index) void {
+pub fn freeDecl(self: *Elf, decl_index: InternPool.DeclIndex) void {
if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);
return self.zigObjectPtr().?.freeDecl(self, decl_index);
}
@@ -3143,7 +3143,7 @@ pub fn updateFunc(self: *Elf, mod: *Module, func_index: InternPool.Index, air: A
pub fn updateDecl(
self: *Elf,
mod: *Module,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
) link.File.UpdateDeclError!void {
if (build_options.skip_non_native and builtin.object_format != .elf) {
@panic("Attempted to compile for object format that was disabled by build configuration");
@@ -3152,7 +3152,7 @@ pub fn updateDecl(
return self.zigObjectPtr().?.updateDecl(self, mod, decl_index);
}
-pub fn lowerUnnamedConst(self: *Elf, typed_value: TypedValue, decl_index: Module.Decl.Index) !u32 {
+pub fn lowerUnnamedConst(self: *Elf, typed_value: TypedValue, decl_index: InternPool.DeclIndex) !u32 {
return self.zigObjectPtr().?.lowerUnnamedConst(self, typed_value, decl_index);
}
@@ -3170,14 +3170,14 @@ pub fn updateExports(
return self.zigObjectPtr().?.updateExports(self, mod, exported, exports);
}
-pub fn updateDeclLineNumber(self: *Elf, mod: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDeclLineNumber(self: *Elf, mod: *Module, decl_index: InternPool.DeclIndex) !void {
if (self.llvm_object) |_| return;
return self.zigObjectPtr().?.updateDeclLineNumber(mod, decl_index);
}
pub fn deleteDeclExport(
self: *Elf,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
name: InternPool.NullTerminatedString,
) void {
if (self.llvm_object) |_| return;
diff --git a/src/link/Elf/ZigObject.zig b/src/link/Elf/ZigObject.zig
index ae546c5d62..ef029c7702 100644
--- a/src/link/Elf/ZigObject.zig
+++ b/src/link/Elf/ZigObject.zig
@@ -618,7 +618,7 @@ pub fn codeAlloc(self: ZigObject, elf_file: *Elf, atom_index: Atom.Index) ![]u8
pub fn getDeclVAddr(
self: *ZigObject,
elf_file: *Elf,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
reloc_info: link.File.RelocInfo,
) !u64 {
const this_sym_index = try self.getOrCreateMetadataForDecl(elf_file, decl_index);
@@ -741,7 +741,7 @@ pub fn getOrCreateMetadataForLazySymbol(
return symbol_index;
}
-fn freeUnnamedConsts(self: *ZigObject, elf_file: *Elf, decl_index: Module.Decl.Index) void {
+fn freeUnnamedConsts(self: *ZigObject, elf_file: *Elf, decl_index: InternPool.DeclIndex) void {
const unnamed_consts = self.unnamed_consts.getPtr(decl_index) orelse return;
for (unnamed_consts.items) |sym_index| {
self.freeDeclMetadata(elf_file, sym_index);
@@ -759,7 +759,7 @@ fn freeDeclMetadata(self: *ZigObject, elf_file: *Elf, sym_index: Symbol.Index) v
// TODO free GOT entry here
}
-pub fn freeDecl(self: *ZigObject, elf_file: *Elf, decl_index: Module.Decl.Index) void {
+pub fn freeDecl(self: *ZigObject, elf_file: *Elf, decl_index: InternPool.DeclIndex) void {
const mod = elf_file.base.options.module.?;
const decl = mod.declPtr(decl_index);
@@ -781,7 +781,7 @@ pub fn freeDecl(self: *ZigObject, elf_file: *Elf, decl_index: Module.Decl.Index)
pub fn getOrCreateMetadataForDecl(
self: *ZigObject,
elf_file: *Elf,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
) !Symbol.Index {
const gop = try self.decls.getOrPut(elf_file.base.allocator, decl_index);
if (!gop.found_existing) {
@@ -857,7 +857,7 @@ fn getDeclShdrIndex(
fn updateDeclCode(
self: *ZigObject,
elf_file: *Elf,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
sym_index: Symbol.Index,
shdr_index: u16,
code: []const u8,
@@ -956,7 +956,7 @@ fn updateDeclCode(
fn updateTlv(
self: *ZigObject,
elf_file: *Elf,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
sym_index: Symbol.Index,
shndx: u16,
code: []const u8,
@@ -1083,7 +1083,7 @@ pub fn updateDecl(
self: *ZigObject,
elf_file: *Elf,
mod: *Module,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
) link.File.UpdateDeclError!void {
const tracy = trace(@src());
defer tracy.end();
@@ -1249,7 +1249,7 @@ pub fn lowerUnnamedConst(
self: *ZigObject,
elf_file: *Elf,
typed_value: TypedValue,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
) !u32 {
const gpa = elf_file.base.allocator;
const mod = elf_file.base.options.module.?;
@@ -1435,7 +1435,7 @@ pub fn updateExports(
pub fn updateDeclLineNumber(
self: *ZigObject,
mod: *Module,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
) !void {
const tracy = trace(@src());
defer tracy.end();
@@ -1453,7 +1453,7 @@ pub fn updateDeclLineNumber(
pub fn deleteDeclExport(
self: *ZigObject,
elf_file: *Elf,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
name: InternPool.NullTerminatedString,
) void {
const metadata = self.decls.getPtr(decl_index) orelse return;
@@ -1584,10 +1584,10 @@ const TlsVariable = struct {
};
const AtomList = std.ArrayListUnmanaged(Atom.Index);
-const UnnamedConstTable = std.AutoHashMapUnmanaged(Module.Decl.Index, std.ArrayListUnmanaged(Symbol.Index));
-const DeclTable = std.AutoHashMapUnmanaged(Module.Decl.Index, DeclMetadata);
+const UnnamedConstTable = std.AutoHashMapUnmanaged(InternPool.DeclIndex, std.ArrayListUnmanaged(Symbol.Index));
+const DeclTable = std.AutoHashMapUnmanaged(InternPool.DeclIndex, DeclMetadata);
const AnonDeclTable = std.AutoHashMapUnmanaged(InternPool.Index, DeclMetadata);
-const LazySymbolTable = std.AutoArrayHashMapUnmanaged(Module.Decl.OptionalIndex, LazySymbolMetadata);
+const LazySymbolTable = std.AutoArrayHashMapUnmanaged(InternPool.OptionalDeclIndex, LazySymbolMetadata);
const TlsTable = std.AutoArrayHashMapUnmanaged(Atom.Index, TlsVariable);
const assert = std.debug.assert;
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index 9d30c374dc..61446b3300 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -2278,7 +2278,7 @@ pub fn updateFunc(self: *MachO, mod: *Module, func_index: InternPool.Index, air:
try self.updateExports(mod, .{ .decl_index = decl_index }, mod.getDeclExports(decl_index));
}
-pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: Module.Decl.Index) !u32 {
+pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: InternPool.DeclIndex) !u32 {
const gpa = self.base.allocator;
const mod = self.base.options.module.?;
const gop = try self.unnamed_const_atoms.getOrPut(gpa, decl_index);
@@ -2358,7 +2358,7 @@ fn lowerConst(
return .{ .ok = atom_index };
}
-pub fn updateDecl(self: *MachO, mod: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDecl(self: *MachO, mod: *Module, decl_index: InternPool.DeclIndex) !void {
if (build_options.skip_non_native and builtin.object_format != .macho) {
@panic("Attempted to compile for object format that was disabled by build configuration");
}
@@ -2544,7 +2544,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *MachO, sym: File.LazySymbol) !Atom.In
return atom;
}
-fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: Module.Decl.Index) !void {
+fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: InternPool.DeclIndex) !void {
const mod = self.base.options.module.?;
// Lowering a TLV on macOS involves two stages:
// 1. first we lower the initializer into appopriate section (__thread_data or __thread_bss)
@@ -2639,7 +2639,7 @@ fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: Module.D
self.markRelocsDirtyByTarget(init_atom_sym_loc);
}
-pub fn getOrCreateAtomForDecl(self: *MachO, decl_index: Module.Decl.Index) !Atom.Index {
+pub fn getOrCreateAtomForDecl(self: *MachO, decl_index: InternPool.DeclIndex) !Atom.Index {
const gop = try self.decls.getOrPut(self.base.allocator, decl_index);
if (!gop.found_existing) {
const sym_index = try self.allocateSymbol();
@@ -2654,7 +2654,7 @@ pub fn getOrCreateAtomForDecl(self: *MachO, decl_index: Module.Decl.Index) !Atom
return gop.value_ptr.atom;
}
-fn getDeclOutputSection(self: *MachO, decl_index: Module.Decl.Index) u8 {
+fn getDeclOutputSection(self: *MachO, decl_index: InternPool.DeclIndex) u8 {
const decl = self.base.options.module.?.declPtr(decl_index);
const ty = decl.ty;
const val = decl.val;
@@ -2693,7 +2693,7 @@ fn getDeclOutputSection(self: *MachO, decl_index: Module.Decl.Index) u8 {
return sect_id;
}
-fn updateDeclCode(self: *MachO, decl_index: Module.Decl.Index, code: []u8) !u64 {
+fn updateDeclCode(self: *MachO, decl_index: InternPool.DeclIndex, code: []u8) !u64 {
const gpa = self.base.allocator;
const mod = self.base.options.module.?;
const decl = mod.declPtr(decl_index);
@@ -2764,7 +2764,7 @@ fn updateDeclCode(self: *MachO, decl_index: Module.Decl.Index, code: []u8) !u64
return atom.getSymbol(self).n_value;
}
-pub fn updateDeclLineNumber(self: *MachO, module: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDeclLineNumber(self: *MachO, module: *Module, decl_index: InternPool.DeclIndex) !void {
if (self.d_sym) |*d_sym| {
try d_sym.dwarf.updateDeclLineNumber(module, decl_index);
}
@@ -2906,7 +2906,7 @@ pub fn updateExports(
pub fn deleteDeclExport(
self: *MachO,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
name: InternPool.NullTerminatedString,
) Allocator.Error!void {
if (self.llvm_object) |_| return;
@@ -2940,7 +2940,7 @@ pub fn deleteDeclExport(
sym_index.* = 0;
}
-fn freeUnnamedConsts(self: *MachO, decl_index: Module.Decl.Index) void {
+fn freeUnnamedConsts(self: *MachO, decl_index: InternPool.DeclIndex) void {
const gpa = self.base.allocator;
const unnamed_consts = self.unnamed_const_atoms.getPtr(decl_index) orelse return;
for (unnamed_consts.items) |atom| {
@@ -2949,7 +2949,7 @@ fn freeUnnamedConsts(self: *MachO, decl_index: Module.Decl.Index) void {
unnamed_consts.clearAndFree(gpa);
}
-pub fn freeDecl(self: *MachO, decl_index: Module.Decl.Index) void {
+pub fn freeDecl(self: *MachO, decl_index: InternPool.DeclIndex) void {
if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);
const mod = self.base.options.module.?;
const decl = mod.declPtr(decl_index);
@@ -2968,7 +2968,7 @@ pub fn freeDecl(self: *MachO, decl_index: Module.Decl.Index) void {
}
}
-pub fn getDeclVAddr(self: *MachO, decl_index: Module.Decl.Index, reloc_info: File.RelocInfo) !u64 {
+pub fn getDeclVAddr(self: *MachO, decl_index: InternPool.DeclIndex, reloc_info: File.RelocInfo) !u64 {
assert(self.llvm_object == null);
const this_atom_index = try self.getOrCreateAtomForDecl(decl_index);
@@ -5667,7 +5667,7 @@ const is_hot_update_compatible = switch (builtin.target.os.tag) {
else => false,
};
-const LazySymbolTable = std.AutoArrayHashMapUnmanaged(Module.Decl.OptionalIndex, LazySymbolMetadata);
+const LazySymbolTable = std.AutoArrayHashMapUnmanaged(InternPool.OptionalDeclIndex, LazySymbolMetadata);
const LazySymbolMetadata = struct {
const State = enum { unused, pending_flush, flushed };
@@ -5701,10 +5701,10 @@ const DeclMetadata = struct {
}
};
-const DeclTable = std.AutoArrayHashMapUnmanaged(Module.Decl.Index, DeclMetadata);
+const DeclTable = std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, DeclMetadata);
const AnonDeclTable = std.AutoHashMapUnmanaged(InternPool.Index, DeclMetadata);
const BindingTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(Atom.Binding));
-const UnnamedConstTable = std.AutoArrayHashMapUnmanaged(Module.Decl.Index, std.ArrayListUnmanaged(Atom.Index));
+const UnnamedConstTable = std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, std.ArrayListUnmanaged(Atom.Index));
const RebaseTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(u32));
const RelocationTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(Relocation));
const ActionTable = std.AutoHashMapUnmanaged(u32, RelocFlags);
diff --git a/src/link/NvPtx.zig b/src/link/NvPtx.zig
index 5ccdb7218a..606c5f1237 100644
--- a/src/link/NvPtx.zig
+++ b/src/link/NvPtx.zig
@@ -70,7 +70,7 @@ pub fn updateFunc(self: *NvPtx, module: *Module, func_index: InternPool.Index, a
try self.llvm_object.updateFunc(module, func_index, air, liveness);
}
-pub fn updateDecl(self: *NvPtx, module: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDecl(self: *NvPtx, module: *Module, decl_index: InternPool.DeclIndex) !void {
return self.llvm_object.updateDecl(module, decl_index);
}
@@ -86,7 +86,7 @@ pub fn updateExports(
return self.llvm_object.updateExports(module, exported, exports);
}
-pub fn freeDecl(self: *NvPtx, decl_index: Module.Decl.Index) void {
+pub fn freeDecl(self: *NvPtx, decl_index: InternPool.DeclIndex) void {
return self.llvm_object.freeDecl(decl_index);
}
diff --git a/src/link/Plan9.zig b/src/link/Plan9.zig
index 0d29cae6dc..b608b29161 100644
--- a/src/link/Plan9.zig
+++ b/src/link/Plan9.zig
@@ -56,10 +56,10 @@ path_arena: std.heap.ArenaAllocator,
/// If we group the decls by file, it makes it really easy to do this (put the symbol in the correct place)
fn_decl_table: std.AutoArrayHashMapUnmanaged(
*Module.File,
- struct { sym_index: u32, functions: std.AutoArrayHashMapUnmanaged(Module.Decl.Index, FnDeclOutput) = .{} },
+ struct { sym_index: u32, functions: std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, FnDeclOutput) = .{} },
) = .{},
/// the code is modified when relocated, so that is why it is mutable
-data_decl_table: std.AutoArrayHashMapUnmanaged(Module.Decl.Index, []u8) = .{},
+data_decl_table: std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, []u8) = .{},
/// Table of unnamed constants associated with a parent `Decl`.
/// We store them here so that we can free the constants whenever the `Decl`
@@ -102,7 +102,7 @@ got_index_free_list: std.ArrayListUnmanaged(usize) = .{},
syms_index_free_list: std.ArrayListUnmanaged(usize) = .{},
atoms: std.ArrayListUnmanaged(Atom) = .{},
-decls: std.AutoHashMapUnmanaged(Module.Decl.Index, DeclMetadata) = .{},
+decls: std.AutoHashMapUnmanaged(InternPool.DeclIndex, DeclMetadata) = .{},
/// Indices of the three "special" symbols into atoms
etext_edata_end_atom_indices: [3]?Atom.Index = .{ null, null, null },
@@ -129,9 +129,9 @@ const Bases = struct {
data: u64,
};
-const UnnamedConstTable = std.AutoHashMapUnmanaged(Module.Decl.Index, std.ArrayListUnmanaged(Atom.Index));
+const UnnamedConstTable = std.AutoHashMapUnmanaged(InternPool.DeclIndex, std.ArrayListUnmanaged(Atom.Index));
-const LazySymbolTable = std.AutoArrayHashMapUnmanaged(Module.Decl.OptionalIndex, LazySymbolMetadata);
+const LazySymbolTable = std.AutoArrayHashMapUnmanaged(InternPool.OptionalDeclIndex, LazySymbolMetadata);
const LazySymbolMetadata = struct {
const State = enum { unused, pending_flush, flushed };
@@ -168,7 +168,7 @@ pub const Atom = struct {
code_ptr: ?[*]u8,
other: union {
code_len: usize,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
},
fn fromSlice(slice: []u8) CodePtr {
return .{ .code_ptr = slice.ptr, .other = .{ .code_len = slice.len } };
@@ -322,7 +322,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Plan9 {
return self;
}
-fn putFn(self: *Plan9, decl_index: Module.Decl.Index, out: FnDeclOutput) !void {
+fn putFn(self: *Plan9, decl_index: InternPool.DeclIndex, out: FnDeclOutput) !void {
const gpa = self.base.allocator;
const mod = self.base.options.module.?;
const decl = mod.declPtr(decl_index);
@@ -447,7 +447,7 @@ pub fn updateFunc(self: *Plan9, mod: *Module, func_index: InternPool.Index, air:
return self.updateFinish(decl_index);
}
-pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.Index) !u32 {
+pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: InternPool.DeclIndex) !u32 {
_ = try self.seeDecl(decl_index);
var code_buffer = std.ArrayList(u8).init(self.base.allocator);
defer code_buffer.deinit();
@@ -508,7 +508,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I
return new_atom_idx;
}
-pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: InternPool.DeclIndex) !void {
const decl = mod.declPtr(decl_index);
if (decl.isExtern(mod)) {
@@ -544,7 +544,7 @@ pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: Module.Decl.Index) !vo
return self.updateFinish(decl_index);
}
/// called at the end of update{Decl,Func}
-fn updateFinish(self: *Plan9, decl_index: Module.Decl.Index) !void {
+fn updateFinish(self: *Plan9, decl_index: InternPool.DeclIndex) !void {
const mod = self.base.options.module.?;
const decl = mod.declPtr(decl_index);
const is_fn = (decl.ty.zigTypeTag(mod) == .Fn);
@@ -982,7 +982,7 @@ pub fn flushModule(self: *Plan9, comp: *Compilation, prog_node: *std.Progress.No
fn addDeclExports(
self: *Plan9,
mod: *Module,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
exports: []const *Module.Export,
) !void {
const metadata = self.decls.getPtr(decl_index).?;
@@ -1017,7 +1017,7 @@ fn addDeclExports(
}
}
-pub fn freeDecl(self: *Plan9, decl_index: Module.Decl.Index) void {
+pub fn freeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) void {
// TODO audit the lifetimes of decls table entries. It's possible to get
// freeDecl without any updateDecl in between.
// However that is planned to change, see the TODO comment in Module.zig
@@ -1063,7 +1063,7 @@ pub fn freeDecl(self: *Plan9, decl_index: Module.Decl.Index) void {
assert(self.relocs.remove(atom_index));
}
}
-fn freeUnnamedConsts(self: *Plan9, decl_index: Module.Decl.Index) void {
+fn freeUnnamedConsts(self: *Plan9, decl_index: InternPool.DeclIndex) void {
const unnamed_consts = self.unnamed_const_atoms.getPtr(decl_index) orelse return;
for (unnamed_consts.items) |atom_idx| {
const atom = self.getAtom(atom_idx);
@@ -1088,7 +1088,7 @@ fn createAtom(self: *Plan9) !Atom.Index {
return index;
}
-pub fn seeDecl(self: *Plan9, decl_index: Module.Decl.Index) !Atom.Index {
+pub fn seeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) !Atom.Index {
const gop = try self.decls.getOrPut(self.base.allocator, decl_index);
if (!gop.found_existing) {
const index = try self.createAtom();
@@ -1428,7 +1428,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void {
}
/// Must be called only after a successful call to `updateDecl`.
-pub fn updateDeclLineNumber(self: *Plan9, mod: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDeclLineNumber(self: *Plan9, mod: *Module, decl_index: InternPool.DeclIndex) !void {
_ = self;
_ = mod;
_ = decl_index;
@@ -1436,7 +1436,7 @@ pub fn updateDeclLineNumber(self: *Plan9, mod: *Module, decl_index: Module.Decl.
pub fn getDeclVAddr(
self: *Plan9,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
reloc_info: link.File.RelocInfo,
) !u64 {
const mod = self.base.options.module.?;
diff --git a/src/link/SpirV.zig b/src/link/SpirV.zig
index d897029f24..ac36a391ec 100644
--- a/src/link/SpirV.zig
+++ b/src/link/SpirV.zig
@@ -109,7 +109,7 @@ pub fn updateFunc(self: *SpirV, module: *Module, func_index: InternPool.Index, a
try self.object.updateFunc(module, func_index, air, liveness);
}
-pub fn updateDecl(self: *SpirV, module: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDecl(self: *SpirV, module: *Module, decl_index: InternPool.DeclIndex) !void {
if (build_options.skip_non_native) {
@panic("Attempted to compile for architecture that was disabled by build configuration");
}
@@ -144,7 +144,7 @@ pub fn updateExports(
// TODO: Export regular functions, variables, etc using Linkage attributes.
}
-pub fn freeDecl(self: *SpirV, decl_index: Module.Decl.Index) void {
+pub fn freeDecl(self: *SpirV, decl_index: InternPool.DeclIndex) void {
_ = self;
_ = decl_index;
}
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 8b1039497c..82f9f9f20d 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -48,7 +48,7 @@ llvm_object: ?*LlvmObject = null,
host_name: []const u8 = "env",
/// List of all `Decl` that are currently alive.
/// Each index maps to the corresponding `Atom.Index`.
-decls: std.AutoHashMapUnmanaged(Module.Decl.Index, Atom.Index) = .{},
+decls: std.AutoHashMapUnmanaged(InternPool.DeclIndex, Atom.Index) = .{},
/// Mapping between an `Atom` and its type index representing the Wasm
/// type of the function signature.
atom_types: std.AutoHashMapUnmanaged(Atom.Index, u32) = .{},
@@ -598,10 +598,10 @@ fn parseObjectFile(wasm: *Wasm, path: []const u8) !bool {
return true;
}
-/// For a given `Module.Decl.Index` returns its corresponding `Atom.Index`.
+/// For a given `InternPool.DeclIndex` returns its corresponding `Atom.Index`.
/// When the index was not found, a new `Atom` will be created, and its index will be returned.
/// The newly created Atom is empty with default fields as specified by `Atom.empty`.
-pub fn getOrCreateAtomForDecl(wasm: *Wasm, decl_index: Module.Decl.Index) !Atom.Index {
+pub fn getOrCreateAtomForDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex) !Atom.Index {
const gop = try wasm.decls.getOrPut(wasm.base.allocator, decl_index);
if (!gop.found_existing) {
const atom_index = try wasm.createAtom();
@@ -1427,7 +1427,7 @@ pub fn updateFunc(wasm: *Wasm, mod: *Module, func_index: InternPool.Index, air:
// Generate code for the Decl, storing it in memory to be later written to
// the file on flush().
-pub fn updateDecl(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDecl(wasm: *Wasm, mod: *Module, decl_index: InternPool.DeclIndex) !void {
if (build_options.skip_non_native and builtin.object_format != .wasm) {
@panic("Attempted to compile for object format that was disabled by build configuration");
}
@@ -1479,7 +1479,7 @@ pub fn updateDecl(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.Index) !voi
return wasm.finishUpdateDecl(decl_index, code, .data);
}
-pub fn updateDeclLineNumber(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDeclLineNumber(wasm: *Wasm, mod: *Module, decl_index: InternPool.DeclIndex) !void {
if (wasm.llvm_object) |_| return;
if (wasm.dwarf) |*dw| {
const tracy = trace(@src());
@@ -1493,7 +1493,7 @@ pub fn updateDeclLineNumber(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.I
}
}
-fn finishUpdateDecl(wasm: *Wasm, decl_index: Module.Decl.Index, code: []const u8, symbol_tag: Symbol.Tag) !void {
+fn finishUpdateDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex, code: []const u8, symbol_tag: Symbol.Tag) !void {
const mod = wasm.base.options.module.?;
const decl = mod.declPtr(decl_index);
const atom_index = wasm.decls.get(decl_index).?;
@@ -1556,7 +1556,7 @@ fn getFunctionSignature(wasm: *const Wasm, loc: SymbolLoc) std.wasm.Type {
/// Lowers a constant typed value to a local symbol and atom.
/// Returns the symbol index of the local
/// The given `decl` is the parent decl whom owns the constant.
-pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: Module.Decl.Index) !u32 {
+pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: InternPool.DeclIndex) !u32 {
const mod = wasm.base.options.module.?;
assert(tv.ty.zigTypeTag(mod) != .Fn); // cannot create local symbols for functions
const decl = mod.declPtr(decl_index);
@@ -1672,7 +1672,7 @@ pub fn getGlobalSymbol(wasm: *Wasm, name: []const u8, lib_name: ?[]const u8) !u3
/// Returns the given pointer address
pub fn getDeclVAddr(
wasm: *Wasm,
- decl_index: Module.Decl.Index,
+ decl_index: InternPool.DeclIndex,
reloc_info: link.File.RelocInfo,
) !u64 {
const mod = wasm.base.options.module.?;
@@ -1780,7 +1780,7 @@ pub fn getAnonDeclVAddr(wasm: *Wasm, decl_val: InternPool.Index, reloc_info: lin
return target_symbol_index;
}
-pub fn deleteDeclExport(wasm: *Wasm, decl_index: Module.Decl.Index) void {
+pub fn deleteDeclExport(wasm: *Wasm, decl_index: InternPool.DeclIndex) void {
if (wasm.llvm_object) |_| return;
const atom_index = wasm.decls.get(decl_index) orelse return;
const sym_index = wasm.getAtom(atom_index).sym_index;
@@ -1923,7 +1923,7 @@ pub fn updateExports(
}
}
-pub fn freeDecl(wasm: *Wasm, decl_index: Module.Decl.Index) void {
+pub fn freeDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex) void {
if (wasm.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);
const mod = wasm.base.options.module.?;
const decl = mod.declPtr(decl_index);
@@ -5012,7 +5012,7 @@ pub fn putOrGetFuncType(wasm: *Wasm, func_type: std.wasm.Type) !u32 {
/// For the given `decl_index`, stores the corresponding type representing the function signature.
/// Asserts declaration has an associated `Atom`.
/// Returns the index into the list of types.
-pub fn storeDeclType(wasm: *Wasm, decl_index: Module.Decl.Index, func_type: std.wasm.Type) !u32 {
+pub fn storeDeclType(wasm: *Wasm, decl_index: InternPool.DeclIndex, func_type: std.wasm.Type) !u32 {
const atom_index = wasm.decls.get(decl_index).?;
const index = try wasm.putOrGetFuncType(func_type);
try wasm.atom_types.put(wasm.base.allocator, atom_index, index);