1 //===----- TargetFrameLoweringImpl.cpp - Implement target frame interface --==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Implements the layout of a stack frame on the target machine.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Target/TargetFrameLowering.h"
15 #include "llvm/CodeGen/MachineFrameInfo.h"
16 #include "llvm/CodeGen/MachineFunction.h"
17 #include "llvm/Target/TargetMachine.h"
18 #include "llvm/Target/TargetRegisterInfo.h"
22 TargetFrameLowering::~TargetFrameLowering() {
25 /// getFrameIndexOffset - Returns the displacement from the frame register to
26 /// the stack frame of the specified index. This is the default implementation
27 /// which is overridden for some targets.
28 int TargetFrameLowering::getFrameIndexOffset(const MachineFunction &MF,
30 const MachineFrameInfo *MFI = MF.getFrameInfo();
31 return MFI->getObjectOffset(FI) + MFI->getStackSize() -
32 getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
35 int TargetFrameLowering::getFrameIndexReference(const MachineFunction &MF,
36 int FI, unsigned &FrameReg) const {
37 const TargetRegisterInfo *RI = MF.getTarget().getRegisterInfo();
39 // By default, assume all frame indices are referenced via whatever
40 // getFrameRegister() says. The target can override this if it's doing
41 // something different.
42 FrameReg = RI->getFrameRegister(MF);
43 return getFrameIndexOffset(MF, FI);