diff options
author | Eric Christopher <echristo@gmail.com> | 2015-08-31 18:39:16 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2015-08-31 18:39:16 +0000 |
commit | a8a14c3d884955453f8eb875434f81a1875d7cb1 (patch) | |
tree | 1c5044d27856d50ced45796712289da2b0f35444 /clang/lib/Basic/Targets.cpp | |
parent | a894266d285fb6c4dfe259942d6c336c1afdc546 (diff) | |
download | bcm5719-llvm-a8a14c3d884955453f8eb875434f81a1875d7cb1.tar.gz bcm5719-llvm-a8a14c3d884955453f8eb875434f81a1875d7cb1.zip |
Pull out the ppc incompatible features check into a separate function.
llvm-svn: 246467
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 2764b2ce775..77cce95dca2 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -1226,9 +1226,36 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, // __NO_FPRS__ } -bool PPCTargetInfo::initFeatureMap( - llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU, - std::vector<std::string> &FeaturesVec) const { +// Handle explicit options being passed to the compiler here: if we've +// explicitly turned off vsx and turned on power8-vector or direct-move then +// go ahead and error since the customer has expressed a somewhat incompatible +// set of options. +static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags, + std::vector<std::string> &FeaturesVec) { + + if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "-vsx") != + FeaturesVec.end()) { + if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+power8-vector") != + FeaturesVec.end()) { + Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower8-vector" + << "-mno-vsx"; + return false; + } + + if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+direct-move") != + FeaturesVec.end()) { + Diags.Report(diag::err_opt_not_valid_with_opt) << "-mdirect-move" + << "-mno-vsx"; + return false; + } + } + + return true; +} + +bool PPCTargetInfo::initFeatureMap(llvm::StringMap<bool> &Features, + DiagnosticsEngine &Diags, StringRef CPU, + std::vector<std::string> &FeaturesVec) const { Features["altivec"] = llvm::StringSwitch<bool>(CPU) .Case("7400", true) .Case("g4", true) @@ -1272,26 +1299,9 @@ bool PPCTargetInfo::initFeatureMap( .Case("pwr7", true) .Default(false); - // Handle explicit options being passed to the compiler here: if we've - // explicitly turned off vsx and turned on power8-vector or direct-move then - // go ahead and error since the customer has expressed a somewhat incompatible - // set of options. - if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "-vsx") != - FeaturesVec.end()) { - if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+power8-vector") != - FeaturesVec.end()) { - Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower8-vector" - << "-mno-vsx"; - return false; - } + if (!ppcUserFeaturesCheck(Diags, FeaturesVec)) + return false; - if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+direct-move") != - FeaturesVec.end()) { - Diags.Report(diag::err_opt_not_valid_with_opt) << "-mdirect-move" - << "-mno-vsx"; - return false; - } - } return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); } @@ -2492,7 +2502,6 @@ bool X86TargetInfo::initFeatureMap( llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU, std::vector<std::string> &FeaturesVec) const { // FIXME: This *really* should not be here. - // X86_64 always has SSE2. if (getTriple().getArch() == llvm::Triple::x86_64) setFeatureEnabledImpl(Features, "sse2", true); @@ -5830,8 +5839,8 @@ public: return CPUKnown; } bool initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, - StringRef CPU, - std::vector<std::string> &FeaturesVec) const override { + StringRef CPU, + std::vector<std::string> &FeaturesVec) const override { if (CPU == "zEC12") Features["transactional-execution"] = true; if (CPU == "z13") { @@ -6200,8 +6209,8 @@ public: } const std::string& getCPU() const { return CPU; } bool initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, - StringRef CPU, - std::vector<std::string> &FeaturesVec) const override { + StringRef CPU, + std::vector<std::string> &FeaturesVec) const override { if (CPU == "octeon") Features["mips64r2"] = Features["cnmips"] = true; else |