-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HLSL][SPIRV] Add option to add all KHR extensions #145536
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
Conversation
In DXC, there is an option to enable all KHR extension. This is added by passing the KHR option to the SPIR-V backend, which will enable all of the appropriate extensions. Part of llvm#137650.
@llvm/pr-subscribers-clang-driver Author: Steven Perron (s-perron) ChangesIn DXC, there is an option to enable all KHR extension. This is added by Part of #137650. Full diff: https://github.com/llvm/llvm-project/pull/145536.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp
index dcc51e182924c..14bbd61c5178a 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -182,13 +182,15 @@ std::string getSpirvExtArg(ArrayRef<std::string> SpvExtensionArgs) {
(Twine("-spirv-ext=+") + SpvExtensionArgs.front()).str();
SpvExtensionArgs = SpvExtensionArgs.slice(1);
for (auto Extension : SpvExtensionArgs) {
- LlvmOption = (Twine(LlvmOption) + ",+" + Extension).str();
+ if (Extension != "KHR")
+ Extension = (Twine("+") + Extension).str();
+ LlvmOption = (Twine(LlvmOption) + "," + Extension).str();
}
return LlvmOption;
}
bool isValidSPIRVExtensionName(const std::string &str) {
- std::regex pattern("SPV_[a-zA-Z0-9_]+");
+ std::regex pattern("KHR|SPV_[a-zA-Z0-9_]+");
return std::regex_match(str, pattern);
}
diff --git a/clang/test/Driver/dxc_fspv_extension.hlsl b/clang/test/Driver/dxc_fspv_extension.hlsl
index 0a9d321b8d95e..7cb7990568d3e 100644
--- a/clang/test/Driver/dxc_fspv_extension.hlsl
+++ b/clang/test/Driver/dxc_fspv_extension.hlsl
@@ -10,8 +10,13 @@
// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=SPV_TEST1 -fspv-extension=SPV_TEST2 2>&1 | FileCheck %s -check-prefix=TEST2
// TEST2: "-spirv-ext=+SPV_TEST1,+SPV_TEST2"
+// Merge KHR with other extensions.
+// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=SPV_TEST1 -fspv-extension=KHR -fspv-extension=SPV_TEST2 2>&1 | FileCheck %s -check-prefix=TEST3
+// TEST3: "-spirv-ext=+SPV_TEST1,KHR,+SPV_TEST2"
+
// Check for the error message if the extension name is not properly formed.
-// RUN: not %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=TEST1 -fspv-extension=SPV_GOOD -fspv-extension=TEST2 2>&1 | FileCheck %s -check-prefix=FAIL
+// RUN: not %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=KHR_BAD -fspv-extension=TEST1 -fspv-extension=SPV_GOOD -fspv-extension=TEST2 2>&1 | FileCheck %s -check-prefix=FAIL
+// FAIL: invalid value 'KHR_BAD' in '-fspv_extension'
// FAIL: invalid value 'TEST1' in '-fspv_extension'
// FAIL: invalid value 'TEST2' in '-fspv_extension'
|
@llvm/pr-subscribers-hlsl Author: Steven Perron (s-perron) ChangesIn DXC, there is an option to enable all KHR extension. This is added by Part of #137650. Full diff: https://github.com/llvm/llvm-project/pull/145536.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp
index dcc51e182924c..14bbd61c5178a 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -182,13 +182,15 @@ std::string getSpirvExtArg(ArrayRef<std::string> SpvExtensionArgs) {
(Twine("-spirv-ext=+") + SpvExtensionArgs.front()).str();
SpvExtensionArgs = SpvExtensionArgs.slice(1);
for (auto Extension : SpvExtensionArgs) {
- LlvmOption = (Twine(LlvmOption) + ",+" + Extension).str();
+ if (Extension != "KHR")
+ Extension = (Twine("+") + Extension).str();
+ LlvmOption = (Twine(LlvmOption) + "," + Extension).str();
}
return LlvmOption;
}
bool isValidSPIRVExtensionName(const std::string &str) {
- std::regex pattern("SPV_[a-zA-Z0-9_]+");
+ std::regex pattern("KHR|SPV_[a-zA-Z0-9_]+");
return std::regex_match(str, pattern);
}
diff --git a/clang/test/Driver/dxc_fspv_extension.hlsl b/clang/test/Driver/dxc_fspv_extension.hlsl
index 0a9d321b8d95e..7cb7990568d3e 100644
--- a/clang/test/Driver/dxc_fspv_extension.hlsl
+++ b/clang/test/Driver/dxc_fspv_extension.hlsl
@@ -10,8 +10,13 @@
// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=SPV_TEST1 -fspv-extension=SPV_TEST2 2>&1 | FileCheck %s -check-prefix=TEST2
// TEST2: "-spirv-ext=+SPV_TEST1,+SPV_TEST2"
+// Merge KHR with other extensions.
+// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=SPV_TEST1 -fspv-extension=KHR -fspv-extension=SPV_TEST2 2>&1 | FileCheck %s -check-prefix=TEST3
+// TEST3: "-spirv-ext=+SPV_TEST1,KHR,+SPV_TEST2"
+
// Check for the error message if the extension name is not properly formed.
-// RUN: not %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=TEST1 -fspv-extension=SPV_GOOD -fspv-extension=TEST2 2>&1 | FileCheck %s -check-prefix=FAIL
+// RUN: not %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=KHR_BAD -fspv-extension=TEST1 -fspv-extension=SPV_GOOD -fspv-extension=TEST2 2>&1 | FileCheck %s -check-prefix=FAIL
+// FAIL: invalid value 'KHR_BAD' in '-fspv_extension'
// FAIL: invalid value 'TEST1' in '-fspv_extension'
// FAIL: invalid value 'TEST2' in '-fspv_extension'
|
@llvm/pr-subscribers-clang Author: Steven Perron (s-perron) ChangesIn DXC, there is an option to enable all KHR extension. This is added by Part of #137650. Full diff: https://github.com/llvm/llvm-project/pull/145536.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp
index dcc51e182924c..14bbd61c5178a 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -182,13 +182,15 @@ std::string getSpirvExtArg(ArrayRef<std::string> SpvExtensionArgs) {
(Twine("-spirv-ext=+") + SpvExtensionArgs.front()).str();
SpvExtensionArgs = SpvExtensionArgs.slice(1);
for (auto Extension : SpvExtensionArgs) {
- LlvmOption = (Twine(LlvmOption) + ",+" + Extension).str();
+ if (Extension != "KHR")
+ Extension = (Twine("+") + Extension).str();
+ LlvmOption = (Twine(LlvmOption) + "," + Extension).str();
}
return LlvmOption;
}
bool isValidSPIRVExtensionName(const std::string &str) {
- std::regex pattern("SPV_[a-zA-Z0-9_]+");
+ std::regex pattern("KHR|SPV_[a-zA-Z0-9_]+");
return std::regex_match(str, pattern);
}
diff --git a/clang/test/Driver/dxc_fspv_extension.hlsl b/clang/test/Driver/dxc_fspv_extension.hlsl
index 0a9d321b8d95e..7cb7990568d3e 100644
--- a/clang/test/Driver/dxc_fspv_extension.hlsl
+++ b/clang/test/Driver/dxc_fspv_extension.hlsl
@@ -10,8 +10,13 @@
// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=SPV_TEST1 -fspv-extension=SPV_TEST2 2>&1 | FileCheck %s -check-prefix=TEST2
// TEST2: "-spirv-ext=+SPV_TEST1,+SPV_TEST2"
+// Merge KHR with other extensions.
+// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=SPV_TEST1 -fspv-extension=KHR -fspv-extension=SPV_TEST2 2>&1 | FileCheck %s -check-prefix=TEST3
+// TEST3: "-spirv-ext=+SPV_TEST1,KHR,+SPV_TEST2"
+
// Check for the error message if the extension name is not properly formed.
-// RUN: not %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=TEST1 -fspv-extension=SPV_GOOD -fspv-extension=TEST2 2>&1 | FileCheck %s -check-prefix=FAIL
+// RUN: not %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=KHR_BAD -fspv-extension=TEST1 -fspv-extension=SPV_GOOD -fspv-extension=TEST2 2>&1 | FileCheck %s -check-prefix=FAIL
+// FAIL: invalid value 'KHR_BAD' in '-fspv_extension'
// FAIL: invalid value 'TEST1' in '-fspv_extension'
// FAIL: invalid value 'TEST2' in '-fspv_extension'
|
In DXC, there is an option to enable all KHR extension. This is added by passing the KHR option to the SPIR-V backend, which will enable all of the appropriate extensions. Part of llvm#137650.
In DXC, there is an option to enable all KHR extension. This is added by
passing the KHR option to the SPIR-V backend, which will enable all of
the appropriate extensions.
Part of #137650.