typedef DenseMap<unsigned, LiveInterval*> Reg2IntervalMap;
Reg2IntervalMap r2iMap_;
- /// phiJoinCopies - Copy instructions which are PHI joins.
- SmallVector<MachineInstr*, 16> phiJoinCopies;
-
/// allocatableRegs_ - A bit vector of allocatable registers.
BitVector allocatableRegs_;
return (isDef + isUse) * powf(10.0F, (float)loopDepth);
}
+ // After summing the spill weights of all defs and uses, the final weight
+ // should be normalized, dividing the weight of the interval by its size.
+ // This encourages spilling of intervals that are large and have few uses,
+ // and discourages spilling of small intervals with many uses.
+ void normalizeSpillWeight(LiveInterval &li) {
+ li.weight /= getApproximateInstructionCount(li) + 25;
+ }
+
typedef Reg2IntervalMap::iterator iterator;
typedef Reg2IntervalMap::const_iterator const_iterator;
const_iterator begin() const { return r2iMap_.begin(); }
return (unsigned)(IntervalPercentage * indexes_->getFunctionSize());
}
- /// conflictsWithPhysRegDef - Returns true if the specified register
- /// is defined during the duration of the specified interval.
- bool conflictsWithPhysRegDef(const LiveInterval &li, VirtRegMap &vrm,
- unsigned reg);
+ /// conflictsWithPhysReg - Returns true if the specified register is used or
+ /// defined during the duration of the specified interval. Copies to and
+ /// from li.reg are allowed. This method is only able to analyze simple
+ /// ranges that stay within a single basic block. Anything else is
+ /// considered a conflict.
+ bool conflictsWithPhysReg(const LiveInterval &li, VirtRegMap &vrm,
+ unsigned reg);
/// conflictsWithPhysRegRef - Similar to conflictsWithPhysRegRef except
/// it can check use as well.
return indexes_->getMBBFromIndex(index);
}
- bool hasGapBeforeInstr(SlotIndex index) {
- return indexes_->hasGapBeforeInstr(index);
- }
-
- bool hasGapAfterInstr(SlotIndex index) {
- return indexes_->hasGapAfterInstr(index);
+ SlotIndex getMBBTerminatorGap(const MachineBasicBlock *mbb) {
+ return indexes_->getTerminatorGap(mbb);
}
- SlotIndex findGapBeforeInstr(SlotIndex index, bool furthest = false) {
- return indexes_->findGapBeforeInstr(index, furthest);
- }
-
- void InsertMachineInstrInMaps(MachineInstr *MI, SlotIndex Index) {
- indexes_->insertMachineInstrInMaps(MI, Index);
+ SlotIndex InsertMachineInstrInMaps(MachineInstr *MI) {
+ return indexes_->insertMachineInstrInMaps(MI);
}
void RemoveMachineInstrFromMaps(MachineInstr *MI) {
}
void renumber() {
- indexes_->renumber();
+ indexes_->renumberIndexes();
}
BumpPtrAllocator& getVNInfoAllocator() { return VNInfoAllocator; }
/// computeIntervals - Compute live intervals.
void computeIntervals();
- bool isSafeAndProfitableToCoalesce(LiveInterval &DstInt,
- LiveInterval &SrcInt,
- SmallVector<MachineInstr*,16> &IdentCopies,
- SmallVector<MachineInstr*,16> &OtherCopies);
-
- void performEarlyCoalescing();
-
/// handleRegisterDef - update intervals for a register def
/// (calls handlePhysicalRegisterDef and
/// handleVirtualRegisterDef)
DenseMap<unsigned,unsigned> &MBBVRegsMap,
std::vector<LiveInterval*> &NewLIs);
+ // Normalize the spill weight of all the intervals in NewLIs.
+ void normalizeSpillWeights(std::vector<LiveInterval*> &NewLIs);
+
static LiveInterval* createInterval(unsigned Reg);
void printInstrs(raw_ostream &O) const;