1 //===-- TargetFrameInfo.cpp - Implement machine frame interface -*- C++ -*-===//
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/CodeGen/MachineFrameInfo.h"
15 #include "llvm/CodeGen/MachineFunction.h"
16 #include "llvm/Target/TargetFrameInfo.h"
17 #include "llvm/Target/TargetMachine.h"
18 #include "llvm/Target/TargetRegisterInfo.h"
23 TargetFrameInfo::~TargetFrameInfo() {
26 /// getInitialFrameState - Returns a list of machine moves that are assumed
27 /// on entry to a function.
29 TargetFrameInfo::getInitialFrameState(std::vector<MachineMove> &Moves) const {
30 // Default is to do nothing.
33 /// getFrameIndexOffset - Returns the displacement from the frame register to
34 /// the stack frame of the specified index. This is the default implementation
35 /// which is overridden for some targets.
36 int TargetFrameInfo::getFrameIndexOffset(const MachineFunction &MF,
38 const MachineFrameInfo *MFI = MF.getFrameInfo();
39 return MFI->getObjectOffset(FI) + MFI->getStackSize() -
40 getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
43 int TargetFrameInfo::getFrameIndexReference(const MachineFunction &MF, int FI,
44 unsigned &FrameReg) const {
45 const TargetRegisterInfo *RI = MF.getTarget().getRegisterInfo();
47 // By default, assume all frame indices are referenced via whatever
48 // getFrameRegister() says. The target can override this if it's doing
49 // something different.
50 FrameReg = RI->getFrameRegister(MF);
51 return getFrameIndexOffset(MF, FI);