diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2010-11-20 15:59:32 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2010-11-20 15:59:32 +0000 |
commit | 82f58740c76b42af8370247b23677a0318f6dde8 (patch) | |
tree | 344788376da3e3154c50a9ef3211b12eafc1e289 /lib/Target/TargetFrameInfo.cpp | |
parent | 3ca136312abe3c41f3422e9de280b7be0dc65362 (diff) |
Move some more hooks to TargetFrameInfo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetFrameInfo.cpp')
-rw-r--r-- | lib/Target/TargetFrameInfo.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Target/TargetFrameInfo.cpp b/lib/Target/TargetFrameInfo.cpp index ff9b89a6f4..dad51b9560 100644 --- a/lib/Target/TargetFrameInfo.cpp +++ b/lib/Target/TargetFrameInfo.cpp @@ -11,7 +11,12 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Codegen/MachineFrameInfo.h" +#include "llvm/Codegen/MachineFunction.h" #include "llvm/Target/TargetFrameInfo.h" +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetRegisterInfo.h" + #include <cstdlib> using namespace llvm; @@ -24,3 +29,24 @@ void TargetFrameInfo::getInitialFrameState(std::vector<MachineMove> &Moves) const { // Default is to do nothing. } + +/// getFrameIndexOffset - Returns the displacement from the frame register to +/// the stack frame of the specified index. This is the default implementation +/// which is overridden for some targets. +int TargetFrameInfo::getFrameIndexOffset(const MachineFunction &MF, + int FI) const { + const MachineFrameInfo *MFI = MF.getFrameInfo(); + return MFI->getObjectOffset(FI) + MFI->getStackSize() - + getOffsetOfLocalArea() + MFI->getOffsetAdjustment(); +} + +int TargetFrameInfo::getFrameIndexReference(const MachineFunction &MF, int FI, + unsigned &FrameReg) const { + const TargetRegisterInfo *RI = MF.getTarget().getRegisterInfo(); + + // By default, assume all frame indices are referenced via whatever + // getFrameRegister() says. The target can override this if it's doing + // something different. + FrameReg = RI->getFrameRegister(MF); + return getFrameIndexOffset(MF, FI); +} |