diff options
author | Owen Anderson <resistor@mac.com> | 2008-07-22 22:46:49 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-07-22 22:46:49 +0000 |
commit | a1566f2e12ce87a5bca30bc0189a0cdbb40136a4 (patch) | |
tree | fecdd6cd2ded8963a4015584d9de5f7f4329a765 /include/llvm/CodeGen | |
parent | 38bcec13e89b33fd6b0553ec47667744c54fbb7b (diff) |
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
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r-- | include/llvm/CodeGen/LiveIntervalAnalysis.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index 8efcbee290..ebbcf63b70 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -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 |