summaryrefslogtreecommitdiffstats
path: root/lib/Driver
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-04-04 20:39:32 +0000
committerChad Rosier <mcrosier@apple.com>2012-04-04 20:39:32 +0000
commit7a938fa66be42710b034a79106de337a275fd265 (patch)
tree503e48f32b4b1acfc430766e4ccfca520752fb1e /lib/Driver
parent878f8502ebea491b818b48e342f9ad9de2feaff6 (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154046 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver')
-rw-r--r--lib/Driver/Tools.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index e5be1e08b6..7dedcc24a5 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -504,6 +504,23 @@ static bool isSignedCharDefault(const llvm::Triple &Triple) {
}
}
+// 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 @@ void Clang::AddARMTargetArgs(const ArgList &Args,
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 @@ void ClangAs::AddARMTargetArgs(const ArgList &Args,
} 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,