Index: llvm/lib/Support/Host.cpp =================================================================== --- llvm/lib/Support/Host.cpp +++ llvm/lib/Support/Host.cpp @@ -216,6 +216,36 @@ .Case("0xc01", "saphira") .Default("generic"); + if (Implementer == "0x53") { // Samsung Electronics Co., Ltd. + // The Exynos chips have a convoluted ID scheme that doesn't seem to follow + // any predictive pattern across variants and parts. + unsigned Variant = 0, Part = 0; + + // Look for the CPU variant line, whose value is a 1 digit hexadecimal + // number, corresponding to the Variant bits in the CP15/C0 register. + for (auto I : Lines) + if (I.consume_front("CPU variant")) + I.ltrim("\t :").getAsInteger(16, Variant); + + // Look for the CPU part line, whose value is a 3 digit hexadecimal + // number, corresponding to the PartNum bits in the CP15/C0 register. + for (auto I : Lines) + if (I.consume_front("CPU part")) + I.ltrim("\t :").getAsInteger(16, Part); + + unsigned Exynos = (Variant << 12) + Part; + switch (Exynos) { + default: + // Default to Exynos M1. + + case 0x01001: + return "exynos-m1"; + + case 0x04001: + return "exynos-m2"; + } + } + return "generic"; } Index: llvm/unittests/Support/Host.cpp =================================================================== --- llvm/unittests/Support/Host.cpp +++ llvm/unittests/Support/Host.cpp @@ -139,6 +139,35 @@ EXPECT_EQ(sys::detail::getHostCPUNameForARM(MSM8992ProcCpuInfo), "cortex-a53"); + + // Exynos big.LITTLE weirdness + const std::string ExynosProcCpuInfo = R"( +processor : 0 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd03 + +processor : 1 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 +CPU implementer : 0x53 +CPU architecture: 8 +)"; + + EXPECT_EQ(sys::detail::getHostCPUNameForARM(ExynosProcCpuInfo + + "CPU variant : 0x1\n" + "CPU part : 0x001"), + "exynos-m1"); + EXPECT_EQ(sys::detail::getHostCPUNameForARM(ExynosProcCpuInfo + + "CPU variant : 0x4\n" + "CPU part : 0x001"), + "exynos-m2"); + // Verify default for Exynos. + EXPECT_EQ(sys::detail::getHostCPUNameForARM(ExynosProcCpuInfo + + "CPU variant : 0xc\n" + "CPU part : 0xafe"), + "exynos-m1"); } #if defined(__APPLE__)