diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-02-19 21:49:54 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-02-19 21:49:54 +0000 |
commit | f7ed82da1011dc74cfbac0a65b7295ca0d4473d3 (patch) | |
tree | 61c2d44fc7362e01cd1ccf15fecb925b1ee359c8 /llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | |
parent | d5cfe7d0040ae9ca32c22bb388faa5503c123880 (diff) | |
download | bcm5719-llvm-f7ed82da1011dc74cfbac0a65b7295ca0d4473d3.tar.gz bcm5719-llvm-f7ed82da1011dc74cfbac0a65b7295ca0d4473d3.zip |
Re-apply my liveintervalanalysis changes. Now with PR1207 fixes.
llvm-svn: 34428
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp index 3370c362f98..7553634066e 100644 --- a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp @@ -34,6 +34,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/MathExtras.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include <cstdlib> using namespace llvm; @@ -338,6 +339,35 @@ PPCRegisterInfo::getCalleeSavedRegClasses() const { Darwin32_CalleeSavedRegClasses; } +// needsFP - Return true if the specified function should have a dedicated frame +// pointer register. This is true if the function has variable sized allocas or +// if frame pointer elimination is disabled. +// +static bool needsFP(const MachineFunction &MF) { + const MachineFrameInfo *MFI = MF.getFrameInfo(); + return NoFramePointerElim || MFI->hasVarSizedObjects(); +} + +BitVector PPCRegisterInfo::getReservedRegs(const MachineFunction &MF) const { + BitVector Reserved(getNumRegs()); + Reserved.set(PPC::R0); + Reserved.set(PPC::R1); + Reserved.set(PPC::LR); + // In Linux, r2 is reserved for the OS. + if (!Subtarget.isDarwin()) + Reserved.set(PPC::R2); + // On PPC64, r13 is the thread pointer. Never allocate this register. + // Note that this is overconservative, as it also prevents allocation of + // R31 when the FP is not needed. + if (Subtarget.isPPC64()) { + Reserved.set(PPC::R13); + Reserved.set(PPC::R31); + } + if (needsFP(MF)) + Reserved.set(PPC::R31); + return Reserved; +} + /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into /// copy instructions, turning them into load/store instructions. MachineInstr *PPCRegisterInfo::foldMemoryOperand(MachineInstr *MI, @@ -398,15 +428,6 @@ MachineInstr *PPCRegisterInfo::foldMemoryOperand(MachineInstr *MI, // Stack Frame Processing methods //===----------------------------------------------------------------------===// -// needsFP - Return true if the specified function should have a dedicated frame -// pointer register. This is true if the function has variable sized allocas or -// if frame pointer elimination is disabled. -// -static bool needsFP(const MachineFunction &MF) { - const MachineFrameInfo *MFI = MF.getFrameInfo(); - return NoFramePointerElim || MFI->hasVarSizedObjects(); -} - // hasFP - Return true if the specified function actually has a dedicated frame // pointer register. This is true if the function needs a frame pointer and has // a non-zero stack size. |