diff options
| author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-06-06 21:02:04 +0000 |
|---|---|---|
| committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-06-06 21:02:04 +0000 |
| commit | 0cde8eb9e25e91928a12357ef6d742b34c8ad001 (patch) | |
| tree | a7844989cb13c09de8be09153b8645afcaafaf3f /llvm/lib/CodeGen/AllocationOrder.h | |
| parent | c807fa5687931184c04c7aca2cacde7de51559a3 (diff) | |
| download | bcm5719-llvm-0cde8eb9e25e91928a12357ef6d742b34c8ad001.tar.gz bcm5719-llvm-0cde8eb9e25e91928a12357ef6d742b34c8ad001.zip | |
Get allocation orders from RegisterClassInfo when possible.
Only target-dependent hints require callbacks. The RCI allocation order
has CSR aliases last according to their order of appearance in the
getCalleeSavedRegs list. This can depend on the calling convention.
This way, AllocationOrder::next doesn't have to check for reserved
registers, and CSRs are always allocated last, even with weird calling
conventions.
llvm-svn: 132690
Diffstat (limited to 'llvm/lib/CodeGen/AllocationOrder.h')
| -rw-r--r-- | llvm/lib/CodeGen/AllocationOrder.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AllocationOrder.h b/llvm/lib/CodeGen/AllocationOrder.h index 4742e8e1968..d1e48a1f2e9 100644 --- a/llvm/lib/CodeGen/AllocationOrder.h +++ b/llvm/lib/CodeGen/AllocationOrder.h @@ -28,6 +28,7 @@ class AllocationOrder { const unsigned *Pos; const RegisterClassInfo &RCI; unsigned Hint; + bool OwnedBegin; public: /// AllocationOrder - Create a new AllocationOrder for VirtReg. @@ -39,10 +40,26 @@ public: const VirtRegMap &VRM, const RegisterClassInfo &RegClassInfo); + ~AllocationOrder(); + /// next - Return the next physical register in the allocation order, or 0. /// It is safe to call next again after it returned 0. /// It will keep returning 0 until rewind() is called. - unsigned next(); + unsigned next() { + // First take the hint. + if (!Pos) { + Pos = Begin; + if (Hint) + return Hint; + } + // Then look at the order from TRI. + while (Pos != End) { + unsigned Reg = *Pos++; + if (Reg != Hint) + return Reg; + } + return 0; + } /// rewind - Start over from the beginning. void rewind() { Pos = 0; } |

