aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveIntervalAnalysis.cpp
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2003-12-28 17:58:18 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2003-12-28 17:58:18 +0000
commit26bfc08b80c904c71487ac1ab49a8b3a15a8d3e9 (patch)
tree9c43be37aababc599020499bb3d87a73e069d472 /lib/CodeGen/LiveIntervalAnalysis.cpp
parent5e30002af70ef09a42cac155d9196f7f0f3b1695 (diff)
Add coalescing to register allocator. A hint is added to each interval
which denotes the register we would like to be assigned to (virtual or physical). In register allocation, if this hint exists and we can map it to a physical register (it is either a physical register or it is a virtual register that already got assigned to a physical one) we use that register if it is available instead of a random one in the free pool. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10634 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index b34a65bc64..4d0916046a 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -108,6 +108,7 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
// compute spill weights
const LoopInfo& loopInfo = getAnalysis<LoopInfo>();
+ const TargetInstrInfo& tii = tm_->getInstrInfo();
for (MbbIndex2MbbMap::iterator
it = mbbi2mbbMap_.begin(), itEnd = mbbi2mbbMap_.end();
@@ -130,6 +131,21 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
assert(r2iit != r2iMap_.end());
intervals_[r2iit->second].weight += pow(10.0F, loopDepth);
}
+
+ // add hints for coalescing
+ unsigned src, dst;
+ if (tii.isMoveInstr(*instr, src, dst)) {
+ if (src >= MRegisterInfo::FirstVirtualRegister) {
+ Reg2IntervalMap::iterator r2iit = r2iMap_.find(src);
+ assert(r2iit != r2iMap_.end());
+ intervals_[r2iit->second].hint = dst;
+ }
+ if (dst >= MRegisterInfo::FirstVirtualRegister) {
+ Reg2IntervalMap::iterator r2iit = r2iMap_.find(dst);
+ assert(r2iit != r2iMap_.end());
+ intervals_[r2iit->second].hint = src;
+ }
+ }
}
}
@@ -329,7 +345,7 @@ void LiveIntervals::computeIntervals()
}
LiveIntervals::Interval::Interval(unsigned r)
- : reg(r),
+ : reg(r), hint(0),
weight((r < MRegisterInfo::FirstVirtualRegister ?
std::numeric_limits<float>::max() : 0.0F))
{