diff options
author | Lei Huang <lei@ca.ibm.com> | 2020-04-17 15:19:46 -0500 |
---|---|---|
committer | Lei Huang <lei@ca.ibm.com> | 2020-04-17 15:19:46 -0500 |
commit | 10b60dde767011c250649dc6a305379034c5b5c5 (patch) | |
tree | eb9a4e085218faed3dd11e8eff029b3ba3f01bda /clang/lib | |
parent | 8e20516540444618ad32dd11e835c05804053697 (diff) | |
download | llvm-10b60dde767011c250649dc6a305379034c5b5c5.zip llvm-10b60dde767011c250649dc6a305379034c5b5c5.tar.gz llvm-10b60dde767011c250649dc6a305379034c5b5c5.tar.bz2 |
[PowerPC] Refactor ppcUserFeaturesCheck()
Summary: This function keeps growing, refactor to use lambda.
Reviewers: nemanjai, stefanp
Subscribers: kbarton, shchenz, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D78308
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/Targets/PPC.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp index 1877d4a..81c13a8 100644 --- a/clang/lib/Basic/Targets/PPC.cpp +++ b/clang/lib/Basic/Targets/PPC.cpp @@ -228,33 +228,25 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags, const std::vector<std::string> &FeaturesVec) { - if (llvm::find(FeaturesVec, "-vsx") != FeaturesVec.end()) { - if (llvm::find(FeaturesVec, "+power8-vector") != FeaturesVec.end()) { - Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower8-vector" - << "-mno-vsx"; - return false; - } - - if (llvm::find(FeaturesVec, "+direct-move") != FeaturesVec.end()) { - Diags.Report(diag::err_opt_not_valid_with_opt) << "-mdirect-move" - << "-mno-vsx"; - return false; - } - - if (llvm::find(FeaturesVec, "+float128") != FeaturesVec.end()) { - Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfloat128" - << "-mno-vsx"; - return false; + // vsx was not explicitly turned off. + if (llvm::find(FeaturesVec, "-vsx") == FeaturesVec.end()) + return true; + + auto FindVSXSubfeature = [&](StringRef Feature, StringRef Option) { + if (llvm::find(FeaturesVec, Feature) != FeaturesVec.end()) { + Diags.Report(diag::err_opt_not_valid_with_opt) << Option << "-mno-vsx"; + return true; } + return false; + }; - if (llvm::find(FeaturesVec, "+power9-vector") != FeaturesVec.end()) { - Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower9-vector" - << "-mno-vsx"; - return false; - } - } + bool Found = FindVSXSubfeature("+power8-vector", "-mpower8-vector"); + Found |= FindVSXSubfeature("+direct-move", "-mdirect-move"); + Found |= FindVSXSubfeature("+float128", "-mfloat128"); + Found |= FindVSXSubfeature("+power9-vector", "-mpower9-vector"); - return true; + // Return false if any vsx subfeatures was found. + return !Found; } bool PPCTargetInfo::initFeatureMap( |