zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 1de2d2ee1c70dfd01dc8b161af53ce188e84b1d0 (tree)
parent e389f524c9a09719ea2f6b684c0bf6f3fe4c3c9b
Author: Robin Voetter <robin@voetter.nl>
Date:   Sat,  8 Apr 2023 15:03:05 +0200

spirv: deny OpEntryPoint in asm

Kernels should be exported by marking the kernel using callconv(.Kernel) and
exporting it as a regular function.

Diffstat:
Msrc/codegen/spirv/Assembler.zig | 20++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/codegen/spirv/Assembler.zig b/src/codegen/spirv/Assembler.zig @@ -239,12 +239,17 @@ fn todo(self: *Assembler, comptime fmt: []const u8, args: anytype) Error { /// If this function returns `error.AssembleFail`, an explanatory /// error message has already been emitted into `self.errors`. fn processInstruction(self: *Assembler) !void { - const result = switch (self.inst.opcode.class()) { - .TypeDeclaration => try self.processTypeInstruction(), - else => if (try self.processGenericInstruction()) |result| - result - else - return, + const result = switch (self.inst.opcode) { + .OpEntryPoint => { + return self.fail(0, "cannot export entry points via OpEntryPoint, export the kernel using callconv(.Kernel)", .{}); + }, + else => switch (self.inst.opcode.class()) { + .TypeDeclaration => try self.processTypeInstruction(), + else => if (try self.processGenericInstruction()) |result| + result + else + return, + }, }; const result_ref = self.inst.result().?; @@ -435,8 +440,7 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue { .Annotation => &self.spv.sections.annotations, .TypeDeclaration => unreachable, // Handled elsewhere. else => switch (self.inst.opcode) { - // TODO: This should emit a proper entry point. - .OpEntryPoint => unreachable, // &self.spv.sections.entry_points, + .OpEntryPoint => unreachable, .OpExecutionMode, .OpExecutionModeId => &self.spv.sections.execution_modes, .OpVariable => switch (@intToEnum(spec.StorageClass, operands[2].value)) { .Function => &self.func.prologue,