aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2023-04-08 15:03:05 +0200
committerRobin Voetter <robin@voetter.nl>2023-04-09 01:51:54 +0200
commit1de2d2ee1c70dfd01dc8b161af53ce188e84b1d0 (patch)
tree60579b813e20e274991502b9672a51b55b5ecb0b /src/codegen/spirv
parente389f524c9a09719ea2f6b684c0bf6f3fe4c3c9b (diff)
downloadzig-1de2d2ee1c70dfd01dc8b161af53ce188e84b1d0.tar.gz
zig-1de2d2ee1c70dfd01dc8b161af53ce188e84b1d0.zip
spirv: deny OpEntryPoint in asm
Kernels should be exported by marking the kernel using callconv(.Kernel) and exporting it as a regular function.
Diffstat (limited to 'src/codegen/spirv')
-rw-r--r--src/codegen/spirv/Assembler.zig20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/codegen/spirv/Assembler.zig b/src/codegen/spirv/Assembler.zig
index a8ff5175d8..ffb5503afc 100644
--- 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,