aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2023-11-23 23:58:50 +0100
committerRobin Voetter <robin@voetter.nl>2023-11-24 11:40:18 +0100
commitb4b1c4df640c9b40c303eef7d0364d01ec490a8e (patch)
treebf5d534fb5b3c7cdb3b78f2846e4272939258e45 /src/codegen
parentcb026c5d599dddc38f34ee93438d52bbffe2f6ad (diff)
downloadzig-b4b1c4df640c9b40c303eef7d0364d01ec490a8e.tar.gz
zig-b4b1c4df640c9b40c303eef7d0364d01ec490a8e.zip
spirv: add -fstructured-cfg option
This enables the compiler to generate a structured cfg even in opencl, even if it is not strictly required by the SPIR-V Kernel specification.
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/spirv.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig
index 8bee639b60..7901e37135 100644
--- a/src/codegen/spirv.zig
+++ b/src/codegen/spirv.zig
@@ -99,6 +99,15 @@ pub const Object = struct {
air: Air,
liveness: Liveness,
) !void {
+ const target = mod.getTarget();
+ // We always want a structured control flow in shaders. This option is only relevant
+ // for OpenCL kernels.
+ const want_structured_cfg = switch (target.os.tag) {
+ .opencl => mod.comp.bin_file.options.want_structured_cfg orelse false,
+ else => true,
+ };
+ _ = want_structured_cfg;
+
var decl_gen = DeclGen{
.gpa = self.gpa,
.object = self,