[PATCH] D155201: [Clang][AArch64] Introduce CLANG_AARCH64_DEFAULT_CPU

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 13 07:02:41 PDT 2023


SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: dmgreen, ab, fhahn.
Herald added subscribers: StephenFan, kristof.beyls.
Herald added a project: All.
SjoerdMeijer requested review of this revision.
Herald added a subscriber: MaskRay.

We would like to default to a particular CPU when -mcpu is not provided on the Clang command line. This introduces a CMake variable CLANG_AARCH64_DEFAULT_CPU, so that a default CPU can be specified at CMake build time.

If CLANG_AARCH64_DEFAULT_CPU is not provided, it will default to "generic", so this will make sure we keep the current behaviour.

If CLANG_AARCH64_DEFAULT_CPU is changed, a companion downstream patch is required at the moment for the tests that check "target-cpu generic" when -mcpu is omitted. Ideally we could somehow parameterize that with something like `"target-cpu ${CLANG_AARCH64_DEFAULT_CPU}"` in the tests. Maybe that is possible in Lit, in the config files, but I don't know and am still looking into that.


https://reviews.llvm.org/D155201

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp


Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -8,6 +8,7 @@
 
 #include "AArch64.h"
 #include "../CommonArgs.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -63,7 +64,7 @@
     return Triple.getArch() == llvm::Triple::aarch64_32 ? "apple-s4"
                                                         : "apple-a7";
 
-  return "generic";
+  return CLANG_AARCH64_DEFAULT_CPU;
 }
 
 // Decode AArch64 features from string like +[no]featureA+[no]featureB+...
Index: clang/include/clang/Config/config.h.cmake
===================================================================
--- clang/include/clang/Config/config.h.cmake
+++ clang/include/clang/Config/config.h.cmake
@@ -32,6 +32,9 @@
 /* Default architecture for SystemZ. */
 #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}"
 
+/* Default CPU for AArch64. */
+#define CLANG_AARCH64_DEFAULT_CPU "${CLANG_AARCH64_DEFAULT_CPU}"
+
 /* Multilib basename for libdir. */
 #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}"
 
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -238,6 +238,10 @@
 
 set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch")
 
+if (NOT (CLANG_AARCH64_DEFAULT_CPU))
+  set(CLANG_AARCH64_DEFAULT_CPU "generic" CACHE STRING "AArch64 Default CPU")
+endif()
+
 set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING
   "Vendor-specific text for showing with version information.")
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155201.540004.patch
Type: text/x-patch
Size: 1774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230713/74f3b956/attachment.bin>


More information about the llvm-commits mailing list