1 //===-- SparcV9FrameInfo.cpp - Stack frame layout info for SparcV9 --------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Interface to stack frame layout info for the UltraSPARC.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/MachineFunction.h"
15 #include "llvm/Target/TargetFrameInfo.h"
16 #include "MachineFunctionInfo.h"
17 #include "SparcV9FrameInfo.h"
22 SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const
24 // ensure no more auto vars are added
25 mcInfo.getInfo<SparcV9FunctionInfo>()->freezeAutomaticVarsArea();
27 pos = false; // static stack area grows downwards
28 unsigned autoVarsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getAutomaticVarsSize();
29 return StaticAreaOffsetFromFP - autoVarsSize;
32 int SparcV9FrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const {
33 SparcV9FunctionInfo *MFI = mcInfo.getInfo<SparcV9FunctionInfo>();
34 MFI->freezeAutomaticVarsArea(); // ensure no more auto vars are added
35 MFI->freezeSpillsArea(); // ensure no more spill slots are added
37 pos = false; // static stack area grows downwards
38 unsigned autoVarsSize = MFI->getAutomaticVarsSize();
39 unsigned spillAreaSize = MFI->getRegSpillsSize();
40 int offset = autoVarsSize + spillAreaSize;
41 return StaticAreaOffsetFromFP - offset;
45 SparcV9FrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo, bool& pos) const {
46 // Dynamic stack area grows downwards starting at top of opt-args area.
47 // The opt-args, required-args, and register-save areas are empty except
48 // during calls and traps, so they are shifted downwards on each
49 // dynamic-size alloca.
51 unsigned optArgsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getMaxOptionalArgsSize();
52 if (int extra = optArgsSize % 16)
53 optArgsSize += (16 - extra);
54 int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
55 assert((offset - OFFSET) % 16 == 0);