================ @@ -176,25 +176,43 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) { SmallVector<StringRef, 32> Lines; ProcCpuinfoContent.split(Lines, '\n'); - // Look for the CPU implementer line. + // Look for the CPU implementer and hardware lines, and store the CPU part + // numbers found. StringRef Implementer; StringRef Hardware; - StringRef Part; + SmallVector<StringRef, 32> Parts; for (unsigned I = 0, E = Lines.size(); I != E; ++I) { if (Lines[I].starts_with("CPU implementer")) Implementer = Lines[I].substr(15).ltrim("\t :"); if (Lines[I].starts_with("Hardware")) Hardware = Lines[I].substr(8).ltrim("\t :"); if (Lines[I].starts_with("CPU part")) - Part = Lines[I].substr(8).ltrim("\t :"); + Parts.emplace_back(Lines[I].substr(8).ltrim("\t :")); } + // Last `Part' seen, in case we don't analyse all `Parts' parsed. + StringRef Part = Parts.empty() ? StringRef() : Parts.back(); + + // Remove duplicate `Parts'. + llvm::sort(Parts); + Parts.erase(llvm::unique(Parts), Parts.end()); + + auto MatchBigLittle = [](auto const &Parts, StringRef Big, StringRef Little) { + if (Parts.size() == 2) + return (Parts[0] == Big && Parts[1] == Little) || + (Parts[1] == Big && Parts[0] == Little); + return false; + }; + if (Implementer == "0x41") { // ARM Ltd. // MSM8992/8994 may give cpu part for the core that the kernel is running on, // which is undeterministic and wrong. Always return cortex-a53 for these SoC. if (Hardware.ends_with("MSM8994") || Hardware.ends_with("MSM8996")) return "cortex-a53"; + // Detect big.LITTLE systems. + if (MatchBigLittle(Parts, "0xd85", "0xd87")) + return "gb10"; ---------------- davemgreen wrote:
Why is this uniquely a gb10 device? Could there not be many devices with a Cortex-X925 and Cortex_X725 pair, with and without crypto, that are not "GB10"? https://github.com/llvm/llvm-project/pull/146515 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits