|
41 | 41 | #include <mach/mach.h>
|
42 | 42 | #include <mach/mach_host.h>
|
43 | 43 | #include <mach/machine.h>
|
44 |
| -#include <sys/param.h> |
45 |
| -#include <sys/sysctl.h> |
46 | 44 | #endif
|
47 | 45 | #ifdef _AIX
|
48 | 46 | #include <sys/systemcfg.h>
|
@@ -1299,45 +1297,32 @@ StringRef sys::getHostCPUName() {
|
1299 | 1297 | bool HaveVectorSupport = CVT[244] & 0x80;
|
1300 | 1298 | return getCPUNameFromS390Model(Id, HaveVectorSupport);
|
1301 | 1299 | }
|
1302 |
| -#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__)) |
1303 |
| -#define CPUFAMILY_ARM_SWIFT 0x1e2d6381 |
1304 |
| -#define CPUFAMILY_ARM_CYCLONE 0x37a09642 |
1305 |
| -#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e |
1306 |
| -#define CPUFAMILY_ARM_TWISTER 0x92fb37c8 |
1307 |
| -#define CPUFAMILY_ARM_HURRICANE 0x67ceee93 |
1308 |
| -#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6 |
1309 |
| -#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f |
1310 |
| -#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2 |
1311 |
| -#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3 |
1312 |
| - |
| 1300 | +#elif defined(__APPLE__) && defined(__aarch64__) |
1313 | 1301 | StringRef sys::getHostCPUName() {
|
1314 |
| - uint32_t Family; |
1315 |
| - size_t Length = sizeof(Family); |
1316 |
| - sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0); |
| 1302 | + return "cyclone"; |
| 1303 | +} |
| 1304 | +#elif defined(__APPLE__) && defined(__arm__) |
| 1305 | +StringRef sys::getHostCPUName() { |
| 1306 | + host_basic_info_data_t hostInfo; |
| 1307 | + mach_msg_type_number_t infoCount; |
1317 | 1308 |
|
1318 |
| - switch (Family) { |
1319 |
| - case CPUFAMILY_ARM_SWIFT: |
1320 |
| - return "swift"; |
1321 |
| - case CPUFAMILY_ARM_CYCLONE: |
1322 |
| - return "apple-a7"; |
1323 |
| - case CPUFAMILY_ARM_TYPHOON: |
1324 |
| - return "apple-a8"; |
1325 |
| - case CPUFAMILY_ARM_TWISTER: |
1326 |
| - return "apple-a9"; |
1327 |
| - case CPUFAMILY_ARM_HURRICANE: |
1328 |
| - return "apple-a10"; |
1329 |
| - case CPUFAMILY_ARM_MONSOON_MISTRAL: |
1330 |
| - return "apple-a11"; |
1331 |
| - case CPUFAMILY_ARM_VORTEX_TEMPEST: |
1332 |
| - return "apple-a12"; |
1333 |
| - case CPUFAMILY_ARM_LIGHTNING_THUNDER: |
1334 |
| - return "apple-a13"; |
1335 |
| - case CPUFAMILY_ARM_FIRESTORM_ICESTORM: |
1336 |
| - return "apple-m1"; |
1337 |
| - default: |
1338 |
| - // Default to the newest CPU we know about. |
1339 |
| - return "apple-m1"; |
| 1309 | + infoCount = HOST_BASIC_INFO_COUNT; |
| 1310 | + mach_port_t hostPort = mach_host_self(); |
| 1311 | + host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo, |
| 1312 | + &infoCount); |
| 1313 | + mach_port_deallocate(mach_task_self(), hostPort); |
| 1314 | + |
| 1315 | + if (hostInfo.cpu_type != CPU_TYPE_ARM) { |
| 1316 | + assert(false && "CPUType not equal to ARM should not be possible on ARM"); |
| 1317 | + return "generic"; |
1340 | 1318 | }
|
| 1319 | + switch (hostInfo.cpu_subtype) { |
| 1320 | + case CPU_SUBTYPE_ARM_V7S: |
| 1321 | + return "swift"; |
| 1322 | + default:; |
| 1323 | + } |
| 1324 | + |
| 1325 | + return "generic"; |
1341 | 1326 | }
|
1342 | 1327 | #elif defined(_AIX)
|
1343 | 1328 | StringRef sys::getHostCPUName() {
|
@@ -1468,6 +1453,9 @@ int computeHostNumPhysicalCores() {
|
1468 | 1453 | #elif defined(__linux__) && defined(__s390x__)
|
1469 | 1454 | int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
|
1470 | 1455 | #elif defined(__APPLE__)
|
| 1456 | +#include <sys/param.h> |
| 1457 | +#include <sys/sysctl.h> |
| 1458 | + |
1471 | 1459 | // Gets the number of *physical cores* on the machine.
|
1472 | 1460 | int computeHostNumPhysicalCores() {
|
1473 | 1461 | uint32_t count;
|
|
0 commit comments