aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-07-22 09:34:44 +0200
committerJakub Konka <kubkon@jakubkonka.com>2021-07-22 09:34:44 +0200
commitdef135918740846d9b206c3188563cb77333f3a9 (patch)
tree2d054e8bca8b70ab2d38e384ff4eaac665b86422 /src/link.zig
parentd0edd37f690c3e6cf3f8a7fc7a27016ba9b010ce (diff)
parent8d0671157cdf8bc8b89d047138b42227420a5388 (diff)
downloadzig-def135918740846d9b206c3188563cb77333f3a9.tar.gz
zig-def135918740846d9b206c3188563cb77333f3a9.zip
Merge remote-tracking branch 'origin/master' into zld-incremental-2
Diffstat (limited to 'src/link.zig')
-rw-r--r--src/link.zig34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/link.zig b/src/link.zig
index 894ec66fff..e9f2c932de 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -1,4 +1,5 @@
const std = @import("std");
+const builtin = @import("builtin");
const mem = std.mem;
const Allocator = std.mem.Allocator;
const fs = std.fs;
@@ -14,8 +15,10 @@ const Cache = @import("Cache.zig");
const build_options = @import("build_options");
const LibCInstallation = @import("libc_installation.zig").LibCInstallation;
const wasi_libc = @import("wasi_libc.zig");
+const Air = @import("Air.zig");
+const Liveness = @import("Liveness.zig");
-pub const producer_string = if (std.builtin.is_test) "zig test" else "zig " ++ build_options.version;
+pub const producer_string = if (builtin.is_test) "zig test" else "zig " ++ build_options.version;
pub const Emit = struct {
/// Where the output will go.
@@ -313,13 +316,34 @@ pub const File = struct {
log.debug("updateDecl {*} ({s}), type={}", .{ decl, decl.name, decl.ty });
assert(decl.has_tv);
switch (base.tag) {
- .coff => return @fieldParentPtr(Coff, "base", base).updateDecl(module, decl),
- .elf => return @fieldParentPtr(Elf, "base", base).updateDecl(module, decl),
+ // zig fmt: off
+ .coff => return @fieldParentPtr(Coff, "base", base).updateDecl(module, decl),
+ .elf => return @fieldParentPtr(Elf, "base", base).updateDecl(module, decl),
.macho => return @fieldParentPtr(MachO, "base", base).updateDecl(module, decl),
- .c => return @fieldParentPtr(C, "base", base).updateDecl(module, decl),
- .wasm => return @fieldParentPtr(Wasm, "base", base).updateDecl(module, decl),
+ .c => return @fieldParentPtr(C, "base", base).updateDecl(module, decl),
+ .wasm => return @fieldParentPtr(Wasm, "base", base).updateDecl(module, decl),
.spirv => return @fieldParentPtr(SpirV, "base", base).updateDecl(module, decl),
.plan9 => return @fieldParentPtr(Plan9, "base", base).updateDecl(module, decl),
+ // zig fmt: on
+ }
+ }
+
+ /// May be called before or after updateDeclExports but must be called
+ /// after allocateDeclIndexes for any given Decl.
+ pub fn updateFunc(base: *File, module: *Module, func: *Module.Fn, air: Air, liveness: Liveness) !void {
+ log.debug("updateFunc {*} ({s}), type={}", .{
+ func.owner_decl, func.owner_decl.name, func.owner_decl.ty,
+ });
+ switch (base.tag) {
+ // zig fmt: off
+ .coff => return @fieldParentPtr(Coff, "base", base).updateFunc(module, func, air, liveness),
+ .elf => return @fieldParentPtr(Elf, "base", base).updateFunc(module, func, air, liveness),
+ .macho => return @fieldParentPtr(MachO, "base", base).updateFunc(module, func, air, liveness),
+ .c => return @fieldParentPtr(C, "base", base).updateFunc(module, func, air, liveness),
+ .wasm => return @fieldParentPtr(Wasm, "base", base).updateFunc(module, func, air, liveness),
+ .spirv => return @fieldParentPtr(SpirV, "base", base).updateFunc(module, func, air, liveness),
+ .plan9 => return @fieldParentPtr(Plan9, "base", base).updateFunc(module, func, air, liveness),
+ // zig fmt: on
}
}