Removed static qualifier from a few index related methods. These methods may require a LiveIntervals instance in future.

llvm-svn: 81374
This commit is contained in:
Lang Hames 2009-09-09 20:14:17 +00:00
parent 3df0459149
commit 6b81770040
3 changed files with 31 additions and 31 deletions

View File

@ -104,26 +104,28 @@ namespace llvm {
static char ID; // Pass identification, replacement for typeid static char ID; // Pass identification, replacement for typeid
LiveIntervals() : MachineFunctionPass(&ID) {} LiveIntervals() : MachineFunctionPass(&ID) {}
static MachineInstrIndex getBaseIndex(MachineInstrIndex index) { MachineInstrIndex getBaseIndex(MachineInstrIndex index) {
return MachineInstrIndex(index, MachineInstrIndex::LOAD); return MachineInstrIndex(index, MachineInstrIndex::LOAD);
} }
static MachineInstrIndex getBoundaryIndex(MachineInstrIndex index) { MachineInstrIndex getBoundaryIndex(MachineInstrIndex index) {
return MachineInstrIndex(index, return MachineInstrIndex(index,
(MachineInstrIndex::Slot)(MachineInstrIndex::NUM - 1)); (MachineInstrIndex::Slot)(MachineInstrIndex::NUM - 1));
} }
static MachineInstrIndex getLoadIndex(MachineInstrIndex index) { MachineInstrIndex getLoadIndex(MachineInstrIndex index) {
return MachineInstrIndex(index, MachineInstrIndex::LOAD); return MachineInstrIndex(index, MachineInstrIndex::LOAD);
} }
static MachineInstrIndex getUseIndex(MachineInstrIndex index) { MachineInstrIndex getUseIndex(MachineInstrIndex index) {
return MachineInstrIndex(index, MachineInstrIndex::USE); return MachineInstrIndex(index, MachineInstrIndex::USE);
} }
static MachineInstrIndex getDefIndex(MachineInstrIndex index) { MachineInstrIndex getDefIndex(MachineInstrIndex index) {
return MachineInstrIndex(index, MachineInstrIndex::DEF); return MachineInstrIndex(index, MachineInstrIndex::DEF);
} }
static MachineInstrIndex getStoreIndex(MachineInstrIndex index) { MachineInstrIndex getStoreIndex(MachineInstrIndex index) {
return MachineInstrIndex(index, MachineInstrIndex::STORE); return MachineInstrIndex(index, MachineInstrIndex::STORE);
} }
MachineInstrIndex getNextSlot(MachineInstrIndex m) const { MachineInstrIndex getNextSlot(MachineInstrIndex m) const {
return m.nextSlot(); return m.nextSlot();
} }

View File

@ -492,7 +492,7 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI,
// Once we've found it, extend its VNInfo to our instruction. // Once we've found it, extend its VNInfo to our instruction.
MachineInstrIndex DefIndex = LIs->getInstructionIndex(Walker); MachineInstrIndex DefIndex = LIs->getInstructionIndex(Walker);
DefIndex = LiveIntervals::getDefIndex(DefIndex); DefIndex = LIs->getDefIndex(DefIndex);
MachineInstrIndex EndIndex = LIs->getMBBEndIdx(MBB); MachineInstrIndex EndIndex = LIs->getMBBEndIdx(MBB);
RetVNI = NewVNs[Walker]; RetVNI = NewVNs[Walker];
@ -529,11 +529,11 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI,
} }
MachineInstrIndex UseIndex = LIs->getInstructionIndex(Walker); MachineInstrIndex UseIndex = LIs->getInstructionIndex(Walker);
UseIndex = LiveIntervals::getUseIndex(UseIndex); UseIndex = LIs->getUseIndex(UseIndex);
MachineInstrIndex EndIndex; MachineInstrIndex EndIndex;
if (IsIntraBlock) { if (IsIntraBlock) {
EndIndex = LIs->getInstructionIndex(UseI); EndIndex = LIs->getInstructionIndex(UseI);
EndIndex = LiveIntervals::getUseIndex(EndIndex); EndIndex = LIs->getUseIndex(EndIndex);
} else } else
EndIndex = LIs->getMBBEndIdx(MBB); EndIndex = LIs->getMBBEndIdx(MBB);
@ -589,12 +589,12 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI,
} }
MachineInstrIndex StartIndex = LIs->getInstructionIndex(Walker); MachineInstrIndex StartIndex = LIs->getInstructionIndex(Walker);
StartIndex = foundDef ? LiveIntervals::getDefIndex(StartIndex) : StartIndex = foundDef ? LIs->getDefIndex(StartIndex) :
LiveIntervals::getUseIndex(StartIndex); LIs->getUseIndex(StartIndex);
MachineInstrIndex EndIndex; MachineInstrIndex EndIndex;
if (IsIntraBlock) { if (IsIntraBlock) {
EndIndex = LIs->getInstructionIndex(UseI); EndIndex = LIs->getInstructionIndex(UseI);
EndIndex = LiveIntervals::getUseIndex(EndIndex); EndIndex = LIs->getUseIndex(EndIndex);
} else } else
EndIndex = LIs->getMBBEndIdx(MBB); EndIndex = LIs->getMBBEndIdx(MBB);
@ -694,7 +694,7 @@ PreAllocSplitting::PerformPHIConstructionFallBack(MachineBasicBlock::iterator Us
MachineInstrIndex EndIndex; MachineInstrIndex EndIndex;
if (IsIntraBlock) { if (IsIntraBlock) {
EndIndex = LIs->getInstructionIndex(UseI); EndIndex = LIs->getInstructionIndex(UseI);
EndIndex = LiveIntervals::getUseIndex(EndIndex); EndIndex = LIs->getUseIndex(EndIndex);
} else } else
EndIndex = LIs->getMBBEndIdx(MBB); EndIndex = LIs->getMBBEndIdx(MBB);
LI->addRange(LiveRange(StartIndex, LIs->getNextSlot(EndIndex), RetVNI)); LI->addRange(LiveRange(StartIndex, LIs->getNextSlot(EndIndex), RetVNI));
@ -734,7 +734,7 @@ void PreAllocSplitting::ReconstructLiveInterval(LiveInterval* LI) {
Defs[(*DI).getParent()].insert(&*DI); Defs[(*DI).getParent()].insert(&*DI);
MachineInstrIndex DefIdx = LIs->getInstructionIndex(&*DI); MachineInstrIndex DefIdx = LIs->getInstructionIndex(&*DI);
DefIdx = LiveIntervals::getDefIndex(DefIdx); DefIdx = LIs->getDefIndex(DefIdx);
assert(DI->getOpcode() != TargetInstrInfo::PHI && assert(DI->getOpcode() != TargetInstrInfo::PHI &&
"Following NewVN isPHIDef flag incorrect. Fix me!"); "Following NewVN isPHIDef flag incorrect. Fix me!");
@ -770,7 +770,7 @@ void PreAllocSplitting::ReconstructLiveInterval(LiveInterval* LI) {
for (MachineRegisterInfo::def_iterator DI = MRI->def_begin(LI->reg), for (MachineRegisterInfo::def_iterator DI = MRI->def_begin(LI->reg),
DE = MRI->def_end(); DI != DE; ++DI) { DE = MRI->def_end(); DI != DE; ++DI) {
MachineInstrIndex DefIdx = LIs->getInstructionIndex(&*DI); MachineInstrIndex DefIdx = LIs->getInstructionIndex(&*DI);
DefIdx = LiveIntervals::getDefIndex(DefIdx); DefIdx = LIs->getDefIndex(DefIdx);
if (LI->liveAt(DefIdx)) continue; if (LI->liveAt(DefIdx)) continue;
@ -815,8 +815,7 @@ void PreAllocSplitting::RenumberValno(VNInfo* VN) {
if (DefIdx == ~0U) continue; if (DefIdx == ~0U) continue;
if (MI->isRegTiedToUseOperand(DefIdx)) { if (MI->isRegTiedToUseOperand(DefIdx)) {
VNInfo* NextVN = VNInfo* NextVN =
CurrLI->findDefinedVNInfoForRegInt( CurrLI->findDefinedVNInfoForRegInt(LIs->getDefIndex(*KI));
LiveIntervals::getDefIndex(*KI));
if (NextVN == OldVN) continue; if (NextVN == OldVN) continue;
Stack.push_back(NextVN); Stack.push_back(NextVN);
} }
@ -850,8 +849,8 @@ void PreAllocSplitting::RenumberValno(VNInfo* VN) {
MachineOperand& MO = I.getOperand(); MachineOperand& MO = I.getOperand();
MachineInstrIndex InstrIdx = LIs->getInstructionIndex(&*I); MachineInstrIndex InstrIdx = LIs->getInstructionIndex(&*I);
if ((MO.isUse() && NewLI.liveAt(LiveIntervals::getUseIndex(InstrIdx))) || if ((MO.isUse() && NewLI.liveAt(LIs->getUseIndex(InstrIdx))) ||
(MO.isDef() && NewLI.liveAt(LiveIntervals::getDefIndex(InstrIdx)))) (MO.isDef() && NewLI.liveAt(LIs->getDefIndex(InstrIdx))))
OpsToChange.push_back(std::make_pair(&*I, I.getOperandNo())); OpsToChange.push_back(std::make_pair(&*I, I.getOperandNo()));
} }
@ -895,7 +894,7 @@ bool PreAllocSplitting::Rematerialize(unsigned VReg, VNInfo* ValNo,
ReconstructLiveInterval(CurrLI); ReconstructLiveInterval(CurrLI);
MachineInstrIndex RematIdx = LIs->getInstructionIndex(prior(RestorePt)); MachineInstrIndex RematIdx = LIs->getInstructionIndex(prior(RestorePt));
RematIdx = LiveIntervals::getDefIndex(RematIdx); RematIdx = LIs->getDefIndex(RematIdx);
RenumberValno(CurrLI->findDefinedVNInfoForRegInt(RematIdx)); RenumberValno(CurrLI->findDefinedVNInfoForRegInt(RematIdx));
++NumSplits; ++NumSplits;
@ -1154,7 +1153,7 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) {
if (!FoldedRestore) { if (!FoldedRestore) {
MachineInstrIndex RestoreIdx = LIs->getInstructionIndex(prior(RestorePt)); MachineInstrIndex RestoreIdx = LIs->getInstructionIndex(prior(RestorePt));
RestoreIdx = LiveIntervals::getDefIndex(RestoreIdx); RestoreIdx = LIs->getDefIndex(RestoreIdx);
RenumberValno(CurrLI->findDefinedVNInfoForRegInt(RestoreIdx)); RenumberValno(CurrLI->findDefinedVNInfoForRegInt(RestoreIdx));
} }
@ -1242,7 +1241,7 @@ bool PreAllocSplitting::removeDeadSpills(SmallPtrSet<LiveInterval*, 8>& split) {
for (MachineRegisterInfo::use_iterator UI = MRI->use_begin((*LI)->reg), for (MachineRegisterInfo::use_iterator UI = MRI->use_begin((*LI)->reg),
UE = MRI->use_end(); UI != UE; ++UI) { UE = MRI->use_end(); UI != UE; ++UI) {
MachineInstrIndex index = LIs->getInstructionIndex(&*UI); MachineInstrIndex index = LIs->getInstructionIndex(&*UI);
index = LiveIntervals::getUseIndex(index); index = LIs->getUseIndex(index);
const LiveRange* LR = (*LI)->getLiveRangeContaining(index); const LiveRange* LR = (*LI)->getLiveRangeContaining(index);
VNUseCount[LR->valno].insert(&*UI); VNUseCount[LR->valno].insert(&*UI);

View File

@ -785,15 +785,14 @@ void StrongPHIElimination::ScheduleCopies(MachineBasicBlock* MBB,
if (RegHandled.insert(I->first).second) { if (RegHandled.insert(I->first).second) {
LiveInterval& Int = LI.getOrCreateInterval(I->first); LiveInterval& Int = LI.getOrCreateInterval(I->first);
MachineInstrIndex instrIdx = LI.getInstructionIndex(I->second); MachineInstrIndex instrIdx = LI.getInstructionIndex(I->second);
if (Int.liveAt(LiveIntervals::getDefIndex(instrIdx))) if (Int.liveAt(LI.getDefIndex(instrIdx)))
Int.removeRange(LiveIntervals::getDefIndex(instrIdx), Int.removeRange(LI.getDefIndex(instrIdx),
LI.getNextSlot(LI.getMBBEndIdx(I->second->getParent())), LI.getNextSlot(LI.getMBBEndIdx(I->second->getParent())),
true); true);
LiveRange R = LI.addLiveRangeToEndOfBlock(I->first, I->second); LiveRange R = LI.addLiveRangeToEndOfBlock(I->first, I->second);
R.valno->setCopy(I->second); R.valno->setCopy(I->second);
R.valno->def = R.valno->def = LI.getDefIndex(LI.getInstructionIndex(I->second));
LiveIntervals::getDefIndex(LI.getInstructionIndex(I->second));
} }
} }
} }
@ -819,7 +818,7 @@ void StrongPHIElimination::InsertCopies(MachineDomTreeNode* MDTN,
// Remove the live range for the old vreg. // Remove the live range for the old vreg.
LiveInterval& OldInt = LI.getInterval(I->getOperand(i).getReg()); LiveInterval& OldInt = LI.getInterval(I->getOperand(i).getReg());
LiveInterval::iterator OldLR = OldInt.FindLiveRangeContaining( LiveInterval::iterator OldLR = OldInt.FindLiveRangeContaining(
LiveIntervals::getUseIndex(LI.getInstructionIndex(I))); LI.getUseIndex(LI.getInstructionIndex(I)));
if (OldLR != OldInt.end()) if (OldLR != OldInt.end())
OldInt.removeRange(*OldLR, true); OldInt.removeRange(*OldLR, true);
@ -832,7 +831,7 @@ void StrongPHIElimination::InsertCopies(MachineDomTreeNode* MDTN,
FirstVN->setHasPHIKill(false); FirstVN->setHasPHIKill(false);
if (I->getOperand(i).isKill()) if (I->getOperand(i).isKill())
FirstVN->addKill( FirstVN->addKill(
LiveIntervals::getUseIndex(LI.getInstructionIndex(I))); LI.getUseIndex(LI.getInstructionIndex(I)));
LiveRange LR (LI.getMBBStartIdx(I->getParent()), LiveRange LR (LI.getMBBStartIdx(I->getParent()),
LI.getNextSlot(LI.getUseIndex(LI.getInstructionIndex(I))), LI.getNextSlot(LI.getUseIndex(LI.getInstructionIndex(I))),
@ -970,14 +969,14 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
LiveInterval& Int = LI.getOrCreateInterval(I->first); LiveInterval& Int = LI.getOrCreateInterval(I->first);
MachineInstrIndex instrIdx = MachineInstrIndex instrIdx =
LI.getInstructionIndex(--SI->second->getFirstTerminator()); LI.getInstructionIndex(--SI->second->getFirstTerminator());
if (Int.liveAt(LiveIntervals::getDefIndex(instrIdx))) if (Int.liveAt(LI.getDefIndex(instrIdx)))
Int.removeRange(LiveIntervals::getDefIndex(instrIdx), Int.removeRange(LI.getDefIndex(instrIdx),
LI.getNextSlot(LI.getMBBEndIdx(SI->second)), true); LI.getNextSlot(LI.getMBBEndIdx(SI->second)), true);
LiveRange R = LI.addLiveRangeToEndOfBlock(I->first, LiveRange R = LI.addLiveRangeToEndOfBlock(I->first,
--SI->second->getFirstTerminator()); --SI->second->getFirstTerminator());
R.valno->setCopy(--SI->second->getFirstTerminator()); R.valno->setCopy(--SI->second->getFirstTerminator());
R.valno->def = LiveIntervals::getDefIndex(instrIdx); R.valno->def = LI.getDefIndex(instrIdx);
DEBUG(errs() << "Renaming failed: " << SI->first << " -> " DEBUG(errs() << "Renaming failed: " << SI->first << " -> "
<< I->first << "\n"); << I->first << "\n");