@@ -1041,6 +1041,51 @@ Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
1041
1041
1042
1042
static VersionTuple parseVersionFromName (StringRef Name);
1043
1043
1044
+ static StringRef getDXILArchNameFromShaderModel (StringRef ShaderModelStr) {
1045
+ VersionTuple Ver =
1046
+ parseVersionFromName (ShaderModelStr.drop_front (strlen (" shadermodel" )));
1047
+ // Default DXIL minor version when Shader Model version is anything other
1048
+ // than 6.[0...8] or 6.x (which translates to latest current SM version)
1049
+ const unsigned SMMajor = 6 ;
1050
+ if (!Ver.empty ()) {
1051
+ if (Ver.getMajor () == SMMajor) {
1052
+ if (std::optional<unsigned > SMMinor = Ver.getMinor ()) {
1053
+ switch (*SMMinor) {
1054
+ case 0 :
1055
+ return Triple::getArchName (Triple::dxil, Triple::DXILSubArch_v1_0);
1056
+ case 1 :
1057
+ return Triple::getArchName (Triple::dxil, Triple::DXILSubArch_v1_1);
1058
+ case 2 :
1059
+ return Triple::getArchName (Triple::dxil, Triple::DXILSubArch_v1_2);
1060
+ case 3 :
1061
+ return Triple::getArchName (Triple::dxil, Triple::DXILSubArch_v1_3);
1062
+ case 4 :
1063
+ return Triple::getArchName (Triple::dxil, Triple::DXILSubArch_v1_4);
1064
+ case 5 :
1065
+ return Triple::getArchName (Triple::dxil, Triple::DXILSubArch_v1_5);
1066
+ case 6 :
1067
+ return Triple::getArchName (Triple::dxil, Triple::DXILSubArch_v1_6);
1068
+ case 7 :
1069
+ return Triple::getArchName (Triple::dxil, Triple::DXILSubArch_v1_7);
1070
+ case 8 :
1071
+ return Triple::getArchName (Triple::dxil, Triple::DXILSubArch_v1_8);
1072
+ default :
1073
+ report_fatal_error (" Unsupported Shader Model version" , false );
1074
+ }
1075
+ }
1076
+ }
1077
+ } else {
1078
+ // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1079
+ // shadermodel6.x is
1080
+ if (ShaderModelStr == " shadermodel6.x" ) {
1081
+ return Triple::getArchName (Triple::dxil, Triple::LatestDXILSubArch);
1082
+ }
1083
+ }
1084
+ // DXIL version corresponding to Shader Model version other than 6.Minor
1085
+ // is 1.0
1086
+ return Triple::getArchName (Triple::dxil, Triple::DXILSubArch_v1_0);
1087
+ }
1088
+
1044
1089
std::string Triple::normalize (StringRef Str) {
1045
1090
bool IsMinGW32 = false ;
1046
1091
bool IsCygwin = false ;
@@ -1244,34 +1289,7 @@ std::string Triple::normalize(StringRef Str) {
1244
1289
}
1245
1290
// Add DXIL version only if shadermodel is specified in the triple
1246
1291
if (OS == Triple::ShaderModel) {
1247
- VersionTuple Ver =
1248
- parseVersionFromName (Components[2 ].drop_front (strlen (" shadermodel" )));
1249
- // Default DXIL minor version when Shader Model version is anything other
1250
- // than 6.[0...8] or 6.x (which translates to latest current SM version)
1251
- // DXIL version corresponding to Shader Model version other than 6.x
1252
- // is 1.0
1253
- unsigned DXILMinor = 0 ;
1254
- const unsigned SMMajor = 6 ;
1255
- const unsigned LatestCurrentDXILMinor = 8 ;
1256
- if (!Ver.empty ()) {
1257
- if (Ver.getMajor () == SMMajor) {
1258
- if (std::optional<unsigned > SMMinor = Ver.getMinor ()) {
1259
- DXILMinor = *SMMinor;
1260
- // Ensure specified minor version is supported
1261
- if (DXILMinor > LatestCurrentDXILMinor) {
1262
- report_fatal_error (" Unsupported Shader Model version" , false );
1263
- }
1264
- }
1265
- }
1266
- } else {
1267
- // Special case: DXIL minor version is set to LatestCurrentDXILMinor for
1268
- // shadermodel6.x is
1269
- if (Components[2 ] == " shadermodel6.x" ) {
1270
- DXILMinor = LatestCurrentDXILMinor;
1271
- }
1272
- }
1273
- Components[0 ] =
1274
- Components[0 ].str ().append (" v1." ).append (std::to_string (DXILMinor));
1292
+ Components[0 ] = getDXILArchNameFromShaderModel (Components[2 ]);
1275
1293
}
1276
1294
}
1277
1295
// Stick the corrected components back together to form the normalized string.
0 commit comments