[llvm] [AArch64] Add native CPU detection for Microsoft Azure Cobalt 100. (PR #77793)

Alexandros Lamprineas via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 08:10:55 PST 2024


https://github.com/labrinea created https://github.com/llvm/llvm-project/pull/77793

This patch extends the -mcpu/mtune=native support to handle the Microsoft Azure Cobalt 100 CPU as a Neoverse N2. We expect users to use -mcpu=neoverse-n2 when targeting this CPU and all the architecture and codegen decisions to be identical.

The only difference is that the Microsoft Azure Cobalt 100 has a different Implementer ID in the /proc/cpuinfo entry that needs to be detected in getHostCPUNameForARM appropriately.

>From 0856e91470b59e8cbe0670e27848032810863158 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas <alexandros.lamprineas at arm.com>
Date: Thu, 11 Jan 2024 10:15:16 +0000
Subject: [PATCH] [AArch64] Add native CPU detection for Microsoft Azure Cobalt
 100.

This patch extends the -mcpu/mtune=native support to handle the
Microsoft Azure Cobalt 100 CPU as a Neoverse N2. We expect users
to use -mcpu=neoverse-n2 when targeting this CPU and all the
architecture and codegen decisions to be identical.

The only difference is that the Microsoft Azure Cobalt 100 has a
different Implementer ID in the /proc/cpuinfo entry that needs to
be detected in getHostCPUNameForARM appropriately.
---
 llvm/lib/TargetParser/Host.cpp       | 7 +++++++
 llvm/unittests/TargetParser/Host.cpp | 4 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 32941c013c66ef..f1197c29655380 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -310,6 +310,13 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
     }
   }
 
+  if (Implementer == "0x6d") { // Microsoft Corporation.
+    // The Microsoft Azure Cobalt 100 CPU is handled as a Neoverse N2.
+    return StringSwitch<const char *>(Part)
+        .Case("0xd49", "neoverse-n2")
+        .Default("generic");
+  }
+
   if (Implementer == "0xc0") { // Ampere Computing
     return StringSwitch<const char *>(Part)
         .Case("0xac3", "ampere1")
diff --git a/llvm/unittests/TargetParser/Host.cpp b/llvm/unittests/TargetParser/Host.cpp
index 452d0326c1e282..5f151616d7ca6a 100644
--- a/llvm/unittests/TargetParser/Host.cpp
+++ b/llvm/unittests/TargetParser/Host.cpp
@@ -113,7 +113,9 @@ TEST(getLinuxHostCPUName, AArch64) {
   EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x51\n"
                                               "CPU part        : 0xc01"),
             "saphira");
-
+  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x6d\n"
+                                              "CPU part        : 0xd49"),
+            "neoverse-n2");
   EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
                                               "CPU part        : 0xac3"),
             "ampere1");



More information about the llvm-commits mailing list