From 26bfc08b80c904c71487ac1ab49a8b3a15a8d3e9 Mon Sep 17 00:00:00 2001 From: Alkis Evlogimenos Date: Sun, 28 Dec 2003 17:58:18 +0000 Subject: 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 --- lib/CodeGen/RegAllocLinearScan.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/RegAllocLinearScan.cpp') diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp index a804e1aa86..e2c1a18b44 100644 --- a/lib/CodeGen/RegAllocLinearScan.cpp +++ b/lib/CodeGen/RegAllocLinearScan.cpp @@ -615,8 +615,19 @@ bool RA::physRegAvailable(unsigned physReg) unsigned RA::getFreePhysReg(Intervals::const_iterator cur) { DEBUG(std::cerr << "\t\tgetting free physical register: "); - const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(cur->reg); + + if (unsigned reg = cur->hint) { + if (reg >= MRegisterInfo::FirstVirtualRegister && + v2pMap_.find(reg) != v2pMap_.end()) + reg = v2pMap_[reg]; + if (reg && reg < MRegisterInfo::FirstVirtualRegister && + mri_->getRegClass(reg) == rc && !regUse_[reg]) { + DEBUG(std::cerr << mri_->getName(reg) << '\n'); + return reg; + } + } + for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_); i != rc->allocation_order_end(*mf_); ++i) { unsigned reg = *i; -- cgit v1.2.3-18-g5258