(original) (raw)

diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 4a125f5..8aa800c 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -38,6 +38,7 @@ #include "llvm/Support/Process.h" #include "llvm/Support/Program.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetParser.h" using namespace clang::driver; using namespace clang::driver::tools; @@ -508,77 +509,37 @@ static void getARMHWDivFeatures(const Driver &D, const Arg *A, } // Handle -mfpu=. -// -// FIXME: Centralize feature selection, defaulting shouldn't be also in the -// frontend target. static void getARMFPUFeatures(const Driver &D, const Arg *A, const ArgList &Args, std::vector &Features) { StringRef FPU = A->getValue(); + llvm::ARM::FPU Fpu = llvm::ARMTargetParser::getFPU(FPU); - // Set the target features based on the FPU. - if (FPU == "fpa" || FPU == "fpe2" || FPU == "fpe3" || FPU == "maverick") { - // Disable any default FPU support. - Features.push_back("-vfp2"); - Features.push_back("-vfp3"); - Features.push_back("-neon"); - } else if (FPU == "vfp") { - Features.push_back("+vfp2"); - Features.push_back("-neon"); - } else if (FPU == "vfp3-d16" || FPU == "vfpv3-d16") { - Features.push_back("+vfp3"); - Features.push_back("+d16"); - Features.push_back("-neon"); - } else if (FPU == "vfp3" || FPU == "vfpv3") { - Features.push_back("+vfp3"); - Features.push_back("-neon"); - } else if (FPU == "vfp4-d16" || FPU == "vfpv4-d16") { - Features.push_back("+vfp4"); - Features.push_back("+d16"); - Features.push_back("-neon"); - } else if (FPU == "vfp4" || FPU == "vfpv4") { - Features.push_back("+vfp4"); - Features.push_back("-neon"); - } else if (FPU == "fp4-sp-d16" || FPU == "fpv4-sp-d16") { - Features.push_back("+vfp4"); - Features.push_back("+d16"); - Features.push_back("+fp-only-sp"); - Features.push_back("-neon"); - } else if (FPU == "fp5-sp-d16" || FPU == "fpv5-sp-d16") { - Features.push_back("+fp-armv8"); - Features.push_back("+fp-only-sp"); - Features.push_back("+d16"); - Features.push_back("-neon"); - Features.push_back("-crypto"); - } else if (FPU == "fp5-dp-d16" || FPU == "fpv5-dp-d16" || - FPU == "fp5-d16" || FPU == "fpv5-d16") { - Features.push_back("+fp-armv8"); - Features.push_back("+d16"); - Features.push_back("-neon"); - Features.push_back("-crypto"); - } else if (FPU == "fp-armv8") { - Features.push_back("+fp-armv8"); - Features.push_back("-neon"); - Features.push_back("-crypto"); - } else if (FPU == "neon-fp-armv8") { - Features.push_back("+fp-armv8"); - Features.push_back("+neon"); - Features.push_back("-crypto"); - } else if (FPU == "crypto-neon-fp-armv8") { - Features.push_back("+fp-armv8"); - Features.push_back("+neon"); - Features.push_back("+crypto"); - } else if (FPU == "neon") { - Features.push_back("+neon"); - } else if (FPU == "none") { - Features.push_back("-vfp2"); - Features.push_back("-vfp3"); - Features.push_back("-vfp4"); - Features.push_back("-fp-armv8"); - Features.push_back("-crypto"); - Features.push_back("-neon"); - } else + if (Fpu.FPU == llvm::ARM::INVALID_FPU) { D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args); + return; + } + + for (unsigned enable = 0; enable <= 1; ++enable) { + Twine Option = enable ? "+" : "-"; + uint64_t Flag = enable ? Fpu.Enabled : Fpu.Disabled; + if (Flag & llvm::ARM::FeatureVFP2) + Features.push_back(Flag + "vfp2"); + if (Flag & llvm::ARM::FeatureVFP3) + Features.push_back(Flag + "vfp3"); + if (Flag & llvm::ARM::FeatureVFP4) + Features.push_back(Flag + "vfp4"); + if (Flag & llvm::ARM::FeatureD16) + Features.push_back(Flag + "d16"); + if (Flag & llvm::ARM::FeatureVFPOnlySP) + Features.push_back(Flag + "fp-only-sp"); + if (Flag & llvm::ARM::FeatureFPARMv8) + Features.push_back(Flag + "fp-armv8"); + if (Flag & llvm::ARM::FeatureNEON) + Features.push_back(Flag + "neon"); + if (Flag & llvm::ARM::FeatureCrypto) + Features.push_back(Flag + "crypto"); + } } // Select the float ABI as determined by -msoft-float, -mhard-float, and