llvm.org GIT mirror llvm / 66db3a0
Make BreakAntiDependencies' SUnits argument const, and make the Begin and End arguments by-value rather than by-reference. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101830 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
5 changed file(s) with 42 addition(s) and 41 deletion(s). Raw diff Collapse all Expand all
280280
281281 /// AntiDepEdges - Return in Edges the anti- and output- dependencies
282282 /// in SU that we want to consider for breaking.
283 static void AntiDepEdges(SUnit *SU, std::vector<SDep*>& Edges) {
283 static void AntiDepEdges(const SUnit *SU, std::vectorSDep*>& Edges) {
284284 SmallSet RegSet;
285 for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end();
285 for (SUnit::const_pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end();
286286 P != PE; ++P) {
287287 if ((P->getKind() == SDep::Anti) || (P->getKind() == SDep::Output)) {
288288 unsigned Reg = P->getReg();
296296
297297 /// CriticalPathStep - Return the next SUnit after SU on the bottom-up
298298 /// critical path.
299 static SUnit *CriticalPathStep(SUnit *SU) {
300 SDep *Next = 0;
299 static const SUnit *CriticalPathStep(const SUnit *SU) {
300 const SDep *Next = 0;
301301 unsigned NextDepth = 0;
302302 // Find the predecessor edge with the greatest depth.
303303 if (SU != 0) {
304 for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end();
304 for (SUnit::const_pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end();
305305 P != PE; ++P) {
306 SUnit *PredSU = P->getSUnit();
306 const SUnit *PredSU = P->getSUnit();
307307 unsigned PredLatency = P->getLatency();
308308 unsigned PredTotalLatency = PredSU->getDepth() + PredLatency;
309309 // In the case of a latency tie, prefer an anti-dependency edge over
702702 /// ScheduleDAG and break them by renaming registers.
703703 ///
704704 unsigned AggressiveAntiDepBreaker::BreakAntiDependencies(
705 std::vector& SUnits,
706 MachineBasicBlock::iterator& Begin,
707 MachineBasicBlock::iterator& End,
705 const std::vector& SUnits,
706 MachineBasicBlock::iterator Begin,
707 MachineBasicBlock::iterator End,
708708 unsigned InsertPosIndex) {
709709 unsigned *KillIndices = State->GetKillIndices();
710710 unsigned *DefIndices = State->GetDefIndices();
719719 RenameOrderType RenameOrder;
720720
721721 // ...need a map from MI to SUnit.
722 std::mapSUnit *> MISUnitMap;
722 std::mapconst SUnit *> MISUnitMap;
723723 for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
724 SUnit *SU = &SUnits[i];
725 MISUnitMap.insert(std::pair(SU->getInstr(), SU));
724 const SUnit *SU = &SUnits[i];
725 MISUnitMap.insert(std::pair(SU->getInstr(),
726 SU));
726727 }
727728
728729 // Track progress along the critical path through the SUnit graph as
729730 // we walk the instructions. This is needed for regclasses that only
730731 // break critical-path anti-dependencies.
731 SUnit *CriticalPathSU = 0;
732 const SUnit *CriticalPathSU = 0;
732733 MachineInstr *CriticalPathMI = 0;
733734 if (CriticalPathSet.any()) {
734735 for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
735 SUnit *SU = &SUnits[i];
736 const SUnit *SU = &SUnits[i];
736737 if (!CriticalPathSU ||
737738 ((SU->getDepth() + SU->Latency) >
738739 (CriticalPathSU->getDepth() + CriticalPathSU->Latency))) {
773774
774775 // The dependence edges that represent anti- and output-
775776 // dependencies that are candidates for breaking.
776 std::vector Edges;
777 SUnit *PathSU = MISUnitMap[MI];
777 std::vector Edges;
778 const SUnit *PathSU = MISUnitMap[MI];
778779 AntiDepEdges(PathSU, Edges);
779780
780781 // If MI is not on the critical path, then we don't rename
792793 if (!MI->isKill()) {
793794 // Attempt to break each anti-dependency...
794795 for (unsigned i = 0, e = Edges.size(); i != e; ++i) {
795 SDep *Edge = Edges[i];
796 const SDep *Edge = Edges[i];
796797 SUnit *NextSU = Edge->getSUnit();
797798
798799 if ((Edge->getKind() != SDep::Anti) &&
836837 // Also, if there are dependencies on other SUnits with the
837838 // same register as the anti-dependency, don't attempt to
838839 // break it.
839 for (SUnit::pred_iterator P = PathSU->Preds.begin(),
840 for (SUnit::const_pred_iterator P = PathSU->Preds.begin(),
840841 PE = PathSU->Preds.end(); P != PE; ++P) {
841842 if (P->getSUnit() == NextSU ?
842843 (P->getKind() != SDep::Anti || P->getReg() != AntiDepReg) :
845846 break;
846847 }
847848 }
848 for (SUnit::pred_iterator P = PathSU->Preds.begin(),
849 for (SUnit::const_pred_iterator P = PathSU->Preds.begin(),
849850 PE = PathSU->Preds.end(); P != PE; ++P) {
850851 if ((P->getSUnit() == NextSU) && (P->getKind() != SDep::Anti) &&
851852 (P->getKind() != SDep::Output)) {
141141 /// path
142142 /// of the ScheduleDAG and break them by renaming registers.
143143 ///
144 unsigned BreakAntiDependencies(std::vector& SUnits,
145 MachineBasicBlock::iterator& Begin,
146 MachineBasicBlock::iterator& End,
144 unsigned BreakAntiDependencies(const std::vector& SUnits,
145 MachineBasicBlock::iterator Begin,
146 MachineBasicBlock::iterator End,
147147 unsigned InsertPosIndex);
148148
149149 /// Observe - Update liveness information to account for the current
3838 /// basic-block region and break them by renaming registers. Return
3939 /// the number of anti-dependencies broken.
4040 ///
41 virtual unsigned BreakAntiDependencies(std::vector& SUnits,
42 MachineBasicBlock::iterator& Begin,
43 MachineBasicBlock::iterator& End,
41 virtual unsigned BreakAntiDependencies(const std::vector& SUnits,
42 MachineBasicBlock::iterator Begin,
43 MachineBasicBlock::iterator End,
4444 unsigned InsertPosIndex) =0;
4545
4646 /// Observe - Update liveness information to account for the current
142142
143143 /// CriticalPathStep - Return the next SUnit after SU on the bottom-up
144144 /// critical path.
145 static SDep *CriticalPathStep(SUnit *SU) {
146 SDep *Next = 0;
145 static const SDep *CriticalPathStep(const SUnit *SU) {
146 const SDep *Next = 0;
147147 unsigned NextDepth = 0;
148148 // Find the predecessor edge with the greatest depth.
149 for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end();
149 for (SUnit::const_pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end();
150150 P != PE; ++P) {
151 SUnit *PredSU = P->getSUnit();
151 const SUnit *PredSU = P->getSUnit();
152152 unsigned PredLatency = P->getLatency();
153153 unsigned PredTotalLatency = PredSU->getDepth() + PredLatency;
154154 // In the case of a latency tie, prefer an anti-dependency edge over
325325 }
326326
327327 unsigned CriticalAntiDepBreaker::
328 BreakAntiDependencies(std::vector& SUnits,
329 MachineBasicBlock::iterator& Begin,
330 MachineBasicBlock::iterator& End,
328 BreakAntiDependencies(const std::vector& SUnits,
329 MachineBasicBlock::iterator Begin,
330 MachineBasicBlock::iterator End,
331331 unsigned InsertPosIndex) {
332332 // The code below assumes that there is at least one instruction,
333333 // so just duck out immediately if the block is empty.
334334 if (SUnits.empty()) return 0;
335335
336336 // Find the node at the bottom of the critical path.
337 SUnit *Max = 0;
337 const SUnit *Max = 0;
338338 for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
339 SUnit *SU = &SUnits[i];
339 const SUnit *SU = &SUnits[i];
340340 if (!Max || SU->getDepth() + SU->Latency > Max->getDepth() + Max->Latency)
341341 Max = SU;
342342 }
356356
357357 // Track progress along the critical path through the SUnit graph as we walk
358358 // the instructions.
359 SUnit *CriticalPathSU = Max;
359 const SUnit *CriticalPathSU = Max;
360360 MachineInstr *CriticalPathMI = CriticalPathSU->getInstr();
361361
362362 // Consider this pattern:
428428 // the anti-dependencies in an instruction in order to be effective.
429429 unsigned AntiDepReg = 0;
430430 if (MI == CriticalPathMI) {
431 if (SDep *Edge = CriticalPathStep(CriticalPathSU)) {
432 SUnit *NextSU = Edge->getSUnit();
431 if (const SDep *Edge = CriticalPathStep(CriticalPathSU)) {
432 const SUnit *NextSU = Edge->getSUnit();
433433
434434 // Only consider anti-dependence edges.
435435 if (Edge->getKind() == SDep::Anti) {
451451 // Also, if there are dependencies on other SUnits with the
452452 // same register as the anti-dependency, don't attempt to
453453 // break it.
454 for (SUnit::pred_iterator P = CriticalPathSU->Preds.begin(),
454 for (SUnit::const_pred_iterator P = CriticalPathSU->Preds.begin(),
455455 PE = CriticalPathSU->Preds.end(); P != PE; ++P)
456456 if (P->getSUnit() == NextSU ?
457457 (P->getKind() != SDep::Anti || P->getReg() != AntiDepReg) :
7171 /// path
7272 /// of the ScheduleDAG and break them by renaming registers.
7373 ///
74 unsigned BreakAntiDependencies(std::vector& SUnits,
75 MachineBasicBlock::iterator& Begin,
76 MachineBasicBlock::iterator& End,
74 unsigned BreakAntiDependencies(const std::vector& SUnits,
75 MachineBasicBlock::iterator Begin,
76 MachineBasicBlock::iterator End,
7777 unsigned InsertPosIndex);
7878
7979 /// Observe - Update liveness information to account for the current