Skip to content

Commit 38eaea7

Browse files
authored
TargetParser: AArch64: Add part numbers for Apple CPUs.
Part numbers taken from: https://github.com/AsahiLinux/m1n1/blob/main/src/chickens.c Reviewers: ahmedbougacha, jroelofs Reviewed By: jroelofs Pull Request: #119777
1 parent 08379d6 commit 38eaea7

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

llvm/lib/TargetParser/Host.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,29 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
347347
}
348348
}
349349

350+
if (Implementer == "0x61") { // Apple
351+
return StringSwitch<const char *>(Part)
352+
.Case("0x020", "apple-m1")
353+
.Case("0x021", "apple-m1")
354+
.Case("0x022", "apple-m1")
355+
.Case("0x023", "apple-m1")
356+
.Case("0x024", "apple-m1")
357+
.Case("0x025", "apple-m1")
358+
.Case("0x028", "apple-m1")
359+
.Case("0x029", "apple-m1")
360+
.Case("0x030", "apple-m2")
361+
.Case("0x031", "apple-m2")
362+
.Case("0x032", "apple-m2")
363+
.Case("0x033", "apple-m2")
364+
.Case("0x034", "apple-m2")
365+
.Case("0x035", "apple-m2")
366+
.Case("0x038", "apple-m2")
367+
.Case("0x039", "apple-m2")
368+
.Case("0x049", "apple-m3")
369+
.Case("0x048", "apple-m3")
370+
.Default("generic");
371+
}
372+
350373
if (Implementer == "0x63") { // Arm China.
351374
return StringSwitch<const char *>(Part)
352375
.Case("0x132", "star-mc1")

llvm/unittests/TargetParser/Host.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ TEST(getLinuxHostCPUName, AArch64) {
143143
EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x46\n"
144144
"CPU part : 0x003"),
145145
"fujitsu-monaka");
146+
EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x61\n"
147+
"CPU part : 0x039"),
148+
"apple-m2");
146149

147150
// MSM8992/4 weirdness
148151
StringRef MSM8992ProcCpuInfo = R"(

0 commit comments

Comments
 (0)