summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegisterClassInfo.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-08-05 21:28:14 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-08-05 21:28:14 +0000
commitf39031b360f135ece3bdc86151804dd1f3f51733 (patch)
treea02e46268ed8a7ce01105399a1e24363f86e9de6 /lib/CodeGen/RegisterClassInfo.cpp
parent19dec207fcc0f04902b7f097b7771ba7abba43fb (diff)
downloadllvm-f39031b360f135ece3bdc86151804dd1f3f51733.tar.gz
llvm-f39031b360f135ece3bdc86151804dd1f3f51733.tar.bz2
llvm-f39031b360f135ece3bdc86151804dd1f3f51733.tar.xz
Detect proper register sub-classes.
Some instructions require restricted register classes, but most of the time that doesn't affect register allocation. For example, some instructions don't work with the stack pointer, but that is a reserved register anyway. Sometimes it matters, GR32_ABCD only has 4 allocatable registers. For such a proper sub-class, the register allocator should try to enable register class inflation since that makes more registers available for allocation. Make sure only legal super-classes are considered. For example, tGPR is not a proper sub-class in Thumb mode, but in ARM mode it is. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136981 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegisterClassInfo.cpp')
-rw-r--r--lib/CodeGen/RegisterClassInfo.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/CodeGen/RegisterClassInfo.cpp b/lib/CodeGen/RegisterClassInfo.cpp
index 5a77e47bc5..786d279c2b 100644
--- a/lib/CodeGen/RegisterClassInfo.cpp
+++ b/lib/CodeGen/RegisterClassInfo.cpp
@@ -99,11 +99,16 @@ void RegisterClassInfo::compute(const TargetRegisterClass *RC) const {
// CSR aliases go after the volatile registers, preserve the target's order.
std::copy(CSRAlias.begin(), CSRAlias.end(), &RCI.Order[N]);
+ // Check if RC is a proper sub-class.
+ if (const TargetRegisterClass *Super = TRI->getLargestLegalSuperClass(RC))
+ if (Super != RC && getNumAllocatableRegs(Super) > RCI.NumRegs)
+ RCI.ProperSubClass = true;
+
DEBUG({
dbgs() << "AllocationOrder(" << RC->getName() << ") = [";
for (unsigned I = 0; I != RCI.NumRegs; ++I)
dbgs() << ' ' << PrintReg(RCI.Order[I], TRI);
- dbgs() << " ]\n";
+ dbgs() << (RCI.ProperSubClass ? " ] (sub-class)\n" : " ]\n");
});
// RCI is now up-to-date.