[llvm] r328032 - [TableGen] Use llvm::transform to simplify some loops. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 20 13:24:13 PDT 2018
Author: ctopper
Date: Tue Mar 20 13:24:12 2018
New Revision: 328032
URL: http://llvm.org/viewvc/llvm-project?rev=328032&view=rev
Log:
[TableGen] Use llvm::transform to simplify some loops. NFCI
Modified:
llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
Modified: llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenSchedule.cpp?rev=328032&r1=328031&r2=328032&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenSchedule.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenSchedule.cpp Tue Mar 20 13:24:12 2018
@@ -1371,21 +1371,15 @@ static void inferFromTransitions(ArrayRe
for (ArrayRef<PredTransition>::iterator
I = LastTransitions.begin(), E = LastTransitions.end(); I != E; ++I) {
IdxVec OperWritesVariant;
- for (SmallVectorImpl<SmallVector<unsigned,4>>::const_iterator
- WSI = I->WriteSequences.begin(), WSE = I->WriteSequences.end();
- WSI != WSE; ++WSI) {
- // Create a new write representing the expanded sequence.
- OperWritesVariant.push_back(
- SchedModels.findOrInsertRW(*WSI, /*IsRead=*/false));
- }
+ transform(I->WriteSequences, std::back_inserter(OperWritesVariant),
+ [&SchedModels](ArrayRef<unsigned> WS) {
+ return SchedModels.findOrInsertRW(WS, /*IsRead=*/false);
+ });
IdxVec OperReadsVariant;
- for (SmallVectorImpl<SmallVector<unsigned,4>>::const_iterator
- RSI = I->ReadSequences.begin(), RSE = I->ReadSequences.end();
- RSI != RSE; ++RSI) {
- // Create a new read representing the expanded sequence.
- OperReadsVariant.push_back(
- SchedModels.findOrInsertRW(*RSI, /*IsRead=*/true));
- }
+ transform(I->ReadSequences, std::back_inserter(OperReadsVariant),
+ [&SchedModels](ArrayRef<unsigned> RS) {
+ return SchedModels.findOrInsertRW(RS, /*IsRead=*/true);
+ });
IdxVec ProcIndices(I->ProcIndices.begin(), I->ProcIndices.end());
CodeGenSchedTransition SCTrans;
SCTrans.ToClassIdx =
@@ -1394,10 +1388,10 @@ static void inferFromTransitions(ArrayRe
SCTrans.ProcIndices = ProcIndices;
// The final PredTerm is unique set of predicates guarding the transition.
RecVec Preds;
- for (SmallVectorImpl<PredCheck>::const_iterator
- PI = I->PredTerm.begin(), PE = I->PredTerm.end(); PI != PE; ++PI) {
- Preds.push_back(PI->Predicate);
- }
+ transform(I->PredTerm, std::back_inserter(Preds),
+ [](const PredCheck &P) {
+ return P.Predicate;
+ });
Preds.erase(std::unique(Preds.begin(), Preds.end()), Preds.end());
SCTrans.PredTerm = Preds;
SchedModels.getSchedClass(FromClassIdx).Transitions.push_back(SCTrans);
More information about the llvm-commits
mailing list