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. Starting offsets
11 // for each area of the stack frame are aligned at a multiple of
12 // getStackFrameSizeAlignment().
14 //===----------------------------------------------------------------------===//
16 #include "llvm/CodeGen/MachineFunction.h"
17 #include "llvm/CodeGen/MachineFunctionInfo.h"
18 #include "llvm/Target/TargetFrameInfo.h"
19 #include "SparcV9FrameInfo.h"
24 SparcV9FrameInfo::getFirstAutomaticVarOffset(MachineFunction&, bool& pos) const {
25 pos = false; // static stack area grows downwards
26 return StaticAreaOffsetFromFP;
30 SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const
32 // ensure no more auto vars are added
33 mcInfo.getInfo()->freezeAutomaticVarsArea();
35 pos = false; // static stack area grows downwards
36 unsigned autoVarsSize = mcInfo.getInfo()->getAutomaticVarsSize();
37 return StaticAreaOffsetFromFP - autoVarsSize;
40 int SparcV9FrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const {
41 MachineFunctionInfo *MFI = mcInfo.getInfo();
42 MFI->freezeAutomaticVarsArea(); // ensure no more auto vars are added
43 MFI->freezeSpillsArea(); // ensure no more spill slots are added
45 pos = false; // static stack area grows downwards
46 unsigned autoVarsSize = MFI->getAutomaticVarsSize();
47 unsigned spillAreaSize = MFI->getRegSpillsSize();
48 int offset = autoVarsSize + spillAreaSize;
49 return StaticAreaOffsetFromFP - offset;
53 SparcV9FrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo, bool& pos) const {
54 // Dynamic stack area grows downwards starting at top of opt-args area.
55 // The opt-args, required-args, and register-save areas are empty except
56 // during calls and traps, so they are shifted downwards on each
57 // dynamic-size alloca.
59 unsigned optArgsSize = mcInfo.getInfo()->getMaxOptionalArgsSize();
60 if (int extra = optArgsSize % getStackFrameSizeAlignment())
61 optArgsSize += (getStackFrameSizeAlignment() - extra);
62 int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
63 assert((offset - OFFSET) % getStackFrameSizeAlignment() == 0);