@@ -313,21 +313,6 @@ static bool containsReg(ArrayRef<unsigned> RegUnits, unsigned RegUnit) {
313313
314314namespace {
315315
316- // / List of register defined and used by a machine instruction.
317- class RegisterOperands {
318- public:
319- SmallVector<unsigned , 8 > Uses;
320- SmallVector<unsigned , 8 > Defs;
321- SmallVector<unsigned , 8 > DeadDefs;
322-
323- void collect (const MachineInstr &MI, const TargetRegisterInfo &TRI,
324- const MachineRegisterInfo &MRI, bool IgnoreDead = false );
325-
326- // / Use liveness information to find dead defs not marked with a dead flag
327- // / and move them to the DeadDefs vector.
328- void detectDeadDefs (const MachineInstr &MI, const LiveIntervals &LIS);
329- };
330-
331316// / Collect this instruction's unique uses and defs into SmallVectors for
332317// / processing defs and uses in order.
333318// /
@@ -385,9 +370,11 @@ class RegisterOperandsCollector {
385370 }
386371 }
387372
388- friend class RegisterOperands ;
373+ friend class llvm :: RegisterOperands;
389374};
390375
376+ } // namespace
377+
391378void RegisterOperands::collect (const MachineInstr &MI,
392379 const TargetRegisterInfo &TRI,
393380 const MachineRegisterInfo &MRI,
@@ -417,8 +404,6 @@ void RegisterOperands::detectDeadDefs(const MachineInstr &MI,
417404 }
418405}
419406
420- } // namespace
421-
422407// / Initialize an array of N PressureDiffs.
423408void PressureDiffs::init (unsigned N) {
424409 Size = N;
@@ -431,6 +416,18 @@ void PressureDiffs::init(unsigned N) {
431416 PDiffArray = reinterpret_cast <PressureDiff*>(calloc (N, sizeof (PressureDiff)));
432417}
433418
419+ void PressureDiffs::addInstruction (unsigned Idx,
420+ const RegisterOperands &RegOpers,
421+ const MachineRegisterInfo &MRI) {
422+ PressureDiff &PDiff = (*this )[Idx];
423+ assert (!PDiff.begin ()->isValid () && " stale PDiff" );
424+ for (unsigned Reg : RegOpers.Defs )
425+ PDiff.addPressureChange (Reg, true , &MRI);
426+
427+ for (unsigned Reg : RegOpers.Uses )
428+ PDiff.addPressureChange (Reg, false , &MRI);
429+ }
430+
434431// / Add a change in pressure to the pressure diff of a given instruction.
435432void PressureDiff::addPressureChange (unsigned RegUnit, bool IsDec,
436433 const MachineRegisterInfo *MRI) {
@@ -467,18 +464,6 @@ void PressureDiff::addPressureChange(unsigned RegUnit, bool IsDec,
467464 }
468465}
469466
470- // / Record the pressure difference induced by the given operand list.
471- static void collectPDiff (PressureDiff &PDiff, RegisterOperands &RegOpers,
472- const MachineRegisterInfo *MRI) {
473- assert (!PDiff.begin ()->isValid () && " stale PDiff" );
474-
475- for (unsigned Reg : RegOpers.Defs )
476- PDiff.addPressureChange (Reg, true , MRI);
477-
478- for (unsigned Reg : RegOpers.Uses )
479- PDiff.addPressureChange (Reg, false , MRI);
480- }
481-
482467// / Force liveness of registers.
483468void RegPressureTracker::addLiveRegs (ArrayRef<unsigned > Regs) {
484469 for (unsigned Reg : Regs) {
@@ -514,39 +499,10 @@ void RegPressureTracker::discoverLiveOut(unsigned Reg) {
514499// / registers that are both defined and used by the instruction. If a pressure
515500// / difference pointer is provided record the changes is pressure caused by this
516501// / instruction independent of liveness.
517- void RegPressureTracker::recede (SmallVectorImpl<unsigned > *LiveUses,
518- PressureDiff *PDiff) {
519- assert (CurrPos != MBB->begin ());
520- if (!isBottomClosed ())
521- closeBottom ();
522-
523- // Open the top of the region using block iterators.
524- if (!RequireIntervals && isTopClosed ())
525- static_cast <RegionPressure&>(P).openTop (CurrPos);
526-
527- // Find the previous instruction.
528- do
529- --CurrPos;
530- while (CurrPos != MBB->begin () && CurrPos->isDebugValue ());
502+ void RegPressureTracker::recede (const RegisterOperands &RegOpers,
503+ SmallVectorImpl<unsigned > *LiveUses) {
531504 assert (!CurrPos->isDebugValue ());
532505
533- SlotIndex SlotIdx;
534- if (RequireIntervals)
535- SlotIdx = LIS->getInstructionIndex (CurrPos).getRegSlot ();
536-
537- // Open the top of the region using slot indexes.
538- if (RequireIntervals && isTopClosed ())
539- static_cast <IntervalPressure&>(P).openTop (SlotIdx);
540-
541- const MachineInstr &MI = *CurrPos;
542- RegisterOperands RegOpers;
543- RegOpers.collect (MI, *TRI, *MRI);
544- if (RequireIntervals)
545- RegOpers.detectDeadDefs (MI, *LIS);
546-
547- if (PDiff)
548- collectPDiff (*PDiff, RegOpers, MRI);
549-
550506 // Boost pressure for all dead defs together.
551507 increaseRegPressure (RegOpers.DeadDefs );
552508 decreaseRegPressure (RegOpers.DeadDefs );
@@ -560,6 +516,10 @@ void RegPressureTracker::recede(SmallVectorImpl<unsigned> *LiveUses,
560516 discoverLiveOut (Reg);
561517 }
562518
519+ SlotIndex SlotIdx;
520+ if (RequireIntervals)
521+ SlotIdx = LIS->getInstructionIndex (CurrPos).getRegSlot ();
522+
563523 // Generate liveness for uses.
564524 for (unsigned Reg : RegOpers.Uses ) {
565525 if (!LiveRegs.contains (Reg)) {
@@ -586,6 +546,41 @@ void RegPressureTracker::recede(SmallVectorImpl<unsigned> *LiveUses,
586546 }
587547}
588548
549+ void RegPressureTracker::recedeSkipDebugValues () {
550+ assert (CurrPos != MBB->begin ());
551+ if (!isBottomClosed ())
552+ closeBottom ();
553+
554+ // Open the top of the region using block iterators.
555+ if (!RequireIntervals && isTopClosed ())
556+ static_cast <RegionPressure&>(P).openTop (CurrPos);
557+
558+ // Find the previous instruction.
559+ do
560+ --CurrPos;
561+ while (CurrPos != MBB->begin () && CurrPos->isDebugValue ());
562+
563+ SlotIndex SlotIdx;
564+ if (RequireIntervals)
565+ SlotIdx = LIS->getInstructionIndex (CurrPos).getRegSlot ();
566+
567+ // Open the top of the region using slot indexes.
568+ if (RequireIntervals && isTopClosed ())
569+ static_cast <IntervalPressure&>(P).openTop (SlotIdx);
570+ }
571+
572+ void RegPressureTracker::recede (SmallVectorImpl<unsigned > *LiveUses) {
573+ recedeSkipDebugValues ();
574+
575+ const MachineInstr &MI = *CurrPos;
576+ RegisterOperands RegOpers;
577+ RegOpers.collect (MI, *TRI, *MRI);
578+ if (RequireIntervals)
579+ RegOpers.detectDeadDefs (MI, *LIS);
580+
581+ recede (RegOpers, LiveUses);
582+ }
583+
589584// / Advance across the current instruction.
590585void RegPressureTracker::advance () {
591586 assert (!TrackUntiedDefs && " unsupported mode" );
0 commit comments