Skip to content

[TableGen] Use llvm::unique (NFC) #94163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions llvm/utils/TableGen/AsmMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3472,9 +3472,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
}
return false;
});
FeatureBitsets.erase(
std::unique(FeatureBitsets.begin(), FeatureBitsets.end()),
FeatureBitsets.end());
FeatureBitsets.erase(llvm::unique(FeatureBitsets), FeatureBitsets.end());
OS << "// Feature bitsets.\n"
<< "enum : " << getMinimalTypeForRange(FeatureBitsets.size()) << " {\n"
<< " AMFBS_None,\n";
Expand Down
3 changes: 1 addition & 2 deletions llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,7 @@ void PatternToMatch::getPredicateRecords(
// Sort so that different orders get canonicalized to the same string.
llvm::sort(PredicateRecs, LessRecord());
// Remove duplicate predicates.
PredicateRecs.erase(std::unique(PredicateRecs.begin(), PredicateRecs.end()),
PredicateRecs.end());
PredicateRecs.erase(llvm::unique(PredicateRecs), PredicateRecs.end());
}

/// getPredicateCheck - Return a single string containing all of this
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/Common/CodeGenRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ struct TupleExpander : SetTheory::Expander {

static void sortAndUniqueRegisters(CodeGenRegister::Vec &M) {
llvm::sort(M, deref<std::less<>>());
M.erase(std::unique(M.begin(), M.end(), deref<std::equal_to<>>()), M.end());
M.erase(llvm::unique(M, deref<std::equal_to<>>()), M.end());
}

CodeGenRegisterClass::CodeGenRegisterClass(CodeGenRegBank &RegBank, Record *R)
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/Common/CodeGenSchedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ static void inferFromTransitions(ArrayRef<PredTransition> LastTransitions,
RecVec Preds;
transform(LastTransition.PredTerm, std::back_inserter(Preds),
[](const PredCheck &P) { return P.Predicate; });
Preds.erase(std::unique(Preds.begin(), Preds.end()), Preds.end());
Preds.erase(llvm::unique(Preds), Preds.end());
dumpTransition(SchedModels, FromSC, SCTrans, Preds);
SCTrans.PredTerm = std::move(Preds);
SchedModels.getSchedClass(FromClassIdx)
Expand Down
6 changes: 2 additions & 4 deletions llvm/utils/TableGen/Common/CodeGenTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ std::vector<ValueTypeByHwMode> CodeGenTarget::getRegisterVTs(Record *R) const {

// Remove duplicates.
llvm::sort(Result);
Result.erase(std::unique(Result.begin(), Result.end()), Result.end());
Result.erase(llvm::unique(Result), Result.end());
return Result;
}

Expand All @@ -260,9 +260,7 @@ void CodeGenTarget::ReadLegalValueTypes() const {

// Remove duplicates.
llvm::sort(LegalValueTypes);
LegalValueTypes.erase(
std::unique(LegalValueTypes.begin(), LegalValueTypes.end()),
LegalValueTypes.end());
LegalValueTypes.erase(llvm::unique(LegalValueTypes), LegalValueTypes.end());
}

CodeGenSchedModels &CodeGenTarget::getSchedModels() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ void GlobalISelMatchTableExecutorEmitter::emitSubtargetFeatureBitsetImpl(

return (A.second < B.second);
});
FeatureBitsets.erase(
std::unique(FeatureBitsets.begin(), FeatureBitsets.end()),
FeatureBitsets.end());
FeatureBitsets.erase(llvm::unique(FeatureBitsets), FeatureBitsets.end());
OS << "// Feature bitsets.\n"
<< "enum {\n"
<< " GIFBS_Invalid,\n";
Expand Down
5 changes: 2 additions & 3 deletions llvm/utils/TableGen/DFAEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ void DfaEmitter::visitDfaState(const DfaState &DS) {
continue;
// Sort and unique.
sort(NewStates);
NewStates.erase(std::unique(NewStates.begin(), NewStates.end()),
NewStates.end());
NewStates.erase(llvm::unique(NewStates), NewStates.end());
sort(TI);
TI.erase(std::unique(TI.begin(), TI.end()), TI.end());
TI.erase(llvm::unique(TI), TI.end());
unsigned ToId = DfaStates.insert(NewStates);
DfaTransitions.emplace(std::pair(FromId, A), std::pair(ToId, TI));
}
Expand Down
3 changes: 1 addition & 2 deletions llvm/utils/TableGen/FastISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,7 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
if (MI != SignaturesWithConstantForms.end()) {
// Unique any duplicates out of the list.
llvm::sort(MI->second);
MI->second.erase(std::unique(MI->second.begin(), MI->second.end()),
MI->second.end());
MI->second.erase(llvm::unique(MI->second), MI->second.end());

// Check each in order it was seen. It would be nice to have a good
// relative ordering between them, but we're not going for optimality
Expand Down
5 changes: 2 additions & 3 deletions llvm/utils/TableGen/GlobalISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2469,9 +2469,8 @@ void GlobalISelEmitter::run(raw_ostream &OS) {
// Sort and remove duplicates to get a list of unique renderer functions, in
// case some were mentioned more than once.
llvm::sort(CustomRendererFns);
CustomRendererFns.erase(
std::unique(CustomRendererFns.begin(), CustomRendererFns.end()),
CustomRendererFns.end());
CustomRendererFns.erase(llvm::unique(CustomRendererFns),
CustomRendererFns.end());

// Create a table containing the LLT objects needed by the matcher and an enum
// for the matcher to reference them with.
Expand Down
4 changes: 1 addition & 3 deletions llvm/utils/TableGen/InstrInfoEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,9 +776,7 @@ void InstrInfoEmitter::emitFeatureVerifier(raw_ostream &OS,
}
return false;
});
FeatureBitsets.erase(
std::unique(FeatureBitsets.begin(), FeatureBitsets.end()),
FeatureBitsets.end());
FeatureBitsets.erase(llvm::unique(FeatureBitsets), FeatureBitsets.end());
OS << "inline FeatureBitset computeRequiredFeatures(unsigned Opcode) {\n"
<< " enum : " << getMinimalTypeForRange(FeatureBitsets.size()) << " {\n"
<< " CEFBS_None,\n";
Expand Down
9 changes: 4 additions & 5 deletions llvm/utils/TableGen/RegisterInfoEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,10 @@ static void finalizeDwarfRegNumsKeys(DwarfRegNumsVecTy &DwarfRegNums) {
"specified multiple times");
LastSeenReg = Reg;
}
auto Last = std::unique(
DwarfRegNums.begin(), DwarfRegNums.end(),
[](const DwarfRegNumsMapPair &A, const DwarfRegNumsMapPair &B) {
return A.first->getName() == B.first->getName();
});
auto Last = llvm::unique(DwarfRegNums, [](const DwarfRegNumsMapPair &A,
const DwarfRegNumsMapPair &B) {
return A.first->getName() == B.first->getName();
});
DwarfRegNums.erase(Last, DwarfRegNums.end());
}

Expand Down
Loading