diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp index b5119c8e2ac50..45b4cafc99598 100644 --- a/llvm/lib/TargetParser/Host.cpp +++ b/llvm/lib/TargetParser/Host.cpp @@ -347,6 +347,29 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) { } } + if (Implementer == "0x61") { // Apple + return StringSwitch(Part) + .Case("0x020", "apple-m1") + .Case("0x021", "apple-m1") + .Case("0x022", "apple-m1") + .Case("0x023", "apple-m1") + .Case("0x024", "apple-m1") + .Case("0x025", "apple-m1") + .Case("0x028", "apple-m1") + .Case("0x029", "apple-m1") + .Case("0x030", "apple-m2") + .Case("0x031", "apple-m2") + .Case("0x032", "apple-m2") + .Case("0x033", "apple-m2") + .Case("0x034", "apple-m2") + .Case("0x035", "apple-m2") + .Case("0x038", "apple-m2") + .Case("0x039", "apple-m2") + .Case("0x049", "apple-m3") + .Case("0x048", "apple-m3") + .Default("generic"); + } + if (Implementer == "0x63") { // Arm China. return StringSwitch(Part) .Case("0x132", "star-mc1") diff --git a/llvm/unittests/TargetParser/Host.cpp b/llvm/unittests/TargetParser/Host.cpp index 67c727a6c1c5d..a478c2e6d92d3 100644 --- a/llvm/unittests/TargetParser/Host.cpp +++ b/llvm/unittests/TargetParser/Host.cpp @@ -143,6 +143,9 @@ TEST(getLinuxHostCPUName, AArch64) { EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x46\n" "CPU part : 0x003"), "fujitsu-monaka"); + EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x61\n" + "CPU part : 0x039"), + "apple-m2"); // MSM8992/4 weirdness StringRef MSM8992ProcCpuInfo = R"(