[cfe-commits] r154046 - in /cfe/trunk: include/clang/Driver/Options.td lib/Basic/Targets.cpp lib/Driver/Tools.cpp test/Driver/arm-mfpmath.c
Sandeep Patel
deeppatel1987 at gmail.com
Fri Apr 6 15:13:00 PDT 2012
Is this really necessary as a driver-level option?
Can't this be inferred from other existing tuning choice (e.g. which
core IP is used)?
How likely is somebody going to want to change this?
deep
On Wed, Apr 4, 2012 at 8:39 PM, Chad Rosier <mcrosier at apple.com> wrote:
> Author: mcrosier
> Date: Wed Apr 4 15:39:32 2012
> New Revision: 154046
>
> URL: http://llvm.org/viewvc/llvm-project?rev=154046&view=rev
> Log:
> [driver] Create a new -mfpmath= option, which is used to control whether clang
> uses Neon instructions for single-precision FP.
>
> -mfpmath=neon is analogous to passing llc -mattr=+neonfp.
> -mfpmath=[vfp|vfp2|vfp3|vfp4] is analogous to passing llc -mattr=-neonfp.
>
> rdar://11108618
>
> Added:
> cfe/trunk/test/Driver/arm-mfpmath.c
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/lib/Driver/Tools.cpp
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=154046&r1=154045&r2=154046&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 4 15:39:32 2012
> @@ -606,6 +606,7 @@
> def mdynamic_no_pic : Joined<"-mdynamic-no-pic">, Group<m_Group>, Flags<[NoArgumentUnused]>;
> def mfix_and_continue : Flag<"-mfix-and-continue">, Group<clang_ignored_m_Group>;
> def mfloat_abi_EQ : Joined<"-mfloat-abi=">, Group<m_Group>;
> +def mfpmath_EQ : Joined<"-mfpmath=">, Group<m_Group>;
> def mfpu_EQ : Joined<"-mfpu=">, Group<m_Group>;
> def mglobal_merge : Flag<"-mglobal-merge">, Group<m_Group>;
> def mhard_float : Flag<"-mhard-float">, Group<m_Group>;
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=154046&r1=154045&r2=154046&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Wed Apr 4 15:39:32 2012
> @@ -2730,7 +2730,8 @@
> StringRef Name,
> bool Enabled) const {
> if (Name == "soft-float" || Name == "soft-float-abi" ||
> - Name == "vfp2" || Name == "vfp3" || Name == "neon" || Name == "d16") {
> + Name == "vfp2" || Name == "vfp3" || Name == "neon" || Name == "d16" ||
> + Name == "neonfp") {
> Features[Name] = Enabled;
> } else
> return false;
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=154046&r1=154045&r2=154046&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Wed Apr 4 15:39:32 2012
> @@ -504,6 +504,23 @@
> }
> }
>
> +// Handle -mfpmath=.
> +static void addFPMathArgs(const Driver &D, const Arg *A, const ArgList &Args,
> + ArgStringList &CmdArgs) {
> + 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");
> + } else if (FPMath == "vfp" || FPMath == "vfp2" || FPMath == "vfp3" ||
> + FPMath == "vfp4") {
> + CmdArgs.push_back("-target-feature");
> + CmdArgs.push_back("-neonfp");
> + } else
> + D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
> +}
> +
> void Clang::AddARMTargetArgs(const ArgList &Args,
> ArgStringList &CmdArgs,
> bool KernelOrKext) const {
> @@ -686,6 +703,10 @@
> D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
> }
>
> + // Honor -mfpmath=.
> + if (const Arg *A = Args.getLastArg(options::OPT_mfpmath_EQ))
> + addFPMathArgs(D, A, Args, CmdArgs);
> +
> // Setting -msoft-float effectively disables NEON because of the GCC
> // implementation, although the same isn't true of VFP or VFP3.
> if (FloatABI == "soft") {
> @@ -2688,6 +2709,10 @@
> } else
> D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
> }
> +
> + // Honor -mfpmath=.
> + if (const Arg *A = Args.getLastArg(options::OPT_mfpmath_EQ))
> + addFPMathArgs(D, A, Args, CmdArgs);
> }
>
> void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
>
> Added: cfe/trunk/test/Driver/arm-mfpmath.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-mfpmath.c?rev=154046&view=auto
> ==============================================================================
> --- cfe/trunk/test/Driver/arm-mfpmath.c (added)
> +++ cfe/trunk/test/Driver/arm-mfpmath.c Wed Apr 4 15:39:32 2012
> @@ -0,0 +1,25 @@
> +// Test different values of -mfpmath.
> +
> +// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp %s -### -c -o %t.o 2>&1 \
> +// RUN: | FileCheck --check-prefix=CHECK-VFP %s
> +// CHECK-VFP: "-target-feature" "-neonfp"
> +
> +// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp2 %s -### -c -o %t.o 2>&1 \
> +// RUN: | FileCheck --check-prefix=CHECK-VFP2 %s
> +// CHECK-VFP2: "-target-feature" "-neonfp"
> +
> +// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp3 %s -### -c -o %t.o 2>&1 \
> +// RUN: | FileCheck --check-prefix=CHECK-VFP3 %s
> +// CHECK-VFP3: "-target-feature" "-neonfp"
> +
> +// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp4 %s -### -c -o %t.o 2>&1 \
> +// RUN: | FileCheck --check-prefix=CHECK-VFP4 %s
> +// CHECK-VFP4: "-target-feature" "-neonfp"
> +
> +// RUN: %clang -target arm-apple-darwin10 -mfpmath=neon %s -### -c -o %t.o 2>&1 \
> +// RUN: | FileCheck --check-prefix=CHECK-NEON %s
> +// CHECK-NEON: "-target-feature" "+neonfp"
> +
> +// 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'
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list