diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-04-04 22:13:40 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-04-04 22:13:40 +0000 |
commit | 30fe6baf95662ea82a794a8fe3b76998713c183d (patch) | |
tree | 20a1f669e57e37bd2e55429ee3886125a4258ef5 | |
parent | 397f32712369bfed739fe3cb180604b472b41942 (diff) |
[driver] When using the -mfpmath= option, add an error message when trying to
enable neonfp on a CPU that doesn't support NEON.
rdar://11108618
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154061 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticDriverKinds.td | 2 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 12 | ||||
-rw-r--r-- | test/Driver/arm-mfpmath.c | 4 |
3 files changed, 15 insertions, 3 deletions
diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td index a66e9f7e5a..b44315932c 100644 --- a/include/clang/Basic/DiagnosticDriverKinds.td +++ b/include/clang/Basic/DiagnosticDriverKinds.td @@ -71,6 +71,8 @@ def err_drv_invalid_mfloat_abi : Error< "invalid float ABI '%0'">; def err_drv_invalid_libcxx_deployment : Error< "invalid deployment target for -stdlib=libc++ (requires %0 or later)">; +def err_drv_invalid_feature : Error< + "invalid feature '%0' for CPU '%1'">; def err_drv_I_dash_not_supported : Error< "'%0' not supported, please use -iquote instead">; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index dda884303a..84021084ca 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -547,17 +547,23 @@ static void addFPUArgs(const Driver &D, const Arg *A, const ArgList &Args, // Handle -mfpmath=. static void addFPMathArgs(const Driver &D, const Arg *A, const ArgList &Args, - ArgStringList &CmdArgs) { + ArgStringList &CmdArgs, StringRef CPU) { StringRef FPMath = A->getValue(Args); // Set the target features based on the FPMath. if (FPMath == "neon") { CmdArgs.push_back("-target-feature"); CmdArgs.push_back("+neonfp"); + + if (CPU != "cortex-a8" && CPU != "cortex-a9" && CPU != "cortex-a9-mp") + D.Diag(diag::err_drv_invalid_feature) << "-mfpmath=neon" << CPU; + } else if (FPMath == "vfp" || FPMath == "vfp2" || FPMath == "vfp3" || FPMath == "vfp4") { CmdArgs.push_back("-target-feature"); CmdArgs.push_back("-neonfp"); + + // FIXME: Add warnings when disabling a feature not present for a given CPU. } else D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args); } @@ -710,7 +716,7 @@ void Clang::AddARMTargetArgs(const ArgList &Args, // Honor -mfpmath=. if (const Arg *A = Args.getLastArg(options::OPT_mfpmath_EQ)) - addFPMathArgs(D, A, Args, CmdArgs); + addFPMathArgs(D, A, Args, CmdArgs, getARMTargetCPU(Args, Triple)); // Setting -msoft-float effectively disables NEON because of the GCC // implementation, although the same isn't true of VFP or VFP3. @@ -2681,7 +2687,7 @@ void ClangAs::AddARMTargetArgs(const ArgList &Args, // Honor -mfpmath=. if (const Arg *A = Args.getLastArg(options::OPT_mfpmath_EQ)) - addFPMathArgs(D, A, Args, CmdArgs); + addFPMathArgs(D, A, Args, CmdArgs, getARMTargetCPU(Args, Triple)); } void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, diff --git a/test/Driver/arm-mfpmath.c b/test/Driver/arm-mfpmath.c index ab1809385a..0421046c5b 100644 --- a/test/Driver/arm-mfpmath.c +++ b/test/Driver/arm-mfpmath.c @@ -23,3 +23,7 @@ // RUN: %clang -target arm-apple-darwin10 -mfpmath=foo %s -### -c -o %t.o 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-ERROR %s // CHECK-ERROR: clang compiler does not support '-mfpmath=foo' + +// RUN: %clang -target arm-apple-darwin10 -mcpu=arm1136j-s -mfpmath=neon %s -### -c -o %t.o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MCPU-ERROR %s +// CHECK-MCPU-ERROR: error: invalid feature '-mfpmath=neon' for CPU 'arm1136j-s' |