Skip to content

Commit

Permalink
RegisterPressure: ArrayRefize some functions for better readability. …
Browse files Browse the repository at this point in the history
…No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155795 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
d0k committed Apr 29, 2012
1 parent 5fe0198 commit 2b8d050
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 38 deletions.
70 changes: 36 additions & 34 deletions lib/CodeGen/RegisterPressure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,34 @@ void RegisterPressure::decrease(const TargetRegisterClass *RC,
decreaseSetPressure(MaxSetPressure, RC, TRI);
}

/// Increase the current pressure as impacted by this physical register and bump
/// the high water mark if needed.
void RegPressureTracker::increasePhysRegPressure(unsigned Reg) {
increaseSetPressure(CurrSetPressure, P.MaxSetPressure,
TRI->getMinimalPhysRegClass(Reg), TRI);
/// Increase the current pressure as impacted by these physical registers and
/// bump the high water mark if needed.
void RegPressureTracker::increasePhysRegPressure(ArrayRef<unsigned> Regs) {
for (unsigned I = 0, E = Regs.size(); I != E; ++I)
increaseSetPressure(CurrSetPressure, P.MaxSetPressure,
TRI->getMinimalPhysRegClass(Regs[I]), TRI);
}

/// Simply decrease the current pressure as impacted by this physcial register.
void RegPressureTracker::decreasePhysRegPressure(unsigned Reg) {
decreaseSetPressure(CurrSetPressure, TRI->getMinimalPhysRegClass(Reg), TRI);
/// Simply decrease the current pressure as impacted by these physcial
/// registers.
void RegPressureTracker::decreasePhysRegPressure(ArrayRef<unsigned> Regs) {
for (unsigned I = 0, E = Regs.size(); I != E; ++I)
decreaseSetPressure(CurrSetPressure, TRI->getMinimalPhysRegClass(Regs[I]),
TRI);
}

/// Increase the current pressure as impacted by this virtual register and bump
/// the high water mark if needed.
void RegPressureTracker::increaseVirtRegPressure(unsigned Reg) {
increaseSetPressure(CurrSetPressure, P.MaxSetPressure,
MRI->getRegClass(Reg), TRI);
/// Increase the current pressure as impacted by these virtual registers and
/// bump the high water mark if needed.
void RegPressureTracker::increaseVirtRegPressure(ArrayRef<unsigned> Regs) {
for (unsigned I = 0, E = Regs.size(); I != E; ++I)
increaseSetPressure(CurrSetPressure, P.MaxSetPressure,
MRI->getRegClass(Regs[I]), TRI);
}

/// Simply decrease the current pressure as impacted by this virtual register.
void RegPressureTracker::decreaseVirtRegPressure(unsigned Reg) {
decreaseSetPressure(CurrSetPressure, MRI->getRegClass(Reg), TRI);
/// Simply decrease the current pressure as impacted by these virtual registers.
void RegPressureTracker::decreaseVirtRegPressure(ArrayRef<unsigned> Regs) {
for (unsigned I = 0, E = Regs.size(); I != E; ++I)
decreaseSetPressure(CurrSetPressure, MRI->getRegClass(Regs[I]), TRI);
}

/// Clear the result so it can be used for another round of pressure tracking.
Expand Down Expand Up @@ -390,7 +396,9 @@ bool RegPressureTracker::recede() {
static_cast<RegionPressure&>(P).openTop(CurrPos);

// Find the previous instruction.
while (--CurrPos != MBB->begin() && CurrPos->isDebugValue());
do
--CurrPos;
while (CurrPos != MBB->begin() && CurrPos->isDebugValue());

if (CurrPos->isDebugValue()) {
closeRegion();
Expand All @@ -409,14 +417,10 @@ bool RegPressureTracker::recede() {
collectOperands(CurrPos, PhysRegOpers, VirtRegOpers, TRI, RCI);

// Boost pressure for all dead defs together.
for (unsigned i = 0; i < PhysRegOpers.DeadDefs.size(); ++i)
increasePhysRegPressure(PhysRegOpers.DeadDefs[i]);
for (unsigned i = 0; i < VirtRegOpers.DeadDefs.size(); ++i)
increaseVirtRegPressure(VirtRegOpers.DeadDefs[i]);
for (unsigned i = 0; i < PhysRegOpers.DeadDefs.size(); ++i)
decreasePhysRegPressure(PhysRegOpers.DeadDefs[i]);
for (unsigned i = 0; i < VirtRegOpers.DeadDefs.size(); ++i)
decreaseVirtRegPressure(VirtRegOpers.DeadDefs[i]);
increasePhysRegPressure(PhysRegOpers.DeadDefs);
increaseVirtRegPressure(VirtRegOpers.DeadDefs);
decreasePhysRegPressure(PhysRegOpers.DeadDefs);
decreaseVirtRegPressure(VirtRegOpers.DeadDefs);

// Kill liveness at live defs.
// TODO: consider earlyclobbers?
Expand Down Expand Up @@ -528,16 +532,14 @@ bool RegPressureTracker::advance() {
}

// Boost pressure for all dead defs together.
for (unsigned i = 0; i < PhysRegOpers.DeadDefs.size(); ++i)
increasePhysRegPressure(PhysRegOpers.DeadDefs[i]);
for (unsigned i = 0; i < VirtRegOpers.DeadDefs.size(); ++i)
increaseVirtRegPressure(VirtRegOpers.DeadDefs[i]);
for (unsigned i = 0; i < PhysRegOpers.DeadDefs.size(); ++i)
decreasePhysRegPressure(PhysRegOpers.DeadDefs[i]);
for (unsigned i = 0; i < VirtRegOpers.DeadDefs.size(); ++i)
decreaseVirtRegPressure(VirtRegOpers.DeadDefs[i]);
increasePhysRegPressure(PhysRegOpers.DeadDefs);
increaseVirtRegPressure(VirtRegOpers.DeadDefs);
decreasePhysRegPressure(PhysRegOpers.DeadDefs);
decreaseVirtRegPressure(VirtRegOpers.DeadDefs);

// Find the next instruction.
while (++CurrPos != MBB->end() && CurrPos->isDebugValue());
do
++CurrPos;
while (CurrPos != MBB->end() && CurrPos->isDebugValue());
return true;
}
8 changes: 4 additions & 4 deletions lib/CodeGen/RegisterPressure.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ class RegPressureTracker {
void closeTop();
void closeBottom();

void increasePhysRegPressure(unsigned Reg);
void decreasePhysRegPressure(unsigned Reg);
void increasePhysRegPressure(ArrayRef<unsigned> Regs);
void decreasePhysRegPressure(ArrayRef<unsigned> Regs);

void increaseVirtRegPressure(unsigned Reg);
void decreaseVirtRegPressure(unsigned Reg);
void increaseVirtRegPressure(ArrayRef<unsigned> Regs);
void decreaseVirtRegPressure(ArrayRef<unsigned> Regs);

void discoverPhysLiveIn(unsigned Reg);
void discoverPhysLiveOut(unsigned Reg);
Expand Down

0 comments on commit 2b8d050

Please sign in to comment.