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.
This commit is contained in:
Robin Voetter
2023-11-23 23:58:50 +01:00
parent cb026c5d59
commit b4b1c4df64
4 changed files with 34 additions and 2 deletions

View File

@@ -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,