[Basic] Use llvm::is_contained (NFC)

This commit is contained in:
Kazu Hirata 2021-10-10 08:52:14 -07:00
parent 05281d95f2
commit 0e9373a6a6
9 changed files with 18 additions and 23 deletions

View File

@ -121,9 +121,7 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
.Default(Target.hasFeature(Feature) ||
isPlatformEnvironment(Target, Feature));
if (!HasFeature)
HasFeature = std::find(LangOpts.ModuleFeatures.begin(),
LangOpts.ModuleFeatures.end(),
Feature) != LangOpts.ModuleFeatures.end();
HasFeature = llvm::is_contained(LangOpts.ModuleFeatures, Feature);
return HasFeature;
}

View File

@ -440,7 +440,7 @@ public:
WavefrontSize = 64;
bool IsOn = F.front() == '+';
StringRef Name = StringRef(F).drop_front();
if (llvm::find(TargetIDFeatures, Name) == TargetIDFeatures.end())
if (!llvm::is_contained(TargetIDFeatures, Name))
return;
assert(OffloadArchFeatures.find(Name) == OffloadArchFeatures.end());
OffloadArchFeatures[Name] = IsOn;

View File

@ -311,8 +311,7 @@ static constexpr llvm::StringLiteral ValidFamilyNames[] = {
"avrxmega6", "avrxmega7", "avrtiny"};
bool AVRTargetInfo::isValidCPUName(StringRef Name) const {
bool IsFamily =
llvm::find(ValidFamilyNames, Name) != std::end(ValidFamilyNames);
bool IsFamily = llvm::is_contained(ValidFamilyNames, Name);
bool IsMCU =
llvm::find_if(AVRMcus, [&](const MCUInfo &Info) {

View File

@ -35,7 +35,7 @@ static constexpr llvm::StringLiteral ValidCPUNames[] = {"generic", "v1", "v2",
"v3", "probe"};
bool BPFTargetInfo::isValidCPUName(StringRef Name) const {
return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
return llvm::is_contained(ValidCPUNames, Name);
}
void BPFTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {

View File

@ -50,7 +50,7 @@ static constexpr llvm::StringLiteral ValidCPUNames[] = {
{"octeon"}, {"octeon+"}, {"p5600"}};
bool MipsTargetInfo::isValidCPUName(StringRef Name) const {
return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
return llvm::is_contained(ValidCPUNames, Name);
}
void MipsTargetInfo::fillValidCPUList(

View File

@ -437,11 +437,11 @@ static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags,
const std::vector<std::string> &FeaturesVec) {
// vsx was not explicitly turned off.
if (llvm::find(FeaturesVec, "-vsx") == FeaturesVec.end())
if (!llvm::is_contained(FeaturesVec, "-vsx"))
return true;
auto FindVSXSubfeature = [&](StringRef Feature, StringRef Option) {
if (llvm::find(FeaturesVec, Feature) != FeaturesVec.end()) {
if (llvm::is_contained(FeaturesVec, Feature)) {
Diags.Report(diag::err_opt_not_valid_with_opt) << Option << "-mno-vsx";
return true;
}
@ -562,28 +562,28 @@ bool PPCTargetInfo::initFeatureMap(
return false;
if (!(ArchDefs & ArchDefinePwr9) && (ArchDefs & ArchDefinePpcgr) &&
llvm::find(FeaturesVec, "+float128") != FeaturesVec.end()) {
llvm::is_contained(FeaturesVec, "+float128")) {
// We have __float128 on PPC but not power 9 and above.
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfloat128" << CPU;
return false;
}
if (!(ArchDefs & ArchDefinePwr10) &&
llvm::find(FeaturesVec, "+mma") != FeaturesVec.end()) {
llvm::is_contained(FeaturesVec, "+mma")) {
// We have MMA on PPC but not power 10 and above.
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mmma" << CPU;
return false;
}
if (!(ArchDefs & ArchDefinePwr8) &&
llvm::find(FeaturesVec, "+rop-protect") != FeaturesVec.end()) {
llvm::is_contained(FeaturesVec, "+rop-protect")) {
// We can turn on ROP Protect on Power 8 and above.
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mrop-protect" << CPU;
return false;
}
if (!(ArchDefs & ArchDefinePwr8) &&
llvm::find(FeaturesVec, "+privileged") != FeaturesVec.end()) {
llvm::is_contained(FeaturesVec, "+privileged")) {
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mprivileged" << CPU;
return false;
}
@ -782,7 +782,7 @@ static constexpr llvm::StringLiteral ValidCPUNames[] = {
{"powerpc64le"}, {"ppc64le"}, {"future"}};
bool PPCTargetInfo::isValidCPUName(StringRef Name) const {
return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
return llvm::is_contained(ValidCPUNames, Name);
}
void PPCTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {

View File

@ -39,10 +39,8 @@ public:
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
// Check if software floating point is enabled
auto Feature = llvm::find(Features, "+soft-float");
if (Feature != Features.end()) {
if (llvm::is_contained(Features, "+soft-float"))
SoftFloat = true;
}
return true;
}
void getTargetDefines(const LangOptions &Opts,

View File

@ -60,7 +60,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
}
bool WebAssemblyTargetInfo::isValidCPUName(StringRef Name) const {
return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
return llvm::is_contained(ValidCPUNames, Name);
}
void WebAssemblyTargetInfo::fillValidCPUList(

View File

@ -139,26 +139,26 @@ bool X86TargetInfo::initFeatureMap(
// Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled.
auto I = Features.find("sse4.2");
if (I != Features.end() && I->getValue() &&
llvm::find(UpdatedFeaturesVec, "-popcnt") == UpdatedFeaturesVec.end())
!llvm::is_contained(UpdatedFeaturesVec, "-popcnt"))
Features["popcnt"] = true;
// Additionally, if SSE is enabled and mmx is not explicitly disabled,
// then enable MMX.
I = Features.find("sse");
if (I != Features.end() && I->getValue() &&
llvm::find(UpdatedFeaturesVec, "-mmx") == UpdatedFeaturesVec.end())
!llvm::is_contained(UpdatedFeaturesVec, "-mmx"))
Features["mmx"] = true;
// Enable xsave if avx is enabled and xsave is not explicitly disabled.
I = Features.find("avx");
if (I != Features.end() && I->getValue() &&
llvm::find(UpdatedFeaturesVec, "-xsave") == UpdatedFeaturesVec.end())
!llvm::is_contained(UpdatedFeaturesVec, "-xsave"))
Features["xsave"] = true;
// Enable CRC32 if SSE4.2 is enabled and CRC32 is not explicitly disabled.
I = Features.find("sse4.2");
if (I != Features.end() && I->getValue() &&
llvm::find(UpdatedFeaturesVec, "-crc32") == UpdatedFeaturesVec.end())
!llvm::is_contained(UpdatedFeaturesVec, "-crc32"))
Features["crc32"] = true;
return true;