[PATCH] D139343: [Driver][PPC] Support -mtune=auto

Qiongsi Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 5 09:32:31 PST 2022


qiongsiwu1 created this revision.
qiongsiwu1 added reviewers: w2yehia, nemanjai, MaskRay.
qiongsiwu1 added projects: clang, PowerPC.
Herald added subscribers: StephenFan, shchenz, kbarton.
Herald added a project: All.
qiongsiwu1 requested review of this revision.
Herald added a subscriber: cfe-commits.

This patch teaches `clang` to recognize the `auto` option for `-mtune`. The option is identical to the `mtune` option `native`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139343

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ppc-cpus.c


Index: clang/test/Driver/ppc-cpus.c
===================================================================
--- clang/test/Driver/ppc-cpus.c
+++ clang/test/Driver/ppc-cpus.c
@@ -22,3 +22,5 @@
 
 // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE
 // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9"
+// RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=auto 2>&1 | FileCheck %s --check-prefix=NO_AUTO
+// NO_AUTO-NOT: "-target-cpu" "ppc64" "-tune-cpu" "auto"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1990,7 +1990,8 @@
                              ArgStringList &CmdArgs) const {
   if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) {
     CmdArgs.push_back("-tune-cpu");
-    if (strcmp(A->getValue(), "native") == 0)
+    if (strcmp(A->getValue(), "native") == 0 ||
+        strcmp(A->getValue(), "auto") == 0)
       CmdArgs.push_back(Args.MakeArgString(llvm::sys::getHostCPUName()));
     else
       CmdArgs.push_back(A->getValue());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139343.480144.patch
Type: text/x-patch
Size: 1175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221205/5ff70727/attachment.bin>


More information about the cfe-commits mailing list