@@ -949,10 +949,9 @@ void SwingSchedulerDAG::changeDependences() {
949
949
950
950
// Remove the dependence. The value now depends on a prior iteration.
951
951
SmallVector<SDep, 4 > Deps;
952
- for (SUnit::pred_iterator P = I.Preds .begin (), E = I.Preds .end (); P != E;
953
- ++P)
954
- if (P->getSUnit () == DefSU)
955
- Deps.push_back (*P);
952
+ for (const SDep &P : I.Preds )
953
+ if (P.getSUnit () == DefSU)
954
+ Deps.push_back (P);
956
955
for (int i = 0 , e = Deps.size (); i != e; i++) {
957
956
Topo.RemovePred (&I, Deps[i].getSUnit ());
958
957
I.removePred (Deps[i]);
@@ -1203,12 +1202,10 @@ static void swapAntiDependences(std::vector<SUnit> &SUnits) {
1203
1202
DepsAdded.push_back (std::make_pair (SU, *IP));
1204
1203
}
1205
1204
}
1206
- for (SmallVector<std::pair<SUnit *, SDep>, 8 >::iterator I = DepsAdded.begin (),
1207
- E = DepsAdded.end ();
1208
- I != E; ++I) {
1205
+ for (std::pair<SUnit *, SDep> &P : DepsAdded) {
1209
1206
// Remove this anti dependency and add one in the reverse direction.
1210
- SUnit *SU = I-> first ;
1211
- SDep &D = I-> second ;
1207
+ SUnit *SU = P. first ;
1208
+ SDep &D = P. second ;
1212
1209
SUnit *TargetSU = D.getSUnit ();
1213
1210
unsigned Reg = D.getReg ();
1214
1211
unsigned Lat = D.getLatency ();
@@ -1447,22 +1444,18 @@ void SwingSchedulerDAG::computeNodeFunctions(NodeSetType &NodeSets) {
1447
1444
ScheduleInfo.resize (SUnits.size ());
1448
1445
1449
1446
LLVM_DEBUG ({
1450
- for (ScheduleDAGTopologicalSort::const_iterator I = Topo.begin (),
1451
- E = Topo.end ();
1452
- I != E; ++I) {
1453
- const SUnit &SU = SUnits[*I];
1447
+ for (int I : Topo) {
1448
+ const SUnit &SU = SUnits[I];
1454
1449
dumpNode (SU);
1455
1450
}
1456
1451
});
1457
1452
1458
1453
int maxASAP = 0 ;
1459
1454
// Compute ASAP and ZeroLatencyDepth.
1460
- for (ScheduleDAGTopologicalSort::const_iterator I = Topo.begin (),
1461
- E = Topo.end ();
1462
- I != E; ++I) {
1455
+ for (int I : Topo) {
1463
1456
int asap = 0 ;
1464
1457
int zeroLatencyDepth = 0 ;
1465
- SUnit *SU = &SUnits[* I];
1458
+ SUnit *SU = &SUnits[I];
1466
1459
for (SUnit::const_pred_iterator IP = SU->Preds .begin (),
1467
1460
EP = SU->Preds .end ();
1468
1461
IP != EP; ++IP) {
@@ -1476,8 +1469,8 @@ void SwingSchedulerDAG::computeNodeFunctions(NodeSetType &NodeSets) {
1476
1469
getDistance (pred, SU, *IP) * MII));
1477
1470
}
1478
1471
maxASAP = std::max (maxASAP, asap);
1479
- ScheduleInfo[* I].ASAP = asap;
1480
- ScheduleInfo[* I].ZeroLatencyDepth = zeroLatencyDepth;
1472
+ ScheduleInfo[I].ASAP = asap;
1473
+ ScheduleInfo[I].ZeroLatencyDepth = zeroLatencyDepth;
1481
1474
}
1482
1475
1483
1476
// Compute ALAP, ZeroLatencyHeight, and MOV.
@@ -1531,25 +1524,22 @@ static bool pred_L(SetVector<SUnit *> &NodeOrder,
1531
1524
Preds.clear ();
1532
1525
for (SetVector<SUnit *>::iterator I = NodeOrder.begin (), E = NodeOrder.end ();
1533
1526
I != E; ++I) {
1534
- for (SUnit::pred_iterator PI = (*I)->Preds .begin (), PE = (*I)->Preds .end ();
1535
- PI != PE; ++PI) {
1536
- if (S && S->count (PI->getSUnit ()) == 0 )
1527
+ for (const SDep &Pred : (*I)->Preds ) {
1528
+ if (S && S->count (Pred.getSUnit ()) == 0 )
1537
1529
continue ;
1538
- if (ignoreDependence (*PI , true ))
1530
+ if (ignoreDependence (Pred , true ))
1539
1531
continue ;
1540
- if (NodeOrder.count (PI-> getSUnit ()) == 0 )
1541
- Preds.insert (PI-> getSUnit ());
1532
+ if (NodeOrder.count (Pred. getSUnit ()) == 0 )
1533
+ Preds.insert (Pred. getSUnit ());
1542
1534
}
1543
1535
// Back-edges are predecessors with an anti-dependence.
1544
- for (SUnit::const_succ_iterator IS = (*I)->Succs .begin (),
1545
- ES = (*I)->Succs .end ();
1546
- IS != ES; ++IS) {
1547
- if (IS->getKind () != SDep::Anti)
1536
+ for (const SDep &Succ : (*I)->Succs ) {
1537
+ if (Succ.getKind () != SDep::Anti)
1548
1538
continue ;
1549
- if (S && S->count (IS-> getSUnit ()) == 0 )
1539
+ if (S && S->count (Succ. getSUnit ()) == 0 )
1550
1540
continue ;
1551
- if (NodeOrder.count (IS-> getSUnit ()) == 0 )
1552
- Preds.insert (IS-> getSUnit ());
1541
+ if (NodeOrder.count (Succ. getSUnit ()) == 0 )
1542
+ Preds.insert (Succ. getSUnit ());
1553
1543
}
1554
1544
}
1555
1545
return !Preds.empty ();
@@ -1564,24 +1554,21 @@ static bool succ_L(SetVector<SUnit *> &NodeOrder,
1564
1554
Succs.clear ();
1565
1555
for (SetVector<SUnit *>::iterator I = NodeOrder.begin (), E = NodeOrder.end ();
1566
1556
I != E; ++I) {
1567
- for (SUnit::succ_iterator SI = (*I)->Succs .begin (), SE = (*I)->Succs .end ();
1568
- SI != SE; ++SI) {
1569
- if (S && S->count (SI->getSUnit ()) == 0 )
1557
+ for (SDep &Succ : (*I)->Succs ) {
1558
+ if (S && S->count (Succ.getSUnit ()) == 0 )
1570
1559
continue ;
1571
- if (ignoreDependence (*SI , false ))
1560
+ if (ignoreDependence (Succ , false ))
1572
1561
continue ;
1573
- if (NodeOrder.count (SI-> getSUnit ()) == 0 )
1574
- Succs.insert (SI-> getSUnit ());
1562
+ if (NodeOrder.count (Succ. getSUnit ()) == 0 )
1563
+ Succs.insert (Succ. getSUnit ());
1575
1564
}
1576
- for (SUnit::const_pred_iterator PI = (*I)->Preds .begin (),
1577
- PE = (*I)->Preds .end ();
1578
- PI != PE; ++PI) {
1579
- if (PI->getKind () != SDep::Anti)
1565
+ for (SDep &Pred : (*I)->Preds ) {
1566
+ if (Pred.getKind () != SDep::Anti)
1580
1567
continue ;
1581
- if (S && S->count (PI-> getSUnit ()) == 0 )
1568
+ if (S && S->count (Pred. getSUnit ()) == 0 )
1582
1569
continue ;
1583
- if (NodeOrder.count (PI-> getSUnit ()) == 0 )
1584
- Succs.insert (PI-> getSUnit ());
1570
+ if (NodeOrder.count (Pred. getSUnit ()) == 0 )
1571
+ Succs.insert (Pred. getSUnit ());
1585
1572
}
1586
1573
}
1587
1574
return !Succs.empty ();
@@ -1807,11 +1794,10 @@ void SwingSchedulerDAG::groupRemainingNodes(NodeSetType &NodeSets) {
1807
1794
1808
1795
// Create new nodes sets with the connected nodes any remaining node that
1809
1796
// has no predecessor.
1810
- for (unsigned i = 0 ; i < SUnits.size (); ++i) {
1811
- SUnit *SU = &SUnits[i];
1812
- if (NodesAdded.count (SU) == 0 ) {
1797
+ for (SUnit &SU : SUnits) {
1798
+ if (NodesAdded.count (&SU) == 0 ) {
1813
1799
NewSet.clear ();
1814
- addConnectedNodes (SU, NewSet, NodesAdded);
1800
+ addConnectedNodes (& SU, NewSet, NodesAdded);
1815
1801
if (!NewSet.empty ())
1816
1802
NodeSets.push_back (NewSet);
1817
1803
}
@@ -1858,9 +1844,8 @@ void SwingSchedulerDAG::fuseRecs(NodeSetType &NodeSets) {
1858
1844
if (NI.getNode (0 )->NodeNum == NJ.getNode (0 )->NodeNum ) {
1859
1845
if (NJ.compareRecMII (NI) > 0 )
1860
1846
NI.setRecMII (NJ.getRecMII ());
1861
- for (NodeSet::iterator NII = J->begin (), ENI = J->end (); NII != ENI;
1862
- ++NII)
1863
- I->insert (*NII);
1847
+ for (SUnit *SU : *J)
1848
+ I->insert (SU);
1864
1849
NodeSets.erase (J);
1865
1850
E = NodeSets.end ();
1866
1851
} else {
@@ -2404,14 +2389,12 @@ bool SMSchedule::insert(SUnit *SU, int StartCycle, int EndCycle, int II) {
2404
2389
checkCycle <= LastCycle; checkCycle += II) {
2405
2390
std::deque<SUnit *> &cycleInstrs = ScheduledInstrs[checkCycle];
2406
2391
2407
- for (std::deque<SUnit *>::iterator I = cycleInstrs.begin (),
2408
- E = cycleInstrs.end ();
2409
- I != E; ++I) {
2410
- if (ST.getInstrInfo ()->isZeroCost ((*I)->getInstr ()->getOpcode ()))
2392
+ for (SUnit *CI : cycleInstrs) {
2393
+ if (ST.getInstrInfo ()->isZeroCost (CI->getInstr ()->getOpcode ()))
2411
2394
continue ;
2412
- assert (ProcItinResources.canReserveResources (*(*I) ->getInstr ()) &&
2395
+ assert (ProcItinResources.canReserveResources (*CI ->getInstr ()) &&
2413
2396
" These instructions have already been scheduled." );
2414
- ProcItinResources.reserveResources (*(*I) ->getInstr ());
2397
+ ProcItinResources.reserveResources (*CI ->getInstr ());
2415
2398
}
2416
2399
}
2417
2400
if (ST.getInstrInfo ()->isZeroCost (SU->getInstr ()->getOpcode ()) ||
@@ -2742,8 +2725,7 @@ bool SMSchedule::isLoopCarriedDefOfUse(SwingSchedulerDAG *SSD,
2742
2725
// different stage than the definition. The pipeliner does not handle
2743
2726
// physical register values that may cross a basic block boundary.
2744
2727
bool SMSchedule::isValidSchedule (SwingSchedulerDAG *SSD) {
2745
- for (int i = 0 , e = SSD->SUnits .size (); i < e; ++i) {
2746
- SUnit &SU = SSD->SUnits [i];
2728
+ for (SUnit &SU : SSD->SUnits ) {
2747
2729
if (!SU.hasPhysRegDefs )
2748
2730
continue ;
2749
2731
int StageDef = stageScheduled (&SU);
@@ -2939,14 +2921,12 @@ void SMSchedule::finalizeSchedule(SwingSchedulerDAG *SSD) {
2939
2921
for (int Cycle = getFirstCycle (), E = getFinalCycle (); Cycle <= E; ++Cycle) {
2940
2922
std::deque<SUnit *> &cycleInstrs = ScheduledInstrs[Cycle];
2941
2923
std::deque<SUnit *> newOrderPhi;
2942
- for (unsigned i = 0 , e = cycleInstrs.size (); i < e; ++i) {
2943
- SUnit *SU = cycleInstrs[i];
2924
+ for (SUnit *SU : cycleInstrs) {
2944
2925
if (SU->getInstr ()->isPHI ())
2945
2926
newOrderPhi.push_back (SU);
2946
2927
}
2947
2928
std::deque<SUnit *> newOrderI;
2948
- for (unsigned i = 0 , e = cycleInstrs.size (); i < e; ++i) {
2949
- SUnit *SU = cycleInstrs[i];
2929
+ for (SUnit *SU : cycleInstrs) {
2950
2930
if (!SU->getInstr ()->isPHI ())
2951
2931
orderDependence (SSD, SU, newOrderI);
2952
2932
}
0 commit comments