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