[clang] [llvm] [DirectX][DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #90809)
S. Bharadwaj Yadavalli via cfe-commits
cfe-commits at lists.llvm.org
Mon May 6 08:24:27 PDT 2024
================
@@ -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");
+ }
+ }
+ // DXIL version is not set for a non-specified OS string or one that does
+ // not starts with shadermodel.
+ }
+
----------------
bharadwajy wrote:
> We should add unit tests to test the normalization.
Additional unit tests added.
https://github.com/llvm/llvm-project/pull/90809
More information about the cfe-commits
mailing list