Change the heuristics used in the coalescer, register allocator, and within

live intervals itself to use an instruction count approximation that is 
not affected by inserting empty indices.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53937 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson
2008-07-22 22:46:49 +00:00
parent 38bcec13e8
commit a1566f2e12
5 changed files with 29 additions and 14 deletions

View File

@ -75,6 +75,9 @@ namespace llvm {
/// and MBB id.
std::vector<IdxMBBPair> Idx2MBBMap;
/// FunctionSize - The number of instructions present in the function
uint64_t FunctionSize;
typedef std::map<MachineInstr*, unsigned> Mi2IndexMap;
Mi2IndexMap mi2iMap_;
@ -169,11 +172,18 @@ namespace llvm {
return MBB2IdxMap[MBBNo].second;
}
/// getIntervalSize - get the size of an interval in "units,"
/// getScaledIntervalSize - get the size of an interval in "units,"
/// where every function is composed of one thousand units. This
/// measure scales properly with empty index slots in the function.
unsigned getScaledIntervalSize(LiveInterval& I) const {
return (1000 / InstrSlots::NUM * I.getSize()) / i2miMap_.size();
double getScaledIntervalSize(LiveInterval& I) {
return (1000.0 / InstrSlots::NUM * I.getSize()) / i2miMap_.size();
}
/// getApproximateInstructionCount - computes an estimate of the number
/// of instructions in a given LiveInterval.
unsigned getApproximateInstructionCount(LiveInterval& I) {
double IntervalPercentage = getScaledIntervalSize(I) / 1000.0;
return IntervalPercentage * FunctionSize;
}
/// getMBBFromIndex - given an index in any instruction of an