[llvm-commits] [llvm] r169179 - in /llvm/trunk: include/llvm/CodeGen/VirtRegMap.h lib/CodeGen/RegAllocGreedy.cpp lib/CodeGen/VirtRegMap.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Mon Dec 3 15:23:50 PST 2012
Author: stoklund
Date: Mon Dec 3 17:23:50 2012
New Revision: 169179
URL: http://llvm.org/viewvc/llvm-project?rev=169179&view=rev
Log:
Add VirtRegMap::hasKnownPreference().
Virtual registers with a known preferred register are prioritized by
RAGreedy. This function makes the condition explicit without depending
on getRegAllocPref().
Modified:
llvm/trunk/include/llvm/CodeGen/VirtRegMap.h
llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
llvm/trunk/lib/CodeGen/VirtRegMap.cpp
Modified: llvm/trunk/include/llvm/CodeGen/VirtRegMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/VirtRegMap.h?rev=169179&r1=169178&r2=169179&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/VirtRegMap.h (original)
+++ llvm/trunk/include/llvm/CodeGen/VirtRegMap.h Mon Dec 3 17:23:50 2012
@@ -134,6 +134,11 @@
return getPhys(VirtReg) == getRegAllocPref(VirtReg);
}
+ /// @brief returns true if VirtReg has a known preferred register.
+ /// This returns false if VirtReg has a preference that is a virtual
+ /// register that hasn't been assigned yet.
+ bool hasKnownPreference(unsigned VirtReg);
+
/// @brief records virtReg is a split live interval from SReg.
void setIsSplitFromReg(unsigned virtReg, unsigned SReg) {
Virt2SplitMap[virtReg] = SReg;
Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=169179&r1=169178&r2=169179&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Mon Dec 3 17:23:50 2012
@@ -413,7 +413,7 @@
Prio = (1u << 31) + Size;
// Boost ranges that have a physical register hint.
- if (TargetRegisterInfo::isPhysicalRegister(VRM->getRegAllocPref(Reg)))
+ if (VRM->hasKnownPreference(Reg))
Prio |= (1u << 30);
}
Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=169179&r1=169178&r2=169179&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original)
+++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Mon Dec 3 17:23:50 2012
@@ -88,6 +88,15 @@
return TRI->ResolveRegAllocHint(Hint.first, physReg, *MF);
}
+bool VirtRegMap::hasKnownPreference(unsigned VirtReg) {
+ std::pair<unsigned, unsigned> Hint = MRI->getRegAllocationHint(VirtReg);
+ if (TargetRegisterInfo::isPhysicalRegister(Hint.second))
+ return true;
+ if (TargetRegisterInfo::isVirtualRegister(Hint.second))
+ return hasPhys(Hint.second);
+ return false;
+}
+
int VirtRegMap::assignVirt2StackSlot(unsigned virtReg) {
assert(TargetRegisterInfo::isVirtualRegister(virtReg));
assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT &&
More information about the llvm-commits
mailing list