From 52122df05bdcc5188ded8088ee9f1a8d392a7e00 Mon Sep 17 00:00:00 2001 From: Javed Absar Date: Sun, 8 Oct 2017 17:23:30 +0000 Subject: [TableGen] Simplify, add range_loop in CodeGenSchedule git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315183 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/CodeGenSchedule.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'utils') diff --git a/utils/TableGen/CodeGenSchedule.cpp b/utils/TableGen/CodeGenSchedule.cpp index 00768d88daa..5754297f5d8 100644 --- a/utils/TableGen/CodeGenSchedule.cpp +++ b/utils/TableGen/CodeGenSchedule.cpp @@ -830,16 +830,16 @@ void CodeGenSchedModels::collectProcItins() { void CodeGenSchedModels::collectProcItinRW() { RecVec ItinRWDefs = Records.getAllDerivedDefinitions("ItinRW"); std::sort(ItinRWDefs.begin(), ItinRWDefs.end(), LessRecord()); - for (RecIter II = ItinRWDefs.begin(), IE = ItinRWDefs.end(); II != IE; ++II) { - if (!(*II)->getValueInit("SchedModel")->isComplete()) - PrintFatalError((*II)->getLoc(), "SchedModel is undefined"); - Record *ModelDef = (*II)->getValueAsDef("SchedModel"); + for (Record *RWDef : make_range(ItinRWDefs.begin(), ItinRWDefs.end())) { + if (!RWDef->getValueInit("SchedModel")->isComplete()) + PrintFatalError(RWDef->getLoc(), "SchedModel is undefined"); + Record *ModelDef = RWDef->getValueAsDef("SchedModel"); ProcModelMapTy::const_iterator I = ProcModelMap.find(ModelDef); if (I == ProcModelMap.end()) { - PrintFatalError((*II)->getLoc(), "Undefined SchedMachineModel " + PrintFatalError(RWDef->getLoc(), "Undefined SchedMachineModel " + ModelDef->getName()); } - ProcModels[I->second].ItinRWDefs.push_back(*II); + ProcModels[I->second].ItinRWDefs.push_back(RWDef); } } @@ -1080,8 +1080,8 @@ void PredTransitions::getIntersectingVariants( } // Push each variant. Assign TransVecIdx later. const RecVec VarDefs = SchedRW.TheDef->getValueAsListOfDefs("Variants"); - for (RecIter RI = VarDefs.begin(), RE = VarDefs.end(); RI != RE; ++RI) - Variants.push_back(TransVariant(*RI, SchedRW.Index, VarProcIdx, 0)); + for (Record *VarDef : VarDefs) + Variants.push_back(TransVariant(VarDef, SchedRW.Index, VarProcIdx, 0)); if (VarProcIdx == 0) GenericRW = true; } @@ -1110,12 +1110,11 @@ void PredTransitions::getIntersectingVariants( if (AliasProcIdx == 0) GenericRW = true; } - for (unsigned VIdx = 0, VEnd = Variants.size(); VIdx != VEnd; ++VIdx) { - TransVariant &Variant = Variants[VIdx]; + for (TransVariant &Variant : Variants) { // Don't expand variants if the processor models don't intersect. // A zero processor index means any processor. SmallVectorImpl &ProcIndices = TransVec[TransIdx].ProcIndices; - if (ProcIndices[0] && Variants[VIdx].ProcIdx) { + if (ProcIndices[0] && Variant.ProcIdx) { unsigned Cnt = std::count(ProcIndices.begin(), ProcIndices.end(), Variant.ProcIdx); if (!Cnt) -- cgit v1.2.3