mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[AIX][llvm][support] Implement getHostCPUName
We implement getHostCPUName() for AIX via systemcfg interfaces since access to the processor version register is a privileged operation. We return a value based on the current processor implementation mode. This fixes the cpu detection used by clang for `-mcpu=native`. Reviewed By: hubert.reinterpretcast Differential Revision: https://reviews.llvm.org/D95966
This commit is contained in:
parent
4cf94ad9e7
commit
3f1767ecef
@ -43,6 +43,9 @@
|
|||||||
#include <mach/mach_host.h>
|
#include <mach/mach_host.h>
|
||||||
#include <mach/machine.h>
|
#include <mach/machine.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _AIX
|
||||||
|
#include <sys/systemcfg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEBUG_TYPE "host-detection"
|
#define DEBUG_TYPE "host-detection"
|
||||||
|
|
||||||
@ -1217,6 +1220,38 @@ StringRef sys::getHostCPUName() {
|
|||||||
|
|
||||||
return "generic";
|
return "generic";
|
||||||
}
|
}
|
||||||
|
#elif defined(_AIX)
|
||||||
|
StringRef sys::getHostCPUName() {
|
||||||
|
switch (_system_configuration.implementation) {
|
||||||
|
case POWER_4:
|
||||||
|
if (_system_configuration.version == PV_4_3)
|
||||||
|
return "970";
|
||||||
|
return "pwr4";
|
||||||
|
case POWER_5:
|
||||||
|
if (_system_configuration.version == PV_5)
|
||||||
|
return "pwr5";
|
||||||
|
return "pwr5x";
|
||||||
|
case POWER_6:
|
||||||
|
if (_system_configuration.version == PV_6_Compat)
|
||||||
|
return "pwr6";
|
||||||
|
return "pwr6x";
|
||||||
|
case POWER_7:
|
||||||
|
return "pwr7";
|
||||||
|
case POWER_8:
|
||||||
|
return "pwr8";
|
||||||
|
case POWER_9:
|
||||||
|
return "pwr9";
|
||||||
|
// TODO: simplify this once the macro is available in all OS levels.
|
||||||
|
#ifdef POWER_10
|
||||||
|
case POWER_10:
|
||||||
|
#else
|
||||||
|
case 0x40000:
|
||||||
|
#endif
|
||||||
|
return "pwr10";
|
||||||
|
default:
|
||||||
|
return "generic";
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
StringRef sys::getHostCPUName() { return "generic"; }
|
StringRef sys::getHostCPUName() { return "generic"; }
|
||||||
#endif
|
#endif
|
||||||
|
@ -431,4 +431,33 @@ TEST_F(HostTest, AIXVersionDetect) {
|
|||||||
ASSERT_EQ(std::tie(SystemMajor, SystemMinor),
|
ASSERT_EQ(std::tie(SystemMajor, SystemMinor),
|
||||||
std::tie(TargetMajor, TargetMinor));
|
std::tie(TargetMajor, TargetMinor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(HostTest, AIXHostCPUDetect) {
|
||||||
|
// Return a value based on the current processor implementation mode.
|
||||||
|
const char *ExePath = "/usr/sbin/getsystype";
|
||||||
|
StringRef argv[] = {ExePath, "-i"};
|
||||||
|
std::unique_ptr<char[]> Buffer;
|
||||||
|
off_t Size;
|
||||||
|
ASSERT_EQ(runAndGetCommandOutput(ExePath, argv, Buffer, Size), true);
|
||||||
|
StringRef CPU(Buffer.get(), Size);
|
||||||
|
StringRef MCPU = StringSwitch<const char *>(CPU)
|
||||||
|
.Case("POWER 4\n", "pwr4")
|
||||||
|
.Case("POWER 5\n", "pwr5")
|
||||||
|
.Case("POWER 6\n", "pwr6")
|
||||||
|
.Case("POWER 7\n", "pwr7")
|
||||||
|
.Case("POWER 8\n", "pwr8")
|
||||||
|
.Case("POWER 9\n", "pwr9")
|
||||||
|
.Case("POWER 10\n", "pwr10")
|
||||||
|
.Default("unknown");
|
||||||
|
|
||||||
|
StringRef HostCPU = sys::getHostCPUName();
|
||||||
|
|
||||||
|
// Just do the comparison on the base implementation mode.
|
||||||
|
if (HostCPU == "970")
|
||||||
|
HostCPU = StringRef("pwr4");
|
||||||
|
else
|
||||||
|
HostCPU = HostCPU.rtrim('x');
|
||||||
|
|
||||||
|
EXPECT_EQ(HostCPU, MCPU);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user