aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
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/main.zig
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/main.zig')
-rw-r--r--src/main.zig9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig
index 641dd04164..11e40f09ca 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -493,6 +493,8 @@ const usage_build_generic =
\\ msvc Use msvc include paths (must be present on the system)
\\ gnu Use mingw include paths (distributed with Zig)
\\ none Do not use any autodetected include paths
+ \\ -fstructured-cfg (SPIR-V) force SPIR-V kernels to use structured control flow
+ \\ -fno-structured-cfg (SPIR-V) force SPIR-V kernels to not use structured control flow
\\
\\Link Options:
\\ -l[lib], --library [lib] Link against system library (only if actually used)
@@ -913,7 +915,7 @@ fn buildOutputType(
var pdb_out_path: ?[]const u8 = null;
var dwarf_format: ?std.dwarf.Format = null;
var error_limit: ?Module.ErrorInt = null;
-
+ var want_structured_cfg: ?bool = null;
// e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names.
// This array is populated by zig cc frontend and then has to be converted to zig-style
// CPU features.
@@ -1070,6 +1072,10 @@ fn buildOutputType(
if (mem.eql(u8, next_arg, "--")) break;
try extra_rcflags.append(next_arg);
}
+ } else if (mem.startsWith(u8, arg, "-fstructured-cfg")) {
+ want_structured_cfg = true;
+ } else if (mem.startsWith(u8, arg, "-fno-structured-cfg")) {
+ want_structured_cfg = false;
} else if (mem.eql(u8, arg, "--color")) {
const next_arg = args_iter.next() orelse {
fatal("expected [auto|on|off] after --color", .{});
@@ -3595,6 +3601,7 @@ fn buildOutputType(
.error_tracing = error_tracing,
.pdb_out_path = pdb_out_path,
.error_limit = error_limit,
+ .want_structured_cfg = want_structured_cfg,
}) catch |err| switch (err) {
error.LibCUnavailable => {
const target = target_info.target;