forked from OSchip/llvm-project
[SystemZ] Fix invalid assumption in getCPUNameFromS390Model
Code in getCPUNameFromS390Model currently assumes that the numerical value of the model number always increases with future hardware. While this has happened to be the case with the last few machines, it is not guaranteed -- that assumption was violated with (much) older machines, and it can be violated again with future machines. Fix by explicitly listing model numbers for all supported machine models.
This commit is contained in:
parent
669275f8a0
commit
e04c05e823
|
@ -299,17 +299,34 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
|
|||
|
||||
namespace {
|
||||
StringRef getCPUNameFromS390Model(unsigned int Id, bool HaveVectorSupport) {
|
||||
if (Id >= 8561 && HaveVectorSupport)
|
||||
return "z15";
|
||||
if (Id >= 3906 && HaveVectorSupport)
|
||||
return "z14";
|
||||
if (Id >= 2964 && HaveVectorSupport)
|
||||
return "z13";
|
||||
if (Id >= 2827)
|
||||
return "zEC12";
|
||||
if (Id >= 2817)
|
||||
return "z196";
|
||||
return "generic";
|
||||
switch (Id) {
|
||||
case 2064: // z900 not supported by LLVM
|
||||
case 2066:
|
||||
case 2084: // z990 not supported by LLVM
|
||||
case 2086:
|
||||
case 2094: // z9-109 not supported by LLVM
|
||||
case 2096:
|
||||
return "generic";
|
||||
case 2097:
|
||||
case 2098:
|
||||
return "z10";
|
||||
case 2817:
|
||||
case 2818:
|
||||
return "z196";
|
||||
case 2827:
|
||||
case 2828:
|
||||
return "zEC12";
|
||||
case 2964:
|
||||
case 2965:
|
||||
return HaveVectorSupport? "z13" : "zEC12";
|
||||
case 3906:
|
||||
case 3907:
|
||||
return HaveVectorSupport? "z14" : "zEC12";
|
||||
case 8561:
|
||||
case 8562:
|
||||
default:
|
||||
return HaveVectorSupport? "z15" : "zEC12";
|
||||
}
|
||||
}
|
||||
} // end anonymous namespace
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ CPU revision : 0
|
|||
|
||||
TEST(getLinuxHostCPUName, s390x) {
|
||||
SmallVector<std::string> ModelIDs(
|
||||
{"8561", "3906", "2964", "2827", "2817", "7"});
|
||||
{"8561", "3906", "2964", "2827", "2817", "2097", "2064"});
|
||||
SmallVector<std::string> VectorSupport({"", "vx"});
|
||||
SmallVector<StringRef> ExpectedCPUs;
|
||||
|
||||
|
@ -336,7 +336,11 @@ TEST(getLinuxHostCPUName, s390x) {
|
|||
ExpectedCPUs.push_back("z196");
|
||||
ExpectedCPUs.push_back("z196");
|
||||
|
||||
// Model Id: 7
|
||||
// Model Id: 2097
|
||||
ExpectedCPUs.push_back("z10");
|
||||
ExpectedCPUs.push_back("z10");
|
||||
|
||||
// Model Id: 2064
|
||||
ExpectedCPUs.push_back("generic");
|
||||
ExpectedCPUs.push_back("generic");
|
||||
|
||||
|
|
Loading…
Reference in New Issue