[llvm] Add Apple M4 host detection (PR #117530)
Jon Roelofs via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 09:39:40 PST 2024
================
@@ -1471,13 +1483,46 @@ StringRef sys::getHostCPUName() {
#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
#define CPUFAMILY_ARM_BLIZZARD_AVALANCHE 0xda33d83d
#define CPUFAMILY_ARM_EVEREST_SAWTOOTH 0x8765edea
+#define CPUFAMILY_ARM_IBIZA 0xfa33415e
+#define CPUFAMILY_ARM_PALMA 0x72015832
+#define CPUFAMILY_ARM_COLL 0x2876f5b5
+#define CPUFAMILY_ARM_LOBOS 0x5f4dea93
+#define CPUFAMILY_ARM_DONAN 0x6f5129ac
+#define CPUFAMILY_ARM_BRAVA 0x17d5b93a
+#define CPUFAMILY_ARM_TAHITI 0x75d4acb9
+#define CPUFAMILY_ARM_TUPAI 0x204526d0
StringRef sys::getHostCPUName() {
uint32_t Family;
size_t Length = sizeof(Family);
sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
+ // This is found by testing on actual hardware, and by looking at:
+ // https://github.com/apple-oss-distributions/xnu/blob/xnu-11215.41.3/osfmk/arm/cpuid.c#L109-L231.
+ //
+ // Another great resource is
+ // https://github.com/AsahiLinux/docs/wiki/Codenames.
+ //
+ // NOTE: We choose to return `apple-mX` instead of `apple-aX`, since the M1,
+ // M2, M3 etc. aliases are more widely known to users than A14, A15, A16 etc.
+ // (and this code is basically only used on host macOS anyways).
----------------
jroelofs wrote:
seems harmless. sgtm.
https://github.com/llvm/llvm-project/pull/117530
More information about the llvm-commits
mailing list