summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/RegAllocGreedy.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-08 22:57:16 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-08 22:57:16 +0000
commiteaa650a945643fe2e22d813d56efbea290d73af6 (patch)
tree17bbcc31e1022bba5fa7f3ecf4fa13f0fe559320 /llvm/lib/CodeGen/RegAllocGreedy.cpp
parent663e4ce357ea2eace958df902c9dc63de7b8638f (diff)
downloadbcm5719-llvm-eaa650a945643fe2e22d813d56efbea290d73af6.tar.gz
bcm5719-llvm-eaa650a945643fe2e22d813d56efbea290d73af6.zip
Implement very primitive hinting support in RegAllocGreedy.
The hint is simply tried first and then forgotten if it couldn't be allocated immediately. llvm-svn: 121306
Diffstat (limited to 'llvm/lib/CodeGen/RegAllocGreedy.cpp')
-rw-r--r--llvm/lib/CodeGen/RegAllocGreedy.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index 5f2be811aa6..c88d474315e 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -70,7 +70,7 @@ public:
virtual Spiller &spiller() { return *SpillerInstance; }
- virtual float getPriority(LiveInterval *LI) { return LI->weight; }
+ virtual float getPriority(LiveInterval *LI);
virtual unsigned selectOrSplit(LiveInterval &VirtReg,
SmallVectorImpl<LiveInterval*> &SplitVRegs);
@@ -126,6 +126,22 @@ void RAGreedy::releaseMemory() {
RegAllocBase::releaseMemory();
}
+float RAGreedy::getPriority(LiveInterval *LI) {
+ float Priority = LI->weight;
+
+ // Prioritize hinted registers so they are allocated first.
+ std::pair<unsigned, unsigned> Hint;
+ if (Hint.first || Hint.second) {
+ // The hint can be target specific, a virtual register, or a physreg.
+ Priority *= 2;
+
+ // Prefer physreg hints above anything else.
+ if (Hint.first == 0 && TargetRegisterInfo::isPhysicalRegister(Hint.second))
+ Priority *= 2;
+ }
+ return Priority;
+}
+
unsigned RAGreedy::selectOrSplit(LiveInterval &VirtReg,
SmallVectorImpl<LiveInterval*> &SplitVRegs) {
// Populate a list of physical register spill candidates.
@@ -135,6 +151,14 @@ unsigned RAGreedy::selectOrSplit(LiveInterval &VirtReg,
const TargetRegisterClass *TRC = MRI->getRegClass(VirtReg.reg);
DEBUG(dbgs() << "RegClass: " << TRC->getName() << ' ');
+ // Preferred physical register computed from hints.
+ unsigned Hint = VRM->getRegAllocPref(VirtReg.reg);
+
+ // Try a hinted allocation.
+ if (Hint && !ReservedRegs.test(Hint) && TRC->contains(Hint) &&
+ checkPhysRegInterference(VirtReg, Hint) == 0)
+ return Hint;
+
for (TargetRegisterClass::iterator I = TRC->allocation_order_begin(*MF),
E = TRC->allocation_order_end(*MF);
I != E; ++I) {
OpenPOWER on IntegriCloud