aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/CodeGen/MachinePipeliner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/MachinePipeliner.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/CodeGen/MachinePipeliner.cpp73
1 files changed, 29 insertions, 44 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/MachinePipeliner.cpp b/contrib/llvm-project/llvm/lib/CodeGen/MachinePipeliner.cpp
index 8d6459a627fa..762395542b40 100644
--- a/contrib/llvm-project/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/contrib/llvm-project/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -649,7 +649,7 @@ void SwingSchedulerDAG::schedule() {
/// Clean up after the software pipeliner runs.
void SwingSchedulerDAG::finishBlock() {
for (auto &KV : NewMIs)
- MF.DeleteMachineInstr(KV.second);
+ MF.deleteMachineInstr(KV.second);
NewMIs.clear();
// Call the superclass.
@@ -1101,17 +1101,15 @@ unsigned SwingSchedulerDAG::calculateResMII() {
// Sort the instructions by the number of available choices for scheduling,
// least to most. Use the number of critical resources as the tie breaker.
FuncUnitSorter FUS = FuncUnitSorter(MF.getSubtarget());
- for (MachineBasicBlock::iterator I = MBB->getFirstNonPHI(),
- E = MBB->getFirstTerminator();
- I != E; ++I)
- FUS.calcCriticalResources(*I);
+ for (MachineInstr &MI :
+ llvm::make_range(MBB->getFirstNonPHI(), MBB->getFirstTerminator()))
+ FUS.calcCriticalResources(MI);
PriorityQueue<MachineInstr *, std::vector<MachineInstr *>, FuncUnitSorter>
FuncUnitOrder(FUS);
- for (MachineBasicBlock::iterator I = MBB->getFirstNonPHI(),
- E = MBB->getFirstTerminator();
- I != E; ++I)
- FuncUnitOrder.push(&*I);
+ for (MachineInstr &MI :
+ llvm::make_range(MBB->getFirstNonPHI(), MBB->getFirstTerminator()))
+ FuncUnitOrder.push(&MI);
while (!FuncUnitOrder.empty()) {
MachineInstr *MI = FuncUnitOrder.top();
@@ -1192,14 +1190,10 @@ unsigned SwingSchedulerDAG::calculateRecMII(NodeSetType &NodeSets) {
/// but we do this to find the circuits, and then change them back.
static void swapAntiDependences(std::vector<SUnit> &SUnits) {
SmallVector<std::pair<SUnit *, SDep>, 8> DepsAdded;
- for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
- SUnit *SU = &SUnits[i];
- for (SUnit::pred_iterator IP = SU->Preds.begin(), EP = SU->Preds.end();
- IP != EP; ++IP) {
- if (IP->getKind() != SDep::Anti)
- continue;
- DepsAdded.push_back(std::make_pair(SU, *IP));
- }
+ for (SUnit &SU : SUnits) {
+ for (SDep &Pred : SU.Preds)
+ if (Pred.getKind() == SDep::Anti)
+ DepsAdded.push_back(std::make_pair(&SU, Pred));
}
for (std::pair<SUnit *, SDep> &P : DepsAdded) {
// Remove this anti dependency and add one in the reverse direction.
@@ -1471,27 +1465,23 @@ void SwingSchedulerDAG::computeNodeFunctions(NodeSetType &NodeSets) {
}
// Compute ALAP, ZeroLatencyHeight, and MOV.
- for (ScheduleDAGTopologicalSort::const_reverse_iterator I = Topo.rbegin(),
- E = Topo.rend();
- I != E; ++I) {
+ for (int I : llvm::reverse(Topo)) {
int alap = maxASAP;
int zeroLatencyHeight = 0;
- SUnit *SU = &SUnits[*I];
- for (SUnit::const_succ_iterator IS = SU->Succs.begin(),
- ES = SU->Succs.end();
- IS != ES; ++IS) {
- SUnit *succ = IS->getSUnit();
- if (IS->getLatency() == 0)
+ SUnit *SU = &SUnits[I];
+ for (const SDep &S : SU->Succs) {
+ SUnit *succ = S.getSUnit();
+ if (S.getLatency() == 0)
zeroLatencyHeight =
std::max(zeroLatencyHeight, getZeroLatencyHeight(succ) + 1);
- if (ignoreDependence(*IS, true))
+ if (ignoreDependence(S, true))
continue;
- alap = std::min(alap, (int)(getALAP(succ) - IS->getLatency() +
- getDistance(SU, succ, *IS) * MII));
+ alap = std::min(alap, (int)(getALAP(succ) - S.getLatency() +
+ getDistance(SU, succ, S) * MII));
}
- ScheduleInfo[*I].ALAP = alap;
- ScheduleInfo[*I].ZeroLatencyHeight = zeroLatencyHeight;
+ ScheduleInfo[I].ALAP = alap;
+ ScheduleInfo[I].ZeroLatencyHeight = zeroLatencyHeight;
}
// After computing the node functions, compute the summary for each node set.
@@ -1548,9 +1538,8 @@ static bool succ_L(SetVector<SUnit *> &NodeOrder,
SmallSetVector<SUnit *, 8> &Succs,
const NodeSet *S = nullptr) {
Succs.clear();
- for (SetVector<SUnit *>::iterator I = NodeOrder.begin(), E = NodeOrder.end();
- I != E; ++I) {
- for (SDep &Succ : (*I)->Succs) {
+ for (const SUnit *SU : NodeOrder) {
+ for (const SDep &Succ : SU->Succs) {
if (S && S->count(Succ.getSUnit()) == 0)
continue;
if (ignoreDependence(Succ, false))
@@ -1558,7 +1547,7 @@ static bool succ_L(SetVector<SUnit *> &NodeOrder,
if (NodeOrder.count(Succ.getSUnit()) == 0)
Succs.insert(Succ.getSUnit());
}
- for (SDep &Pred : (*I)->Preds) {
+ for (const SDep &Pred : SU->Preds) {
if (Pred.getKind() != SDep::Anti)
continue;
if (S && S->count(Pred.getSUnit()) == 0)
@@ -2202,7 +2191,7 @@ bool SwingSchedulerDAG::canUseLastOffsetValue(MachineInstr *MI,
MachineInstr *NewMI = MF.CloneMachineInstr(MI);
NewMI->getOperand(OffsetPosLd).setImm(LoadOffset + StoreOffset);
bool Disjoint = TII->areMemAccessesTriviallyDisjoint(*NewMI, *PrevDef);
- MF.DeleteMachineInstr(NewMI);
+ MF.deleteMachineInstr(NewMI);
if (!Disjoint)
return false;
@@ -2885,10 +2874,8 @@ void SMSchedule::finalizeSchedule(SwingSchedulerDAG *SSD) {
++stage) {
std::deque<SUnit *> &cycleInstrs =
ScheduledInstrs[cycle + (stage * InitiationInterval)];
- for (std::deque<SUnit *>::reverse_iterator I = cycleInstrs.rbegin(),
- E = cycleInstrs.rend();
- I != E; ++I)
- ScheduledInstrs[cycle].push_front(*I);
+ for (SUnit *SU : llvm::reverse(cycleInstrs))
+ ScheduledInstrs[cycle].push_front(SU);
}
}
@@ -2899,10 +2886,8 @@ void SMSchedule::finalizeSchedule(SwingSchedulerDAG *SSD) {
// Change the registers in instruction as specified in the InstrChanges
// map. We need to use the new registers to create the correct order.
- for (int i = 0, e = SSD->SUnits.size(); i != e; ++i) {
- SUnit *SU = &SSD->SUnits[i];
- SSD->applyInstrChange(SU->getInstr(), *this);
- }
+ for (const SUnit &SU : SSD->SUnits)
+ SSD->applyInstrChange(SU.getInstr(), *this);
// Reorder the instructions in each cycle to fix and improve the
// generated code.