Eliminate MachineFunction& argument from eliminateFrameIndex in x86 Target. Get...
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9FrameInfo.cpp
1 //===-- SparcV9FrameInfo.cpp - Stack frame layout info for SparcV9 --------===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 // 
10 // Interface to stack frame layout info for the UltraSPARC.
11 // 
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/CodeGen/MachineFunction.h"
15 #include "llvm/CodeGen/MachineFunctionInfo.h"
16 #include "llvm/Target/TargetFrameInfo.h"
17 #include "SparcV9FrameInfo.h"
18
19 using namespace llvm;
20
21 int
22 SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const 
23 {
24   // ensure no more auto vars are added
25   mcInfo.getInfo()->freezeAutomaticVarsArea();
26   
27   pos = false;                          // static stack area grows downwards
28   unsigned autoVarsSize = mcInfo.getInfo()->getAutomaticVarsSize();
29   return StaticAreaOffsetFromFP - autoVarsSize; 
30 }
31
32 int SparcV9FrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const {
33   MachineFunctionInfo *MFI = mcInfo.getInfo();
34   MFI->freezeAutomaticVarsArea();     // ensure no more auto vars are added
35   MFI->freezeSpillsArea();            // ensure no more spill slots are added
36   
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;
42 }
43
44 int
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.
50   pos = false;
51   unsigned optArgsSize = mcInfo.getInfo()->getMaxOptionalArgsSize();
52   if (int extra = optArgsSize % 16)
53     optArgsSize += (16 - extra);
54   int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
55   assert((offset - OFFSET) % 16 == 0);
56   return offset;
57 }