diff options
| author | Robin Voetter <robin@voetter.nl> | 2023-04-08 14:55:39 +0200 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2023-04-09 01:51:54 +0200 |
| commit | e389f524c9a09719ea2f6b684c0bf6f3fe4c3c9b (patch) | |
| tree | 8cde9fe9ea079375e1beb32542cd29a7124eabd6 /src/link | |
| parent | f12beb857ad7868396a4246b8f62f83f625c0978 (diff) | |
| download | zig-e389f524c9a09719ea2f6b684c0bf6f3fe4c3c9b.tar.gz zig-e389f524c9a09719ea2f6b684c0bf6f3fe4c3c9b.zip | |
spirv: export functions with .Kernel callconv as entry point
Exported functions which have the .Kernel calling convention are now exported
as entry point. This also works with @export.
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/SpirV.zig | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/link/SpirV.zig b/src/link/SpirV.zig index 7ec4c2cac6..3eed369933 100644 --- a/src/link/SpirV.zig +++ b/src/link/SpirV.zig @@ -135,10 +135,21 @@ pub fn updateDeclExports( decl_index: Module.Decl.Index, exports: []const *Module.Export, ) !void { - _ = self; - _ = module; - _ = decl_index; - _ = exports; + const decl = module.declPtr(decl_index); + if (decl.val.tag() == .function and decl.ty.fnCallingConvention() == .Kernel) { + // TODO: Unify with resolveDecl in spirv.zig. + const entry = try self.decl_link.getOrPut(decl_index); + if (!entry.found_existing) { + entry.value_ptr.* = try self.spv.allocDecl(.func); + } + const spv_decl_index = entry.value_ptr.*; + + for (exports) |exp| { + try self.spv.declareEntryPoint(spv_decl_index, exp.options.name); + } + } + + // TODO: Export regular functions, variables, etc using Linkage attributes. } pub fn freeDecl(self: *SpirV, decl_index: Module.Decl.Index) void { |
