2011-12-15 22:58:58 +00:00
|
|
|
//===----- TargetFrameLoweringImpl.cpp - Implement target frame interface --==//
|
2005-04-21 22:55:34 +00:00
|
|
|
//
|
2004-03-11 23:52:43 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:55:34 +00:00
|
|
|
//
|
2004-03-11 23:52:43 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Implements the layout of a stack frame on the target machine.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/Target/TargetFrameLowering.h"
|
2010-11-20 16:14:57 +00:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2010-11-20 15:59:32 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
2014-08-04 21:25:23 +00:00
|
|
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
2004-03-11 23:52:43 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
using namespace llvm;
|
|
|
|
|
2011-01-10 12:39:04 +00:00
|
|
|
TargetFrameLowering::~TargetFrameLowering() {
|
2005-02-17 21:40:27 +00:00
|
|
|
}
|
2010-11-18 23:25:52 +00:00
|
|
|
|
2010-11-20 15:59:32 +00:00
|
|
|
/// 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.
|
2011-01-10 12:39:04 +00:00
|
|
|
int TargetFrameLowering::getFrameIndexOffset(const MachineFunction &MF,
|
2010-11-20 15:59:32 +00:00
|
|
|
int FI) const {
|
|
|
|
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
|
|
|
return MFI->getObjectOffset(FI) + MFI->getStackSize() -
|
|
|
|
getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
|
|
|
|
}
|
|
|
|
|
2011-01-10 12:39:04 +00:00
|
|
|
int TargetFrameLowering::getFrameIndexReference(const MachineFunction &MF,
|
|
|
|
int FI, unsigned &FrameReg) const {
|
2014-08-05 02:39:49 +00:00
|
|
|
const TargetRegisterInfo *RI = MF.getSubtarget().getRegisterInfo();
|
2010-11-20 15:59:32 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|