Skip to content

Commit

Permalink
[AArch64] Add native CPU detection for Ampere1
Browse files Browse the repository at this point in the history
Map the IMPLEMENTOR ID 0xc0 (Ampere Computing) and CPU ID 0xac3
(Ampere1) to ampere1.

Differential Revision: https://reviews.llvm.org/D117111
  • Loading branch information
ptomsich authored and davemgreen committed May 3, 2022
1 parent e6cb64a commit 7e02bc5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions llvm/lib/Support/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
}
}

if (Implementer == "0xc0") { // Ampere Computing
return StringSwitch<const char *>(Part)
.Case("0xac3", "ampere1")
.Default("generic");
}

return "generic";
}

Expand Down
4 changes: 4 additions & 0 deletions llvm/unittests/Support/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ TEST(getLinuxHostCPUName, AArch64) {
"CPU part : 0xc01"),
"saphira");

EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
"CPU part : 0xac3"),
"ampere1");

// MSM8992/4 weirdness
StringRef MSM8992ProcCpuInfo = R"(
Processor : AArch64 Processor rev 3 (aarch64)
Expand Down

0 comments on commit 7e02bc5

Please sign in to comment.