Author: Fangrui Song Date: 2022-07-28T00:34:04-07:00 New Revision: 1dc26b80b872a94c581549a21943756a8c3448a3
URL: https://github.com/llvm/llvm-project/commit/1dc26b80b872a94c581549a21943756a8c3448a3 DIFF: https://github.com/llvm/llvm-project/commit/1dc26b80b872a94c581549a21943756a8c3448a3.diff LOG: [Driver][PowerPC] Support -mtune= Reviewed By: #powerpc, nemanjai Differential Revision: https://reviews.llvm.org/D130526 Added: Modified: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Arch/PPC.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/ppc-cpus.c Removed: ################################################################################ diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 3cab37b21aaf3..c723f6164530b 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3986,7 +3986,7 @@ def module_file_info : Flag<["-"], "module-file-info">, Flags<[NoXarchOption,CC1 HelpText<"Provide information about a particular module file">; def mthumb : Flag<["-"], "mthumb">, Group<m_Group>; def mtune_EQ : Joined<["-"], "mtune=">, Group<m_Group>, - HelpText<"Only supported on X86, RISC-V and SystemZ. Otherwise accepted for compatibility with GCC.">; + HelpText<"Only supported on AArch64, PowerPC, RISC-V, SystemZ, and X86">; def multi__module : Flag<["-"], "multi_module">; def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">; def multiply__defined : Separate<["-"], "multiply_defined">; diff --git a/clang/lib/Driver/ToolChains/Arch/PPC.cpp b/clang/lib/Driver/ToolChains/Arch/PPC.cpp index 7817ec595ceb3..bcaecf4b2d980 100644 --- a/clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ b/clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -107,10 +107,6 @@ const char *ppc::getPPCAsmModeForCPU(StringRef Name) { void ppc::getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple, const ArgList &Args, std::vector<StringRef> &Features) { - // TODO Handle -mtune=. Suppress -Wunused-command-line-argument as a - // longstanding behavior. - (void)Args.getLastArg(options::OPT_mtune_EQ); - if (Triple.getSubArch() == llvm::Triple::PPCSubArch_spe) Features.push_back("+spe"); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index eb71a561a1cd4..e94a4e8145107 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2083,6 +2083,14 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args, void Clang::AddPPCTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const { + if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) { + CmdArgs.push_back("-tune-cpu"); + if (strcmp(A->getValue(), "native") == 0) + CmdArgs.push_back(Args.MakeArgString(llvm::sys::getHostCPUName())); + else + CmdArgs.push_back(A->getValue()); + } + // Select the ABI to use. const char *ABIName = nullptr; const llvm::Triple &T = getToolChain().getTriple(); diff --git a/clang/test/Driver/ppc-cpus.c b/clang/test/Driver/ppc-cpus.c index 9f23d86e41efa..a38bf87ab6098 100644 --- a/clang/test/Driver/ppc-cpus.c +++ b/clang/test/Driver/ppc-cpus.c @@ -19,3 +19,6 @@ // RUN: %clang -### -c -target powerpc64 %s -mcpu=pwr8 2>&1 | FileCheck %s --check-prefix=NO_PPC64 // NO_PPC64-NOT: "-target-cpu" "ppc64" + +// RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE +// TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits