Changes in directory llvm/lib/CodeGen:
LiveIntervalAnalysis.cpp updated: 1.195 -> 1.196 --- Log message: Added a new method "CreateNewLiveInterval" which, given a list of LiveRanges, creates a new LiveInterval from them. The LiveRanges should have existed already in another LiveInterval, but removed. --- Diffs of the changes: (+49 -0) LiveIntervalAnalysis.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.195 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.196 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.195 Wed Nov 15 14:54:11 2006 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Nov 15 20:41:50 2006 @@ -251,6 +251,55 @@ } } +/// CreateNewLiveInterval - Create a new live interval with the given live +/// ranges. The new live interval will have an infinite spill weight. +LiveInterval& +LiveIntervals::CreateNewLiveInterval(const LiveInterval *LI, + const std::vector<LiveRange> &LRs) { + const TargetRegisterClass *RC = mf_->getSSARegMap()->getRegClass(LI->reg); + + // Create a new virtual register for the spill interval. + unsigned NewVReg = mf_->getSSARegMap()->createVirtualRegister(RC); + + // Replace the old virtual registers in the machine operands with the shiny + // new one. + for (std::vector<LiveRange>::const_iterator + I = LRs.begin(), E = LRs.end(); I != E; ++I) { + unsigned Index = getBaseIndex(I->start); + unsigned End = getBaseIndex(I->end - 1) + InstrSlots::NUM; + + for (; Index != End; Index += InstrSlots::NUM) { + // Skip deleted instructions + while (Index != End && !getInstructionFromIndex(Index)) + Index += InstrSlots::NUM; + + if (Index == End) break; + + MachineInstr *MI = getInstructionFromIndex(Index); + + for (unsigned J = 0; J != MI->getNumOperands(); ++J) { + MachineOperand &MOp = MI->getOperand(J); + if (MOp.isRegister() && rep(MOp.getReg()) == LI->reg) + MOp.setReg(NewVReg); + } + } + } + + LiveInterval &NewLI = getOrCreateInterval(NewVReg); + + // The spill weight is now infinity as it cannot be spilled again + NewLI.weight = float(HUGE_VAL); + + for (std::vector<LiveRange>::const_iterator + I = LRs.begin(), E = LRs.end(); I != E; ++I) { + DEBUG(std::cerr << " Adding live range " << *I << " to new interval\n"); + NewLI.addRange(*I); + } + + DEBUG(std::cerr << "Created new live interval " << NewLI << "\n"); + return NewLI; +} + std::vector<LiveInterval*> LiveIntervals:: addIntervalsForSpills(const LiveInterval &li, VirtRegMap &vrm, int slot) { // since this is called after the analysis is done we don't know if _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits