[llvm-commits] [llvm] r44699 - in /llvm/trunk/lib/Target/PowerPC: PPCMachineFunctionInfo.h PPCRegisterInfo.cpp PPCRegisterInfo.h
Chris Lattner
sabre at nondot.org
Fri Dec 7 22:39:12 PST 2007
Author: lattner
Date: Sat Dec 8 00:39:11 2007
New Revision: 44699
URL: http://llvm.org/viewvc/llvm-project?rev=44699&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Target/PowerPC/PPCMachineFunctionInfo.h
llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp
llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.h
Modified: llvm/trunk/lib/Target/PowerPC/PPCMachineFunctionInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCMachineFunctionInfo.h?rev=44699&r1=44698&r2=44699&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCMachineFunctionInfo.h (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCMachineFunctionInfo.h Sat Dec 8 00:39:11 2007
@@ -39,8 +39,12 @@
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; }
};
Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp?rev=44699&r1=44698&r2=44699&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Sat Dec 8 00:39:11 2007
@@ -645,11 +645,13 @@
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 @@
// 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 @@
// 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;
Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.h?rev=44699&r1=44698&r2=44699&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.h (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.h Sat Dec 8 00:39:11 2007
@@ -96,10 +96,6 @@
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;
More information about the llvm-commits
mailing list