[clang] [llvm] [AArch64] Add support for -mcpu=gb10. (PR #146515)
Ricardo Jesus via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 3 03:35:29 PDT 2025
================
@@ -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";
----------------
rj-jesus wrote:
Hi @davemgreen, I agree with the sentiment. As far as native detection goes, our main concern is indeed to pick a valid, consistent CPU. I'm happy picking the "cortex-x925" here (so long as we detect the right crypto features in #146323). Does that sound reasonable to you?
(The problem with +crypto is that we need LLVM and GCC to be consistent, so we'd need both compilers to fix it, which may not happen quickly.)
https://github.com/llvm/llvm-project/pull/146515
More information about the llvm-commits
mailing list