[clang] [llvm] [HLSL] Explicitly set the SPIR-V version with spv-target-env (PR #121961)

Nathan Gauër via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 8 07:27:28 PST 2025


================
@@ -1468,9 +1468,14 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
 
         // Set specific Vulkan version if applicable.
         if (const Arg *A = Args.getLastArg(options::OPT_fspv_target_env_EQ)) {
-          const llvm::StringSet<> ValidValues = {"vulkan1.2", "vulkan1.3"};
-          if (ValidValues.contains(A->getValue())) {
-            T.setOSName(A->getValue());
+          const llvm::StringMap<llvm::Triple::SubArchType> ValidTargets = {
+              {"vulkan1.2", llvm::Triple::SPIRVSubArch_v15},
+              {"vulkan1.3", llvm::Triple::SPIRVSubArch_v16}};
+
+          auto TargetInfo = ValidTargets.find(A->getValue());
+          if (TargetInfo != ValidTargets.end()) {
----------------
Keenuts wrote:

Ah right, forgot only vk1.1 had multiple spirv versions.

https://github.com/llvm/llvm-project/pull/121961


More information about the cfe-commits mailing list