Skip to content

Commit 7f3cc09

Browse files
committed
[SPIRV] Add -spirv option to DXC driver
Add an option to target SPIR-V to the clang-dxc driver, which sets the target triple's architecture to logical SPIR-V.
1 parent f89b859 commit 7f3cc09

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8316,3 +8316,5 @@ def dxc_disable_validation : DXCFlag<"Vd">,
83168316
def : Option<["/", "-"], "Qembed_debug", KIND_FLAG>, Group<dxc_Group>,
83178317
Flags<[Ignored]>, Visibility<[DXCOption]>,
83188318
HelpText<"Embed PDB in shader container (ignored)">;
8319+
def spirv : DXCFlag<"spirv">,
8320+
HelpText<"Generate SPIR-V code">;

clang/lib/Driver/Driver.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,12 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
13031303
Diag(diag::err_drv_invalid_directx_shader_module) << TargetProfile;
13041304

13051305
A->claim();
1306+
1307+
if (Args.hasArg(options::OPT_spirv)) {
1308+
llvm::Triple T(TargetTriple);
1309+
T.setArch(llvm::Triple::spirv);
1310+
TargetTriple = T.str();
1311+
}
13061312
} else {
13071313
Diag(diag::err_drv_dxc_missing_target_profile);
13081314
}

clang/test/Driver/dxc_spirv.hlsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %clang_dxc -T cs_6_0 -spirv -### %s 2>&1 | FileCheck %s
2+
3+
// CHECK: "-triple" "spirv-unknown-shadermodel6.0-compute"
4+
// CHECK-SAME: "-x" "hlsl"

0 commit comments

Comments
 (0)