Fix warning
[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::getFirstAutomaticVarOffset(MachineFunction&, bool& pos) const {
23   pos = false;                          // static stack area grows downwards
24   return StaticAreaOffsetFromFP;
25 }
26
27 int
28 SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const 
29 {
30   // ensure no more auto vars are added
31   mcInfo.getInfo()->freezeAutomaticVarsArea();
32   
33   pos = false;                          // static stack area grows downwards
34   unsigned autoVarsSize = mcInfo.getInfo()->getAutomaticVarsSize();
35   return StaticAreaOffsetFromFP - autoVarsSize; 
36 }
37
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
42   
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;
48 }
49
50 int
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.
56   pos = false;
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);
62   return offset;
63 }