aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-08 06:39:11 +0000
committerChris Lattner <sabre@nondot.org>2007-12-08 06:39:11 +0000
commit73944fb22270697e75408cba52cca276be371a1f (patch)
treee6ebc214c149c6da74c62763df7166a3761f65a0
parentedfd10de873a424a8516a6dbf5feb8168efc462d (diff)
downloadexternal_llvm-73944fb22270697e75408cba52cca276be371a1f.zip
external_llvm-73944fb22270697e75408cba52cca276be371a1f.tar.gz
external_llvm-73944fb22270697e75408cba52cca276be371a1f.tar.bz2
refactor some code to avoid overloading the name 'usesLR' in
different places to mean different things. Document what the one in PPCFunctionInfo means and when it is valid. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44699 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/PowerPC/PPCMachineFunctionInfo.h6
-rw-r--r--lib/Target/PowerPC/PPCRegisterInfo.cpp16
-rw-r--r--lib/Target/PowerPC/PPCRegisterInfo.h4
3 files changed, 14 insertions, 12 deletions
diff --git a/lib/Target/PowerPC/PPCMachineFunctionInfo.h b/lib/Target/PowerPC/PPCMachineFunctionInfo.h
index e227456..bf1fea2 100644
--- a/lib/Target/PowerPC/PPCMachineFunctionInfo.h
+++ b/lib/Target/PowerPC/PPCMachineFunctionInfo.h
@@ -39,8 +39,12 @@ public:
int getFramePointerSaveIndex() const { return FramePointerSaveIndex; }
void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; }
+ /// UsesLR - This is set when the prolog/epilog inserter does its initial scan
+ /// of the function, it is true if the LR/LR8 register is ever explicitly
+ /// accessed/clobbered in the machine function (e.g. by calls and movpctolr,
+ /// which is used in PIC generation).
void setUsesLR(bool U) { UsesLR = U; }
- bool usesLR() { return UsesLR; }
+ bool usesLR() const { return UsesLR; }
};
diff --git a/lib/Target/PowerPC/PPCRegisterInfo.cpp b/lib/Target/PowerPC/PPCRegisterInfo.cpp
index f93c2ce..679ca2e 100644
--- a/lib/Target/PowerPC/PPCRegisterInfo.cpp
+++ b/lib/Target/PowerPC/PPCRegisterInfo.cpp
@@ -645,11 +645,13 @@ bool PPCRegisterInfo::hasFP(const MachineFunction &MF) const {
return MFI->getStackSize() && needsFP(MF);
}
-/// usesLR - Returns if the link registers (LR) has been used in the function.
-///
-bool PPCRegisterInfo::usesLR(MachineFunction &MF) const {
- PPCFunctionInfo *FI = MF.getInfo<PPCFunctionInfo>();
- return FI->usesLR();
+/// MustSaveLR - Return true if this function requires that we save the LR
+/// register onto the stack in the prolog and restore it in the epilog of the function.
+static bool MustSaveLR(const MachineFunction &MF) {
+ return MF.getInfo<PPCFunctionInfo>()->usesLR() ||
+ // FIXME: Anything that has a call should clobber the LR register,
+ // isn't this redundant??
+ MF.getFrameInfo()->hasCalls();
}
void PPCRegisterInfo::
@@ -1062,7 +1064,7 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
// Get operating system
bool IsMachoABI = Subtarget.isMachoABI();
// Check if the link register (LR) has been used.
- bool UsesLR = MFI->hasCalls() || usesLR(MF);
+ bool UsesLR = MustSaveLR(MF);
// Do we have a frame pointer for this function?
bool HasFP = hasFP(MF) && FrameSize;
@@ -1226,7 +1228,7 @@ void PPCRegisterInfo::emitEpilogue(MachineFunction &MF,
// Get operating system
bool IsMachoABI = Subtarget.isMachoABI();
// Check if the link register (LR) has been used.
- bool UsesLR = MFI->hasCalls() || usesLR(MF);
+ bool UsesLR = MustSaveLR(MF);
// Do we have a frame pointer for this function?
bool HasFP = hasFP(MF) && FrameSize;
diff --git a/lib/Target/PowerPC/PPCRegisterInfo.h b/lib/Target/PowerPC/PPCRegisterInfo.h
index 2106c6e..b4a0415 100644
--- a/lib/Target/PowerPC/PPCRegisterInfo.h
+++ b/lib/Target/PowerPC/PPCRegisterInfo.h
@@ -96,10 +96,6 @@ public:
MachineBasicBlock &MBB,
MachineBasicBlock::iterator I) const;
- /// usesLR - Returns if the link registers (LR) has been used in the function.
- ///
- bool usesLR(MachineFunction &MF) const;
-
void lowerDynamicAlloc(MachineBasicBlock::iterator II) const;
void eliminateFrameIndex(MachineBasicBlock::iterator II,
int SPAdj, RegScavenger *RS = NULL) const;