================
@@ -1200,6 +1224,27 @@ std::string Triple::normalize(StringRef Str) {
     }
   }
 
+  // Normalize DXIL triple if it does not include DXIL version number.
+  // Determine DXIL version number using the minor version number of Shader
+  // Model version specified in target triple, if any. 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
+  if (Components[0] == "dxil") {
+    std::string DXILVerStr{"dxilv1."};
+    if (Components.size() > 2) {
+      // OS component specified
+      if (Components[2].starts_with("shadermodel6.")) {
+        Components[0] = DXILVerStr.append(
+            Components[2].drop_front(strlen("shadermodel6.")));
+      } else if (Components[2].starts_with("shadermodel")) {
+        // If shader model specified is other than 6.x, set DXIL Version to 1.0
+        Components[0] = DXILVerStr.append("0");
+      }
+    }
----------------
bharadwajy wrote:

The function `normalize` does not parse for `SubArch`. So, `SubArch` is not 
available  for checking.

An input DXIL triple string `Str` with or without version (e.g., 
`dxil-pc-shadermodel6.3` or `dxilv1.3-pc-shadermodel6.3` will set `Arch` to 
`Triple::dxil`. Implicit deduction and insertion of DXIL version should be done 
only is `Component[0] == "dxil"` and not otherwise. Hence the string 
equivalence check for "dxil" and not for `Arch == Triple::dxil`.

However, made code changes to leverage Arch and OS values already parsed as 
suggested. A couple of additional sanity checks are also added.


https://github.com/llvm/llvm-project/pull/90809
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to