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"
19 #include "llvm/Target/TargetSubtargetInfo.h"
23 TargetFrameLowering::~TargetFrameLowering() {
26 /// getFrameIndexOffset - Returns the displacement from the frame register to
27 /// the stack frame of the specified index. This is the default implementation
28 /// which is overridden for some targets.
29 int TargetFrameLowering::getFrameIndexOffset(const MachineFunction &MF,
31 const MachineFrameInfo *MFI = MF.getFrameInfo();
32 return MFI->getObjectOffset(FI) + MFI->getStackSize() -
33 getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
36 int TargetFrameLowering::getFrameIndexReference(const MachineFunction &MF,
37 int FI, unsigned &FrameReg) const {
38 const TargetRegisterInfo *RI = MF.getSubtarget().getRegisterInfo();
40 // By default, assume all frame indices are referenced via whatever
41 // getFrameRegister() says. The target can override this if it's doing
42 // something different.
43 FrameReg = RI->getFrameRegister(MF);
44 return getFrameIndexOffset(MF, FI);