aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveIntervalAnalysis.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-19 14:08:10 +0000
committerChris Lattner <sabre@nondot.org>2004-07-19 14:08:10 +0000
commit1c5c0444f1326b58cf05015651f36f2b04ca322d (patch)
tree4803d0803832693904fc94ca92b3fe7fa10f12e0 /lib/CodeGen/LiveIntervalAnalysis.cpp
parentc49c872a1ac4ccd13ebabd161597aef6de909077 (diff)
Split joinIntervals into two methods
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15003 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp169
1 files changed, 85 insertions, 84 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index 44f860c71d..475bb6e1d9 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -494,101 +494,102 @@ unsigned LiveIntervals::rep(unsigned reg)
return reg;
}
-void LiveIntervals::joinIntervals()
-{
- DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n");
-
+void LiveIntervals::joinIntervalsInMachineBB(MachineBasicBlock *MBB) {
+ DEBUG(std::cerr << ((Value*)MBB->getBasicBlock())->getName() << ":\n");
const TargetInstrInfo& tii = *tm_->getInstrInfo();
- for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end();
- mbbi != mbbe; ++mbbi) {
- MachineBasicBlock* mbb = mbbi;
- DEBUG(std::cerr << ((Value*)mbb->getBasicBlock())->getName() << ":\n");
-
- for (MachineBasicBlock::iterator mi = mbb->begin(), mie = mbb->end();
- mi != mie; ++mi) {
- const TargetInstrDescriptor& tid = tii.get(mi->getOpcode());
- DEBUG(std::cerr << getInstructionIndex(mi) << '\t';
- mi->print(std::cerr, tm_););
-
- // we only join virtual registers with allocatable
- // physical registers since we do not have liveness information
- // on not allocatable physical registers
- unsigned regA, regB;
- if (tii.isMoveInstr(*mi, regA, regB) &&
- (MRegisterInfo::isVirtualRegister(regA) ||
- lv_->getAllocatablePhysicalRegisters()[regA]) &&
- (MRegisterInfo::isVirtualRegister(regB) ||
- lv_->getAllocatablePhysicalRegisters()[regB])) {
-
- // get representative registers
- regA = rep(regA);
- regB = rep(regB);
-
- // if they are already joined we continue
- if (regA == regB)
+ for (MachineBasicBlock::iterator mi = MBB->begin(), mie = MBB->end();
+ mi != mie; ++mi) {
+ const TargetInstrDescriptor& tid = tii.get(mi->getOpcode());
+ DEBUG(std::cerr << getInstructionIndex(mi) << '\t';
+ mi->print(std::cerr, tm_););
+
+ // we only join virtual registers with allocatable
+ // physical registers since we do not have liveness information
+ // on not allocatable physical registers
+ unsigned regA, regB;
+ if (tii.isMoveInstr(*mi, regA, regB) &&
+ (MRegisterInfo::isVirtualRegister(regA) ||
+ lv_->getAllocatablePhysicalRegisters()[regA]) &&
+ (MRegisterInfo::isVirtualRegister(regB) ||
+ lv_->getAllocatablePhysicalRegisters()[regB])) {
+
+ // get representative registers
+ regA = rep(regA);
+ regB = rep(regB);
+
+ // if they are already joined we continue
+ if (regA == regB)
+ continue;
+
+ Reg2IntervalMap::iterator r2iA = r2iMap_.find(regA);
+ assert(r2iA != r2iMap_.end() &&
+ "Found unknown vreg in 'isMoveInstr' instruction");
+ Reg2IntervalMap::iterator r2iB = r2iMap_.find(regB);
+ assert(r2iB != r2iMap_.end() &&
+ "Found unknown vreg in 'isMoveInstr' instruction");
+
+ Intervals::iterator intA = r2iA->second;
+ Intervals::iterator intB = r2iB->second;
+
+ // both A and B are virtual registers
+ if (MRegisterInfo::isVirtualRegister(intA->reg) &&
+ MRegisterInfo::isVirtualRegister(intB->reg)) {
+
+ const TargetRegisterClass *rcA, *rcB;
+ rcA = mf_->getSSARegMap()->getRegClass(intA->reg);
+ rcB = mf_->getSSARegMap()->getRegClass(intB->reg);
+ // if they are not of the same register class we continue
+ if (rcA != rcB)
continue;
- Reg2IntervalMap::iterator r2iA = r2iMap_.find(regA);
- assert(r2iA != r2iMap_.end() &&
- "Found unknown vreg in 'isMoveInstr' instruction");
- Reg2IntervalMap::iterator r2iB = r2iMap_.find(regB);
- assert(r2iB != r2iMap_.end() &&
- "Found unknown vreg in 'isMoveInstr' instruction");
-
- Intervals::iterator intA = r2iA->second;
- Intervals::iterator intB = r2iB->second;
-
- // both A and B are virtual registers
- if (MRegisterInfo::isVirtualRegister(intA->reg) &&
- MRegisterInfo::isVirtualRegister(intB->reg)) {
-
- const TargetRegisterClass *rcA, *rcB;
- rcA = mf_->getSSARegMap()->getRegClass(intA->reg);
- rcB = mf_->getSSARegMap()->getRegClass(intB->reg);
- // if they are not of the same register class we continue
- if (rcA != rcB)
- continue;
-
- // if their intervals do not overlap we join them
- if (!intB->overlaps(*intA)) {
- intA->join(*intB);
- r2iB->second = r2iA->second;
- r2rMap_.insert(std::make_pair(intB->reg, intA->reg));
- intervals_.erase(intB);
- }
- } else if (MRegisterInfo::isPhysicalRegister(intA->reg) ^
- MRegisterInfo::isPhysicalRegister(intB->reg)) {
- if (MRegisterInfo::isPhysicalRegister(intB->reg)) {
- std::swap(regA, regB);
- std::swap(intA, intB);
- std::swap(r2iA, r2iB);
- }
+ // if their intervals do not overlap we join them
+ if (!intB->overlaps(*intA)) {
+ intA->join(*intB);
+ r2iB->second = r2iA->second;
+ r2rMap_.insert(std::make_pair(intB->reg, intA->reg));
+ intervals_.erase(intB);
+ }
+ } else if (MRegisterInfo::isPhysicalRegister(intA->reg) ^
+ MRegisterInfo::isPhysicalRegister(intB->reg)) {
+ if (MRegisterInfo::isPhysicalRegister(intB->reg)) {
+ std::swap(regA, regB);
+ std::swap(intA, intB);
+ std::swap(r2iA, r2iB);
+ }
- assert(MRegisterInfo::isPhysicalRegister(intA->reg) &&
- MRegisterInfo::isVirtualRegister(intB->reg) &&
- "A must be physical and B must be virtual");
-
- const TargetRegisterClass *rcA, *rcB;
- rcA = mri_->getRegClass(intA->reg);
- rcB = mf_->getSSARegMap()->getRegClass(intB->reg);
- // if they are not of the same register class we continue
- if (rcA != rcB)
- continue;
-
- if (!intA->overlaps(*intB) &&
- !overlapsAliases(*intA, *intB)) {
- intA->join(*intB);
- r2iB->second = r2iA->second;
- r2rMap_.insert(std::make_pair(intB->reg, intA->reg));
- intervals_.erase(intB);
- }
+ assert(MRegisterInfo::isPhysicalRegister(intA->reg) &&
+ MRegisterInfo::isVirtualRegister(intB->reg) &&
+ "A must be physical and B must be virtual");
+
+ const TargetRegisterClass *rcA, *rcB;
+ rcA = mri_->getRegClass(intA->reg);
+ rcB = mf_->getSSARegMap()->getRegClass(intB->reg);
+ // if they are not of the same register class we continue
+ if (rcA != rcB)
+ continue;
+
+ if (!intA->overlaps(*intB) &&
+ !overlapsAliases(*intA, *intB)) {
+ intA->join(*intB);
+ r2iB->second = r2iA->second;
+ r2rMap_.insert(std::make_pair(intB->reg, intA->reg));
+ intervals_.erase(intB);
}
}
}
}
}
+void LiveIntervals::joinIntervals()
+{
+ DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n");
+
+ for (MachineFunction::iterator I = mf_->begin(), E = mf_->end();
+ I != E; ++I)
+ joinIntervalsInMachineBB(I);
+}
+
bool LiveIntervals::overlapsAliases(const LiveInterval& lhs,
const LiveInterval& rhs) const
{