aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-02-01 19:32:54 +0100
committerJakub Konka <kubkon@jakubkonka.com>2023-02-01 19:32:54 +0100
commitbeb20d29db3fe945746581eba5d2f2cae1403cdb (patch)
treea5e7a1c3a098c93f5cf8fec062dfbf0f3a85c6af /src/Module.zig
parent46f54b23ae604c3f99f51ca719d9085530f6b59c (diff)
downloadzig-beb20d29db3fe945746581eba5d2f2cae1403cdb.tar.gz
zig-beb20d29db3fe945746581eba5d2f2cae1403cdb.zip
link: remove union types which are now internal to backends
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig56
1 files changed, 6 insertions, 50 deletions
diff --git a/src/Module.zig b/src/Module.zig
index f84d720d1f..b395c0a950 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -328,8 +328,6 @@ pub const ErrorInt = u32;
pub const Export = struct {
options: std.builtin.ExportOptions,
src: LazySrcLoc,
- /// Represents the position of the export, if any, in the output file.
- link: link.File.Export,
/// The Decl that performs the export. Note that this is *not* the Decl being exported.
owner_decl: Decl.Index,
/// The Decl containing the export statement. Inline function calls
@@ -533,16 +531,8 @@ pub const Decl = struct {
/// What kind of a declaration is this.
kind: Kind,
- /// Represents the position of the code in the output file.
- /// This is populated regardless of semantic analysis and code generation.
- link: link.File.LinkBlock,
-
- /// Represents the function in the linked output file, if the `Decl` is a function.
- /// This is stored here and not in `Fn` because `Decl` survives across updates but
- /// `Fn` does not.
- /// TODO Look into making `Fn` a longer lived structure and moving this field there
- /// to save on memory usage.
- fn_link: link.File.LinkFn,
+ /// TODO remove this once Wasm backend catches up
+ fn_link: ?link.File.Wasm.FnData = null,
/// The shallow set of other decls whose typed_value could possibly change if this Decl's
/// typed_value is modified.
@@ -5258,27 +5248,9 @@ pub fn clearDecl(
if (decl.ty.isFnOrHasRuntimeBits()) {
mod.comp.bin_file.freeDecl(decl_index);
- // TODO instead of a union, put this memory trailing Decl objects,
- // and allow it to be variably sized.
- decl.link = switch (mod.comp.bin_file.tag) {
- .coff => .{ .coff = {} },
- .elf => .{ .elf = {} },
- .macho => .{ .macho = {} },
- .plan9 => .{ .plan9 = {} },
- .c => .{ .c = {} },
- .wasm => .{ .wasm = {} },
- .spirv => .{ .spirv = {} },
- .nvptx => .{ .nvptx = {} },
- };
decl.fn_link = switch (mod.comp.bin_file.tag) {
- .coff => .{ .coff = {} },
- .elf => .{ .elf = {} },
- .macho => .{ .macho = {} },
- .plan9 => .{ .plan9 = {} },
- .c => .{ .c = {} },
- .wasm => .{ .wasm = link.File.Wasm.FnData.empty },
- .spirv => .{ .spirv = {} },
- .nvptx => .{ .nvptx = {} },
+ .wasm => link.File.Wasm.FnData.empty,
+ else => null,
};
}
if (decl.getInnerNamespace()) |namespace| {
@@ -5680,25 +5652,9 @@ pub fn allocateNewDecl(
.deletion_flag = false,
.zir_decl_index = 0,
.src_scope = src_scope,
- .link = switch (mod.comp.bin_file.tag) {
- .coff => .{ .coff = {} },
- .elf => .{ .elf = {} },
- .macho => .{ .macho = {} },
- .plan9 => .{ .plan9 = {} },
- .c => .{ .c = {} },
- .wasm => .{ .wasm = {} },
- .spirv => .{ .spirv = {} },
- .nvptx => .{ .nvptx = {} },
- },
.fn_link = switch (mod.comp.bin_file.tag) {
- .coff => .{ .coff = {} },
- .elf => .{ .elf = {} },
- .macho => .{ .macho = {} },
- .plan9 => .{ .plan9 = {} },
- .c => .{ .c = {} },
- .wasm => .{ .wasm = link.File.Wasm.FnData.empty },
- .spirv => .{ .spirv = {} },
- .nvptx => .{ .nvptx = {} },
+ .wasm => link.File.Wasm.FnData.empty,
+ else => null,
},
.generation = 0,
.is_pub = false,