diff options
| author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-05-30 07:24:39 +0000 |
|---|---|---|
| committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-05-30 07:24:39 +0000 |
| commit | a5268e8199bb39e62b9a53b3440100f3b435b6cc (patch) | |
| tree | 8846fb7779464fba688d480d1f01acf4b98cb018 /llvm/lib/CodeGen/LiveIntervals.cpp | |
| parent | 01c1f3279dd72f743269a20dcf9a1e540c97077d (diff) | |
| download | bcm5719-llvm-a5268e8199bb39e62b9a53b3440100f3b435b6cc.tar.gz bcm5719-llvm-a5268e8199bb39e62b9a53b3440100f3b435b6cc.zip | |
When spilling an register, introduce a new temporary for each of its
spills. This allows for more flexibility when allocating registers for
spill code.
llvm-svn: 13907
Diffstat (limited to 'llvm/lib/CodeGen/LiveIntervals.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/LiveIntervals.cpp | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp index 1dda527c85f..e77babb136e 100644 --- a/llvm/lib/CodeGen/LiveIntervals.cpp +++ b/llvm/lib/CodeGen/LiveIntervals.cpp @@ -186,19 +186,23 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) { return true; } -void LiveIntervals::updateSpilledInterval(Interval& li, - VirtRegMap& vrm, - int slot) +std::vector<LiveIntervals::Interval*> +LiveIntervals::addIntervalsForSpills(const Interval& li, + VirtRegMap& vrm, + int slot) { + std::vector<Interval*> added; + assert(li.weight != HUGE_VAL && "attempt to spill already spilled interval!"); - Interval::Ranges oldRanges; - swap(oldRanges, li.ranges); - DEBUG(std::cerr << "\t\t\t\tupdating interval: " << li); + DEBUG(std::cerr << "\t\t\t\tadding intervals for spills for interval: " + << li << '\n'); + + const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(li.reg); - for (Interval::Ranges::iterator i = oldRanges.begin(), e = oldRanges.end(); - i != e; ++i) { + for (Interval::Ranges::const_iterator + i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) { unsigned index = getBaseIndex(i->first); unsigned end = getBaseIndex(i->second-1) + InstrSlots::NUM; for (; index < end; index += InstrSlots::NUM) { @@ -240,16 +244,31 @@ void LiveIntervals::updateSpilledInterval(Interval& li, unsigned end = 1 + (mop.isDef() ? getUseIndex(index+InstrSlots::NUM) : getUseIndex(index)); - li.addRange(start, end); + + // create a new register for this spill + unsigned nReg = + mf_->getSSARegMap()->createVirtualRegister(rc); + mi->SetMachineOperandReg(i, nReg); + vrm.grow(); + vrm.assignVirt2StackSlot(nReg, slot); + Interval& nI = getOrCreateInterval(nReg); + assert(nI.empty()); + // the spill weight is now infinity as it + // cannot be spilled again + nI.weight = HUGE_VAL; + nI.addRange(start, end); + added.push_back(&nI); + // update live variables + lv_->addVirtualRegisterKilled(nReg, mi->getParent(),mi); + DEBUG(std::cerr << "\t\t\t\tadded new interval: " + << nI << '\n'); } } } } } - // the new spill weight is now infinity as it cannot be spilled again - li.weight = HUGE_VAL; - DEBUG(std::cerr << '\n'); - DEBUG(std::cerr << "\t\t\t\tupdated interval: " << li << '\n'); + + return added; } void LiveIntervals::printRegName(unsigned reg) const |

