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/CodeGen/MachineFunctionInfo.h"
16 #include "llvm/Target/TargetFrameInfo.h"
17 #include "SparcV9FrameInfo.h"
22 SparcV9FrameInfo::getFirstAutomaticVarOffset(MachineFunction&, bool& pos) const {
23 pos = false; // static stack area grows downwards
24 return StaticAreaOffsetFromFP;
28 SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const
30 // ensure no more auto vars are added
31 mcInfo.getInfo()->freezeAutomaticVarsArea();
33 pos = false; // static stack area grows downwards
34 unsigned autoVarsSize = mcInfo.getInfo()->getAutomaticVarsSize();
35 return StaticAreaOffsetFromFP - autoVarsSize;
38 int SparcV9FrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const {
39 MachineFunctionInfo *MFI = mcInfo.getInfo();
40 MFI->freezeAutomaticVarsArea(); // ensure no more auto vars are added
41 MFI->freezeSpillsArea(); // ensure no more spill slots are added
43 pos = false; // static stack area grows downwards
44 unsigned autoVarsSize = MFI->getAutomaticVarsSize();
45 unsigned spillAreaSize = MFI->getRegSpillsSize();
46 int offset = autoVarsSize + spillAreaSize;
47 return StaticAreaOffsetFromFP - offset;
51 SparcV9FrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo, bool& pos) const {
52 // Dynamic stack area grows downwards starting at top of opt-args area.
53 // The opt-args, required-args, and register-save areas are empty except
54 // during calls and traps, so they are shifted downwards on each
55 // dynamic-size alloca.
57 unsigned optArgsSize = mcInfo.getInfo()->getMaxOptionalArgsSize();
58 if (int extra = optArgsSize % 16)
59 optArgsSize += (16 - extra);
60 int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
61 assert((offset - OFFSET) % 16 == 0);