Skip to content

Commit 832cd2d

Browse files
authored
[SPIRV] Add option to add all KHR extensions (#145535)
In DXC, there is an option to enable all KHR extension. I would like to extend the existing `-spirv-ext` backend commandline option to have the same capability. It is like the special case for `all` execept it only adds the `SPV_KHR_*` extensions. Part of #137650.
1 parent a4d517d commit 832cd2d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
121121
continue;
122122
}
123123

124+
if (Token.size() == 3 && Token.upper() == "KHR") {
125+
for (const auto &[ExtensionName, ExtensionEnum] : SPIRVExtensionMap)
126+
if (StringRef(ExtensionName).starts_with("SPV_KHR_"))
127+
EnabledExtensions.insert(ExtensionEnum);
128+
continue;
129+
}
130+
124131
if (Token.empty() || (!Token.starts_with("+") && !Token.starts_with("-")))
125132
return O.error("Invalid extension list format: " + Token.str());
126133

llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-but-one.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=all,-SPV_INTEL_arbitrary_precision_integers %s -o - | FileCheck %s
2+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=KHR %s -o - | FileCheck %s
3+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=khr %s -o - | FileCheck %s
24

35
define i6 @foo() {
46
%call = tail call i32 @llvm.bitreverse.i32(i32 42)

0 commit comments

Comments
 (0)