MaskRay created this revision. MaskRay added reviewers: PowerPC, nemanjai. Herald added subscribers: shchenz, fedor.sergeev, kbarton, jyknight. Herald added a project: All. MaskRay requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Clang -march= for ppc triples currently leads to an -Wunused-command-line-argument warning but GCC rejects -march=. error: unrecognized command-line option ‘-march=xxx’ Let's reject -march= as well similar to the Sparc change D130273 <https://reviews.llvm.org/D130273>. Close https://github.com/llvm/llvm-project/issues/57587 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D145141 Files: clang/lib/Driver/ToolChains/Arch/PPC.cpp clang/lib/Driver/ToolChains/Arch/PPC.h clang/lib/Driver/ToolChains/CommonArgs.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 @@ -37,3 +37,6 @@ // RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC // // GENERIC: "-target-cpu" "ppc64" + +// RUN: %clang -### -c --target=powerpc64 %s -march=generic 2>&1 | FileCheck --check-prefix=MARCH %s +// MARCH: error: unsupported option '-march=' for target 'powerpc64' Index: clang/lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -410,7 +410,7 @@ case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: - return ppc::getPPCTargetCPU(Args, T); + return ppc::getPPCTargetCPU(D, Args, T); case llvm::Triple::csky: if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) Index: clang/lib/Driver/ToolChains/Arch/PPC.h =================================================================== --- clang/lib/Driver/ToolChains/Arch/PPC.h +++ clang/lib/Driver/ToolChains/Arch/PPC.h @@ -35,7 +35,7 @@ FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getPPCTargetCPU(const llvm::opt::ArgList &Args, +std::string getPPCTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, const llvm::Triple &T); const char *getPPCAsmModeForCPU(StringRef Name); ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D, const llvm::Triple &Triple, Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp =================================================================== --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -35,7 +35,13 @@ } /// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting. -std::string ppc::getPPCTargetCPU(const ArgList &Args, const llvm::Triple &T) { +std::string ppc::getPPCTargetCPU(const Driver &D, const ArgList &Args, + const llvm::Triple &T) { + if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { + D.Diag(diag::err_drv_unsupported_opt_for_target) + << A->getSpelling() << T.getTriple(); + } + if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue();
Index: clang/test/Driver/ppc-cpus.c =================================================================== --- clang/test/Driver/ppc-cpus.c +++ clang/test/Driver/ppc-cpus.c @@ -37,3 +37,6 @@ // RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC // // GENERIC: "-target-cpu" "ppc64" + +// RUN: %clang -### -c --target=powerpc64 %s -march=generic 2>&1 | FileCheck --check-prefix=MARCH %s +// MARCH: error: unsupported option '-march=' for target 'powerpc64' Index: clang/lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -410,7 +410,7 @@ case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: - return ppc::getPPCTargetCPU(Args, T); + return ppc::getPPCTargetCPU(D, Args, T); case llvm::Triple::csky: if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) Index: clang/lib/Driver/ToolChains/Arch/PPC.h =================================================================== --- clang/lib/Driver/ToolChains/Arch/PPC.h +++ clang/lib/Driver/ToolChains/Arch/PPC.h @@ -35,7 +35,7 @@ FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getPPCTargetCPU(const llvm::opt::ArgList &Args, +std::string getPPCTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, const llvm::Triple &T); const char *getPPCAsmModeForCPU(StringRef Name); ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D, const llvm::Triple &Triple, Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp =================================================================== --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -35,7 +35,13 @@ } /// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting. -std::string ppc::getPPCTargetCPU(const ArgList &Args, const llvm::Triple &T) { +std::string ppc::getPPCTargetCPU(const Driver &D, const ArgList &Args, + const llvm::Triple &T) { + if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { + D.Diag(diag::err_drv_unsupported_opt_for_target) + << A->getSpelling() << T.getTriple(); + } + if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits