[clang] [llvm] [DirectX] Set DXIL Version using shader model version in compilation target profile (PR #89823)

Chris B via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 14:04:25 PDT 2024


================
@@ -98,9 +100,47 @@ std::optional<std::string> tryParseProfile(StringRef Profile) {
   else if (llvm::getAsUnsignedInteger(Parts[2], 0, Minor))
     return std::nullopt;
 
-  // dxil-unknown-shadermodel-hull
+  // Determine DXIL version number using the minor version number of Shader
+  // Model version specified in target profile. Prior to decoupling DXIL version
+  // numbering from that of Shader Model DXIL version 1.Y corresponds to SM 6.Y.
+  // E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
   llvm::Triple T;
-  T.setArch(Triple::ArchType::dxil);
+  Triple::SubArchType SubArch = llvm::Triple::NoSubArch;
+  switch (Minor) {
+  case 0:
+    SubArch = llvm::Triple::DXILSubArch_v1_0;
+    break;
+  case 1:
+    SubArch = llvm::Triple::DXILSubArch_v1_1;
+    break;
+  case 2:
+    SubArch = llvm::Triple::DXILSubArch_v1_2;
+    break;
+  case 3:
+    SubArch = llvm::Triple::DXILSubArch_v1_3;
+    break;
+  case 4:
+    SubArch = llvm::Triple::DXILSubArch_v1_4;
+    break;
+  case 5:
+    SubArch = llvm::Triple::DXILSubArch_v1_5;
+    break;
+  case 6:
+    SubArch = llvm::Triple::DXILSubArch_v1_6;
+    break;
+  case 7:
+    SubArch = llvm::Triple::DXILSubArch_v1_7;
+    break;
+  case 8:
+    SubArch = llvm::Triple::DXILSubArch_v1_8;
+    break;
+  }
+  if (SubArch == llvm::Triple::NoSubArch) {
+    report_fatal_error(
----------------
llvm-beanz wrote:

The frontend should not call `report_fatal_error`. If this error is possible we should emit a driver diagnostic (see the `D.Diag` calls elsewhere in this file).

If this can't happen, we should instead assert.

If this error can occur we need a test that verifies the error condition.

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


More information about the llvm-commits mailing list