Brian Gaeke | 3ca4fcc | 2004-04-25 07:04:49 +0000 | [diff] [blame] | 1 | //===-- SparcV9FrameInfo.cpp - Stack frame layout info for SparcV9 --------===// |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 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 | // |
Chris Lattner | be5af7d | 2004-08-12 18:20:41 +0000 | [diff] [blame] | 10 | // Interface to stack frame layout info for the UltraSPARC. |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/CodeGen/MachineFunction.h" |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 15 | #include "llvm/Target/TargetFrameInfo.h" |
Chris Lattner | 85015a0 | 2004-08-16 21:55:02 +0000 | [diff] [blame] | 16 | #include "MachineFunctionInfo.h" |
Brian Gaeke | e3d6807 | 2004-02-25 18:44:15 +0000 | [diff] [blame] | 17 | #include "SparcV9FrameInfo.h" |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 18 | |
| 19 | using namespace llvm; |
| 20 | |
| 21 | int |
Brian Gaeke | e3d6807 | 2004-02-25 18:44:15 +0000 | [diff] [blame] | 22 | SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 23 | { |
| 24 | // ensure no more auto vars are added |
Chris Lattner | a1e51ff | 2004-08-18 18:13:37 +0000 | [diff] [blame^] | 25 | mcInfo.getInfo<SparcV9FunctionInfo>()->freezeAutomaticVarsArea(); |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 26 | |
| 27 | pos = false; // static stack area grows downwards |
Chris Lattner | a1e51ff | 2004-08-18 18:13:37 +0000 | [diff] [blame^] | 28 | unsigned autoVarsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getAutomaticVarsSize(); |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 29 | return StaticAreaOffsetFromFP - autoVarsSize; |
| 30 | } |
| 31 | |
Brian Gaeke | e3d6807 | 2004-02-25 18:44:15 +0000 | [diff] [blame] | 32 | int SparcV9FrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const { |
Chris Lattner | a1e51ff | 2004-08-18 18:13:37 +0000 | [diff] [blame^] | 33 | SparcV9FunctionInfo *MFI = mcInfo.getInfo<SparcV9FunctionInfo>(); |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 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 |
Brian Gaeke | e3d6807 | 2004-02-25 18:44:15 +0000 | [diff] [blame] | 45 | SparcV9FrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo, bool& pos) const { |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 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; |
Chris Lattner | a1e51ff | 2004-08-18 18:13:37 +0000 | [diff] [blame^] | 51 | unsigned optArgsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getMaxOptionalArgsSize(); |
Chris Lattner | be5af7d | 2004-08-12 18:20:41 +0000 | [diff] [blame] | 52 | if (int extra = optArgsSize % 16) |
| 53 | optArgsSize += (16 - extra); |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 54 | int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP; |
Chris Lattner | be5af7d | 2004-08-12 18:20:41 +0000 | [diff] [blame] | 55 | assert((offset - OFFSET) % 16 == 0); |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 56 | return offset; |
| 57 | } |