[llvm] 38eaea7 - TargetParser: AArch64: Add part numbers for Apple CPUs.

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 12 16:53:01 PST 2024


Author: pcc
Date: 2024-12-12T16:52:58-08:00
New Revision: 38eaea73cab3f427edd16d60035cf126f9a99cd0

URL: https://github.com/llvm/llvm-project/commit/38eaea73cab3f427edd16d60035cf126f9a99cd0
DIFF: https://github.com/llvm/llvm-project/commit/38eaea73cab3f427edd16d60035cf126f9a99cd0.diff

LOG: 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: https://github.com/llvm/llvm-project/pull/119777

Added: 
    

Modified: 
    llvm/lib/TargetParser/Host.cpp
    llvm/unittests/TargetParser/Host.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index b5119c8e2ac50a..45b4cafc995986 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<const char *>(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<const char *>(Part)
         .Case("0x132", "star-mc1")

diff  --git a/llvm/unittests/TargetParser/Host.cpp b/llvm/unittests/TargetParser/Host.cpp
index 67c727a6c1c5df..a478c2e6d92d3e 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"(


        


More information about the llvm-commits mailing list