[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp PPCRegisterInfo.h
Evan Cheng
evan.cheng at apple.com
Mon Feb 19 13:50:35 PST 2007
Changes in directory llvm/lib/Target/PowerPC:
PPCRegisterInfo.cpp updated: 1.107 -> 1.108
PPCRegisterInfo.h updated: 1.26 -> 1.27
---
Log message:
Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes.
---
Diffs of the changes: (+32 -9)
PPCRegisterInfo.cpp | 39 ++++++++++++++++++++++++++++++---------
PPCRegisterInfo.h | 2 ++
2 files changed, 32 insertions(+), 9 deletions(-)
Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.107 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.108
--- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.107 Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Mon Feb 19 15:49:54 2007
@@ -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 @@
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 @@
// 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.
Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.h
diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.26 llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.27
--- llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.26 Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/PowerPC/PPCRegisterInfo.h Mon Feb 19 15:49:54 2007
@@ -58,6 +58,8 @@
const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
+ BitVector getReservedRegs(const MachineFunction &MF) const;
+
/// targetHandlesStackFrameRounding - Returns true if the target is
/// responsible for rounding up the stack frame (probably at emitPrologue
/// time).
More information about the llvm-commits
mailing list