This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG1dc26b80b872: [Driver][PowerPC] Support -mtune= (authored by MaskRay).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130526/new/ https://reviews.llvm.org/D130526 Files: 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 Index: clang/test/Driver/ppc-cpus.c =================================================================== --- clang/test/Driver/ppc-cpus.c +++ 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" Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -2083,6 +2083,14 @@ 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(); Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp =================================================================== --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -107,10 +107,6 @@ 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"); Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -3986,7 +3986,7 @@ 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">;
Index: clang/test/Driver/ppc-cpus.c =================================================================== --- clang/test/Driver/ppc-cpus.c +++ 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" Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -2083,6 +2083,14 @@ 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(); Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp =================================================================== --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -107,10 +107,6 @@ 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"); Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -3986,7 +3986,7 @@ 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">;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits