Move -mfpmath handling to -cc1 and implement it for x86.

The original idea was to implement it all on the driver, but to do that the
driver needs to know the sse level and to do that it has to know the default
features of a cpu.

Benjamin Kramer pointed out that if one day we decide to implement support for
' __attribute__ ((__target__ ("arch=core2")))', then the frontend needs to
keep its knowledge of default features of a cpu.

To avoid duplicating which part of clang handles default cpu features,
it is probably better to handle -mfpmath in the frontend.

For ARM this patch is just a small improvement. Instead of a cpu list, we
check if neon is enabled, which allows us to reject things like

-mcpu=cortex-a9 -mfpu=vfp -mfpmath=neon

For X86, since LLVM doesn't support an independent ssefp feature, we just
make sure the selected -mfpmath matches the sse level.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188939 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 7463000..25be6b4 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -602,30 +602,6 @@
     D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
 }
 
-// Handle -mfpmath=.
-static void getFPMathFeatures(const Driver &D, const Arg *A,
-                              const ArgList &Args,
-                              std::vector<const char *> &Features,
-                              StringRef CPU) {
-  StringRef FPMath = A->getValue();
-
-  // Set the target features based on the FPMath.
-  if (FPMath == "neon") {
-    Features.push_back("+neonfp");
-
-    if (CPU != "cortex-a5" && CPU != "cortex-a7" &&
-        CPU != "cortex-a8" && CPU != "cortex-a9" &&
-        CPU != "cortex-a9-mp" && CPU != "cortex-a15")
-      D.Diag(diag::err_drv_invalid_feature) << "-mfpmath=neon" << CPU;
-
-  } else if (FPMath == "vfp" || FPMath == "vfp2" || FPMath == "vfp3" ||
-             FPMath == "vfp4") {
-    Features.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);
-}
-
 // Select the float ABI as determined by -msoft-float, -mhard-float, and
 // -mfloat-abi=.
 static StringRef getARMFloatABI(const Driver &D,
@@ -725,10 +701,6 @@
   if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ))
     getFPUFeatures(D, A, Args, Features);
 
-  // Honor -mfpmath=.
-  if (const Arg *A = Args.getLastArg(options::OPT_mfpmath_EQ))
-    getFPMathFeatures(D, A, Args, Features, getARMTargetCPU(Args, Triple));
-
   // Setting -msoft-float effectively disables NEON because of the GCC
   // implementation, although the same isn't true of VFP or VFP3.
   if (FloatABI == "soft")
@@ -2409,6 +2381,11 @@
     CmdArgs.push_back(Args.MakeArgString(CPU));
   }
 
+  if (const Arg *A = Args.getLastArg(options::OPT_mfpmath_EQ)) {
+    CmdArgs.push_back("-mfpmath");
+    CmdArgs.push_back(A->getValue());
+  }
+
   // Add the target features
   getTargetFeatures(D, ETriple, Args, CmdArgs);