summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegisterPressure.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-05-10 21:06:10 +0000
committerAndrew Trick <atrick@apple.com>2012-05-10 21:06:10 +0000
commit7f8ab785af09e4d6e4db07157a5b5aa449b5c3ae (patch)
treee7929d2f815285147153759912c1ee058e0d6c05 /lib/CodeGen/RegisterPressure.cpp
parent0cfb5cfe9748abda71c62ebec7b2488b51c3ac32 (diff)
downloadllvm-7f8ab785af09e4d6e4db07157a5b5aa449b5c3ae.tar.gz
llvm-7f8ab785af09e4d6e4db07157a5b5aa449b5c3ae.tar.bz2
llvm-7f8ab785af09e4d6e4db07157a5b5aa449b5c3ae.tar.xz
misched: Introducing Top and Bottom register pressure trackers during scheduling.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegisterPressure.cpp')
-rw-r--r--lib/CodeGen/RegisterPressure.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/CodeGen/RegisterPressure.cpp b/lib/CodeGen/RegisterPressure.cpp
index 657d066405..7b86899b17 100644
--- a/lib/CodeGen/RegisterPressure.cpp
+++ b/lib/CodeGen/RegisterPressure.cpp
@@ -337,6 +337,22 @@ static void collectOperands(const MachineInstr *MI,
}
}
+/// Force liveness of registers.
+void RegPressureTracker::addLiveRegs(ArrayRef<unsigned> Regs) {
+ for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
+ if (TargetRegisterInfo::isVirtualRegister(Regs[i])) {
+ if (LiveVirtRegs.insert(Regs[i]).second)
+ increaseVirtRegPressure(Regs[i]);
+ }
+ else {
+ if (!hasRegAlias(Regs[i], LivePhysRegs, TRI)) {
+ LivePhysRegs.insert(Regs[i]);
+ increasePhysRegPressure(Regs[i]);
+ }
+ }
+ }
+}
+
/// Add PhysReg to the live in set and increase max pressure.
void RegPressureTracker::discoverPhysLiveIn(unsigned Reg) {
assert(!LivePhysRegs.count(Reg) && "avoid bumping max pressure twice");
@@ -607,28 +623,14 @@ getMaxUpwardPressureDelta(const MachineInstr *MI, RegPressureDelta &Delta) {
decreaseVirtRegPressure(VirtRegOpers.DeadDefs);
// Kill liveness at live defs.
- // TODO: consider earlyclobbers?
- for (unsigned i = 0; i < PhysRegOpers.Defs.size(); ++i) {
- unsigned Reg = PhysRegOpers.Defs[i];
- if (LivePhysRegs.erase(Reg))
- decreasePhysRegPressure(Reg);
- else
- discoverPhysLiveOut(Reg);
- }
- for (unsigned i = 0; i < VirtRegOpers.Defs.size(); ++i) {
- unsigned Reg = VirtRegOpers.Defs[i];
- if (LiveVirtRegs.erase(Reg))
- decreaseVirtRegPressure(Reg);
- else
- discoverVirtLiveOut(Reg);
- }
+ decreasePhysRegPressure(PhysRegOpers.Defs);
+ decreaseVirtRegPressure(VirtRegOpers.Defs);
// Generate liveness for uses.
for (unsigned i = 0, e = PhysRegOpers.Uses.size(); i < e; ++i) {
unsigned Reg = PhysRegOpers.Uses[i];
if (!hasRegAlias(Reg, LivePhysRegs, TRI)) {
increasePhysRegPressure(Reg);
- LivePhysRegs.insert(Reg);
}
}
for (unsigned i = 0, e = VirtRegOpers.Uses.size(); i < e; ++i) {