diff options
| author | Robin Voetter <robin@voetter.nl> | 2021-01-19 00:34:44 +0100 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2021-01-19 15:28:17 +0100 |
| commit | b2b87b590011d8df52874e3f9bd1f88d1b0189d1 (patch) | |
| tree | 3cccc8d6f0424ef50361a9eec66b1ef021e3330d /src/link.zig | |
| parent | ab607d455e47c35b980c3281ef5c3fb433a770a7 (diff) | |
| download | zig-b2b87b590011d8df52874e3f9bd1f88d1b0189d1.tar.gz zig-b2b87b590011d8df52874e3f9bd1f88d1b0189d1.zip | |
SPIR-V: Linking and codegen setup
Diffstat (limited to 'src/link.zig')
| -rw-r--r-- | src/link.zig | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/link.zig b/src/link.zig index fdbb7efd4b..a19a261f55 100644 --- a/src/link.zig +++ b/src/link.zig @@ -142,7 +142,7 @@ pub const File = struct { macho: MachO.SrcFn, c: C.FnBlock, wasm: ?Wasm.FnData, - spirv: void, + spirv: SpirV.FnData, }; pub const Export = union { @@ -180,7 +180,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 => return error.SpirVObjectFormatUnimplemented, + .spirv => &(try SpirV.createEmpty(allocator, options)).base, .hex => return error.HexObjectFormatUnimplemented, .raw => return error.RawObjectFormatUnimplemented, }; @@ -196,7 +196,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 => return error.SpirVObjectFormatUnimplemented, + .spirv => &(try SpirV.createEmpty(allocator, options)).base, .hex => return error.HexObjectFormatUnimplemented, .raw => return error.RawObjectFormatUnimplemented, }; @@ -212,7 +212,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 => return error.SpirVObjectFormatUnimplemented, + .spirv => &(try SpirV.openPath(allocator, sub_path, options)).base, .hex => return error.HexObjectFormatUnimplemented, .raw => return error.RawObjectFormatUnimplemented, }; @@ -242,7 +242,7 @@ pub const File = struct { .mode = determineMode(base.options), }); }, - .c, .wasm => {}, + .c, .wasm, .spirv => {}, } } @@ -287,7 +287,7 @@ pub const File = struct { f.close(); base.file = null; }, - .c, .wasm => {}, + .c, .wasm, .spirv => {}, } } @@ -300,6 +300,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 +310,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 +322,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 +369,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 +407,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 +420,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 +432,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 +442,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 +460,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 +471,7 @@ pub const File = struct { .macho => return @fieldParentPtr(MachO, "base", base).getDeclVAddr(decl), .c => unreachable, .wasm => unreachable, + .spirv => unreachable, } } |
