-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SPIRV] Add option to add all KHR extensions #145535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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 llvm#137650.
@llvm/pr-subscribers-backend-spir-v Author: Steven Perron (s-perron) ChangesIn DXC, there is an option to enable all KHR extension. I would like to Part of #137650. Full diff: https://github.com/llvm/llvm-project/pull/145535.diff 2 Files Affected:
diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
index fbaca4e0e4d81..365e586ba6018 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
@@ -119,6 +119,13 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
continue;
}
+ if (Token == "KHR") {
+ for (const auto &[ExtensionName, ExtensionEnum] : SPIRVExtensionMap)
+ if (StringRef(ExtensionName).starts_with("SPV_KHR_"))
+ EnabledExtensions.insert(ExtensionEnum);
+ continue;
+ }
+
if (Token.empty() || (!Token.starts_with("+") && !Token.starts_with("-")))
return O.error("Invalid extension list format: " + Token.str());
diff --git a/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-but-one.ll b/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-but-one.ll
index 02d21a1abafa5..7b7bdb193a468 100644
--- a/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-but-one.ll
+++ b/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-but-one.ll
@@ -1,4 +1,5 @@
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=all,-SPV_INTEL_arbitrary_precision_integers %s -o - | FileCheck %s
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=KHR %s -o - | FileCheck %s
define i6 @foo() {
%call = tail call i32 @llvm.bitreverse.i32(i32 42)
|
@@ -119,6 +119,13 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName, | |||
continue; | |||
} | |||
|
|||
if (Token == "KHR") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the token normalized to upper? Shall we accept both KHR
and khr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DXC only accepts "KHR", so I implemented the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add it if you want.
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 thesame capability. It is like the special case for
all
execept it onlyadds the
SPV_KHR_*
extensions.Part of #137650.