aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-02-01 12:49:51 -0800
committerGitHub <noreply@github.com>2021-02-01 12:49:51 -0800
commit102d9542203e52839156cb61efdfca8403a379a9 (patch)
tree72daf0d9a1ac3680f2f1fbc6447a120dde9b52ee /src/link.zig
parent06b29c854656a1f9320ee16024b1c3a6b78180a5 (diff)
parent1055344673a87af39f2288bae069ec9403e6086d (diff)
downloadzig-102d9542203e52839156cb61efdfca8403a379a9.tar.gz
zig-102d9542203e52839156cb61efdfca8403a379a9.zip
Merge pull request #7827 from Snektron/spirv-setup
Stage 2: SPIR-V setup
Diffstat (limited to 'src/link.zig')
-rw-r--r--src/link.zig29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/link.zig b/src/link.zig
index 82ff0bb3f8..3d0a54f416 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -139,6 +139,7 @@ pub const File = struct {
macho: MachO.TextBlock,
c: C.DeclBlock,
wasm: void,
+ spirv: void,
};
pub const LinkFn = union {
@@ -147,6 +148,7 @@ pub const File = struct {
macho: MachO.SrcFn,
c: C.FnBlock,
wasm: ?Wasm.FnData,
+ spirv: SpirV.FnData,
};
pub const Export = union {
@@ -155,6 +157,7 @@ pub const File = struct {
macho: MachO.Export,
c: void,
wasm: void,
+ spirv: void,
};
/// For DWARF .debug_info.
@@ -183,6 +186,7 @@ pub const File = struct {
.macho => &(try MachO.createEmpty(allocator, options)).base,
.wasm => &(try Wasm.createEmpty(allocator, options)).base,
.c => unreachable, // Reported error earlier.
+ .spirv => &(try SpirV.createEmpty(allocator, options)).base,
.hex => return error.HexObjectFormatUnimplemented,
.raw => return error.RawObjectFormatUnimplemented,
};
@@ -198,6 +202,7 @@ pub const File = struct {
.macho => &(try MachO.createEmpty(allocator, options)).base,
.wasm => &(try Wasm.createEmpty(allocator, options)).base,
.c => unreachable, // Reported error earlier.
+ .spirv => &(try SpirV.createEmpty(allocator, options)).base,
.hex => return error.HexObjectFormatUnimplemented,
.raw => return error.RawObjectFormatUnimplemented,
};
@@ -213,6 +218,7 @@ pub const File = struct {
.macho => &(try MachO.openPath(allocator, sub_path, options)).base,
.wasm => &(try Wasm.openPath(allocator, sub_path, options)).base,
.c => &(try C.openPath(allocator, sub_path, options)).base,
+ .spirv => &(try SpirV.openPath(allocator, sub_path, options)).base,
.hex => return error.HexObjectFormatUnimplemented,
.raw => return error.RawObjectFormatUnimplemented,
};
@@ -242,7 +248,7 @@ pub const File = struct {
.mode = determineMode(base.options),
});
},
- .c, .wasm => {},
+ .c, .wasm, .spirv => {},
}
}
@@ -287,7 +293,7 @@ pub const File = struct {
f.close();
base.file = null;
},
- .c, .wasm => {},
+ .c, .wasm, .spirv => {},
}
}
@@ -300,6 +306,7 @@ pub const File = struct {
.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),
+ .spirv => return @fieldParentPtr(SpirV, "base", base).updateDecl(module, decl),
}
}
@@ -309,7 +316,7 @@ pub const File = struct {
.elf => return @fieldParentPtr(Elf, "base", base).updateDeclLineNumber(module, decl),
.macho => return @fieldParentPtr(MachO, "base", base).updateDeclLineNumber(module, decl),
.c => return @fieldParentPtr(C, "base", base).updateDeclLineNumber(module, decl),
- .wasm => {},
+ .wasm, .spirv => {},
}
}
@@ -321,7 +328,7 @@ pub const File = struct {
.elf => return @fieldParentPtr(Elf, "base", base).allocateDeclIndexes(decl),
.macho => return @fieldParentPtr(MachO, "base", base).allocateDeclIndexes(decl),
.c => return @fieldParentPtr(C, "base", base).allocateDeclIndexes(decl),
- .wasm => {},
+ .wasm, .spirv => {},
}
}
@@ -368,6 +375,11 @@ pub const File = struct {
parent.deinit();
base.allocator.destroy(parent);
},
+ .spirv => {
+ const parent = @fieldParentPtr(SpirV, "base", base);
+ parent.deinit();
+ base.allocator.destroy(parent);
+ },
}
}
@@ -401,6 +413,7 @@ pub const File = struct {
.macho => return @fieldParentPtr(MachO, "base", base).flush(comp),
.c => return @fieldParentPtr(C, "base", base).flush(comp),
.wasm => return @fieldParentPtr(Wasm, "base", base).flush(comp),
+ .spirv => return @fieldParentPtr(SpirV, "base", base).flush(comp),
}
}
@@ -413,6 +426,7 @@ pub const File = struct {
.macho => return @fieldParentPtr(MachO, "base", base).flushModule(comp),
.c => return @fieldParentPtr(C, "base", base).flushModule(comp),
.wasm => return @fieldParentPtr(Wasm, "base", base).flushModule(comp),
+ .spirv => return @fieldParentPtr(SpirV, "base", base).flushModule(comp),
}
}
@@ -424,6 +438,7 @@ pub const File = struct {
.macho => @fieldParentPtr(MachO, "base", base).freeDecl(decl),
.c => @fieldParentPtr(C, "base", base).freeDecl(decl),
.wasm => @fieldParentPtr(Wasm, "base", base).freeDecl(decl),
+ .spirv => @fieldParentPtr(SpirV, "base", base).freeDecl(decl),
}
}
@@ -433,7 +448,7 @@ pub const File = struct {
.elf => return @fieldParentPtr(Elf, "base", base).error_flags,
.macho => return @fieldParentPtr(MachO, "base", base).error_flags,
.c => return .{ .no_entry_point_found = false },
- .wasm => return ErrorFlags{},
+ .wasm, .spirv => return ErrorFlags{},
}
}
@@ -451,6 +466,7 @@ pub const File = struct {
.macho => return @fieldParentPtr(MachO, "base", base).updateDeclExports(module, decl, exports),
.c => return @fieldParentPtr(C, "base", base).updateDeclExports(module, decl, exports),
.wasm => return @fieldParentPtr(Wasm, "base", base).updateDeclExports(module, decl, exports),
+ .spirv => return @fieldParentPtr(SpirV, "base", base).updateDeclExports(module, decl, exports),
}
}
@@ -461,6 +477,7 @@ pub const File = struct {
.macho => return @fieldParentPtr(MachO, "base", base).getDeclVAddr(decl),
.c => unreachable,
.wasm => unreachable,
+ .spirv => unreachable,
}
}
@@ -601,6 +618,7 @@ pub const File = struct {
macho,
c,
wasm,
+ spirv,
};
pub const ErrorFlags = struct {
@@ -611,6 +629,7 @@ pub const File = struct {
pub const Coff = @import("link/Coff.zig");
pub const Elf = @import("link/Elf.zig");
pub const MachO = @import("link/MachO.zig");
+ pub const SpirV = @import("link/SpirV.zig");
pub const Wasm = @import("link/Wasm.zig");
};