Skip to content

Commit bb9dcb2

Browse files
authored
[TableGen] Use contains instead of count. NFC. (#143156)
1 parent eec9431 commit bb9dcb2

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

llvm/utils/TableGen/Basic/DirectiveEmitter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ static void emitLeafTable(const DirectiveLanguage &DirLang, raw_ostream &OS,
685685
auto &LeavesB = LeafTable[B];
686686
int DirA = LeavesA[0], DirB = LeavesB[0];
687687
// First of all, end directives compare greater than non-end directives.
688-
int IsEndA = EndDirectives.count(DirA), IsEndB = EndDirectives.count(DirB);
688+
bool IsEndA = EndDirectives.contains(DirA);
689+
bool IsEndB = EndDirectives.contains(DirB);
689690
if (IsEndA != IsEndB)
690691
return IsEndA < IsEndB;
691692
if (LeavesA[1] == 0 && LeavesB[1] == 0)
@@ -725,7 +726,7 @@ static void emitLeafTable(const DirectiveLanguage &DirLang, raw_ostream &OS,
725726

726727
// Emit a marker where the first "end directive" is.
727728
auto FirstE = find_if(Ordering, [&](int RowIdx) {
728-
return EndDirectives.count(LeafTable[RowIdx][0]);
729+
return EndDirectives.contains(LeafTable[RowIdx][0]);
729730
});
730731
OS << "[[maybe_unused]] static auto " << TableName
731732
<< "EndDirective = " << TableName << " + "

llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ bool TypeInfer::EnforceSameNumElts(TypeSetByHwMode &V, TypeSetByHwMode &W) {
730730
// processed identically.
731731
auto NoLength = [](const SmallDenseSet<ElementCount> &Lengths,
732732
MVT T) -> bool {
733-
return !Lengths.count(T.isVector() ? T.getVectorElementCount()
734-
: ElementCount());
733+
return !Lengths.contains(T.isVector() ? T.getVectorElementCount()
734+
: ElementCount());
735735
};
736736

737737
SmallVector<unsigned, 4> Modes;
@@ -778,7 +778,7 @@ bool TypeInfer::EnforceSameSize(TypeSetByHwMode &A, TypeSetByHwMode &B) {
778778
typedef SmallSet<TypeSize, 2, TypeSizeComparator> TypeSizeSet;
779779

780780
auto NoSize = [](const TypeSizeSet &Sizes, MVT T) -> bool {
781-
return !Sizes.count(T.getSizeInBits());
781+
return !Sizes.contains(T.getSizeInBits());
782782
};
783783

784784
SmallVector<unsigned, 4> Modes;
@@ -3331,7 +3331,7 @@ void CodeGenDAGPatterns::ParsePatternFragments(bool OutFrags) {
33313331
auto ArgsCopy = Args;
33323332
SmallDenseSet<StringRef, 4> OperandsSet(llvm::from_range, ArgsCopy);
33333333

3334-
if (OperandsSet.count(""))
3334+
if (OperandsSet.contains(""))
33353335
P->error("Cannot have unnamed 'node' values in pattern fragment!");
33363336

33373337
// Parse the operands list.

llvm/utils/TableGen/Common/CodeGenRegisters.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ void CodeGenRegBank::computeComposites() {
15321532
if (CodeGenSubRegIndex *Prev =
15331533
Idx1->addComposite(Idx2, Idx3, getHwModes())) {
15341534
// If the composition was not user-defined, always emit a warning.
1535-
if (!UserDefined.count({Idx1, Idx2}) ||
1535+
if (!UserDefined.contains({Idx1, Idx2}) ||
15361536
agree(compose(Idx1, Idx2), SubRegAction.at(Idx3)))
15371537
PrintWarning(Twine("SubRegIndex ") + Idx1->getQualifiedName() +
15381538
" and " + Idx2->getQualifiedName() +
@@ -2408,7 +2408,7 @@ void CodeGenRegBank::inferMatchingSuperRegClass(
24082408
if (RC->getSubClassWithSubReg(SubIdx) != RC)
24092409
continue;
24102410

2411-
if (ImpliedSubRegIndices.count(SubIdx))
2411+
if (ImpliedSubRegIndices.contains(SubIdx))
24122412
continue;
24132413

24142414
// Build list of (Sub, Super) pairs for this SubIdx, sorted by Sub. Note
@@ -2639,13 +2639,13 @@ CodeGenRegBank::computeCoveredRegisters(ArrayRef<const Record *> Regs) {
26392639
// Second, find all super-registers that are completely covered by the set.
26402640
for (unsigned i = 0; i != Set.size(); ++i) {
26412641
for (const CodeGenRegister *Super : Set[i]->getSuperRegs()) {
2642-
if (!Super->CoveredBySubRegs || Set.count(Super))
2642+
if (!Super->CoveredBySubRegs || Set.contains(Super))
26432643
continue;
26442644
// This new super-register is covered by its sub-registers.
26452645
bool AllSubsInSet = true;
26462646
const CodeGenRegister::SubRegMap &SRM = Super->getSubRegs();
26472647
for (auto [_, SR] : SRM)
2648-
if (!Set.count(SR)) {
2648+
if (!Set.contains(SR)) {
26492649
AllSubsInSet = false;
26502650
break;
26512651
}

llvm/utils/TableGen/Common/CodeGenSchedule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ static void inferFromTransitions(ArrayRef<PredTransition> LastTransitions,
16371637
// Transition should not contain processor indices already assigned to
16381638
// InstRWs in this scheduling class.
16391639
const CodeGenSchedClass &FromSC = SchedModels.getSchedClass(FromClassIdx);
1640-
if (FromSC.InstRWProcIndices.count(LastTransition.ProcIndex))
1640+
if (FromSC.InstRWProcIndices.contains(LastTransition.ProcIndex))
16411641
continue;
16421642
SCTrans.ProcIndex = LastTransition.ProcIndex;
16431643
SCTrans.ToClassIdx =
@@ -2176,7 +2176,7 @@ bool CodeGenProcModel::isUnsupported(const CodeGenInstruction &Inst) const {
21762176
}
21772177

21782178
bool CodeGenProcModel::hasReadOfWrite(const Record *WriteDef) const {
2179-
return ReadOfWriteSet.count(WriteDef);
2179+
return ReadOfWriteSet.contains(WriteDef);
21802180
}
21812181

21822182
#ifndef NDEBUG

llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ class InstructionOpcodeMatcher : public InstructionPredicateMatcher {
14001400
}
14011401

14021402
bool hasValue() const override {
1403-
return Insts.size() == 1 && OpcodeValues.count(Insts[0]);
1403+
return Insts.size() == 1 && OpcodeValues.contains(Insts[0]);
14041404
}
14051405

14061406
// TODO: This is used for the SwitchMatcher optimization. We should be able to

llvm/utils/TableGen/Common/GlobalISel/Patterns.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ bool PatFrag::checkSemantics() {
581581

582582
StringSet<> SeenOps;
583583
for (const auto &Op : in_params()) {
584-
if (SeenOps.count(Op.Name)) {
584+
if (SeenOps.contains(Op.Name)) {
585585
PrintError("duplicate parameter '" + Op.Name + "'");
586586
return false;
587587
}
@@ -609,7 +609,7 @@ bool PatFrag::checkSemantics() {
609609
return false;
610610
}
611611

612-
if (SeenOps.count(Op.Name)) {
612+
if (SeenOps.contains(Op.Name)) {
613613
PrintError("duplicate parameter '" + Op.Name + "'");
614614
return false;
615615
}

llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ bool CombineRuleBuilder::buildPermutationsToEmit() {
11611161
PermutationsToEmit.clear();
11621162

11631163
for (const auto &Perm : CurPerms) {
1164-
assert(!Perm.count(Pat.get()) && "Pattern already emitted?");
1164+
assert(!Perm.contains(Pat.get()) && "Pattern already emitted?");
11651165
for (unsigned K = 0; K < NumAlts; ++K) {
11661166
PatternAlternatives NewPerm = Perm;
11671167
NewPerm[Pat.get()] = K;

0 commit comments

Comments
 (0)