2004-04-25 15:04:49 +08:00
|
|
|
//===-- SparcV9FrameInfo.cpp - Stack frame layout info for SparcV9 --------===//
|
2005-04-22 07:30:14 +08:00
|
|
|
//
|
2003-12-18 06:04:00 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-22 07:30:14 +08:00
|
|
|
//
|
2003-12-18 06:04:00 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2005-04-22 07:30:14 +08:00
|
|
|
//
|
2004-08-13 02:20:41 +08:00
|
|
|
// Interface to stack frame layout info for the UltraSPARC.
|
2005-04-22 07:30:14 +08:00
|
|
|
//
|
2003-12-18 06:04:00 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/Target/TargetFrameInfo.h"
|
2004-08-17 05:55:02 +08:00
|
|
|
#include "MachineFunctionInfo.h"
|
2004-02-26 02:44:15 +08:00
|
|
|
#include "SparcV9FrameInfo.h"
|
2003-12-18 06:04:00 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
int
|
2005-04-22 07:30:14 +08:00
|
|
|
SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const
|
2003-12-18 06:04:00 +08:00
|
|
|
{
|
|
|
|
// ensure no more auto vars are added
|
2004-08-19 02:13:37 +08:00
|
|
|
mcInfo.getInfo<SparcV9FunctionInfo>()->freezeAutomaticVarsArea();
|
2005-04-22 07:30:14 +08:00
|
|
|
|
2003-12-18 06:04:00 +08:00
|
|
|
pos = false; // static stack area grows downwards
|
2004-08-19 02:13:37 +08:00
|
|
|
unsigned autoVarsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getAutomaticVarsSize();
|
2005-04-22 07:30:14 +08:00
|
|
|
return StaticAreaOffsetFromFP - autoVarsSize;
|
2003-12-18 06:04:00 +08:00
|
|
|
}
|
|
|
|
|
2004-02-26 02:44:15 +08:00
|
|
|
int SparcV9FrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const {
|
2004-08-19 02:13:37 +08:00
|
|
|
SparcV9FunctionInfo *MFI = mcInfo.getInfo<SparcV9FunctionInfo>();
|
2003-12-18 06:04:00 +08:00
|
|
|
MFI->freezeAutomaticVarsArea(); // ensure no more auto vars are added
|
|
|
|
MFI->freezeSpillsArea(); // ensure no more spill slots are added
|
2005-04-22 07:30:14 +08:00
|
|
|
|
2003-12-18 06:04:00 +08:00
|
|
|
pos = false; // static stack area grows downwards
|
|
|
|
unsigned autoVarsSize = MFI->getAutomaticVarsSize();
|
|
|
|
unsigned spillAreaSize = MFI->getRegSpillsSize();
|
|
|
|
int offset = autoVarsSize + spillAreaSize;
|
|
|
|
return StaticAreaOffsetFromFP - offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2004-02-26 02:44:15 +08:00
|
|
|
SparcV9FrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo, bool& pos) const {
|
2003-12-18 06:04:00 +08:00
|
|
|
// Dynamic stack area grows downwards starting at top of opt-args area.
|
|
|
|
// The opt-args, required-args, and register-save areas are empty except
|
|
|
|
// during calls and traps, so they are shifted downwards on each
|
|
|
|
// dynamic-size alloca.
|
|
|
|
pos = false;
|
2004-08-19 02:13:37 +08:00
|
|
|
unsigned optArgsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getMaxOptionalArgsSize();
|
2004-08-13 02:20:41 +08:00
|
|
|
if (int extra = optArgsSize % 16)
|
|
|
|
optArgsSize += (16 - extra);
|
2003-12-18 06:04:00 +08:00
|
|
|
int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
|
2004-08-13 02:20:41 +08:00
|
|
|
assert((offset - OFFSET) % 16 == 0);
|
2003-12-18 06:04:00 +08:00
|
|
|
return offset;
|
|
|
|
}
|