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" |
| 15 | #include "llvm/CodeGen/MachineFunctionInfo.h" |
| 16 | #include "llvm/Target/TargetFrameInfo.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::getFirstAutomaticVarOffset(MachineFunction&, bool& pos) const { |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 23 | pos = false; // static stack area grows downwards |
| 24 | return StaticAreaOffsetFromFP; |
| 25 | } |
| 26 | |
| 27 | int |
Brian Gaeke | e3d6807 | 2004-02-25 18:44:15 +0000 | [diff] [blame] | 28 | SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 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 | |
Brian Gaeke | e3d6807 | 2004-02-25 18:44:15 +0000 | [diff] [blame] | 38 | int SparcV9FrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const { |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 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 |
Brian Gaeke | e3d6807 | 2004-02-25 18:44:15 +0000 | [diff] [blame] | 51 | SparcV9FrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo, bool& pos) const { |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 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(); |
Chris Lattner | be5af7d | 2004-08-12 18:20:41 +0000 | [diff] [blame^] | 58 | if (int extra = optArgsSize % 16) |
| 59 | optArgsSize += (16 - extra); |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 60 | int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP; |
Chris Lattner | be5af7d | 2004-08-12 18:20:41 +0000 | [diff] [blame^] | 61 | assert((offset - OFFSET) % 16 == 0); |
Misha Brukman | d71295a | 2003-12-17 22:04:00 +0000 | [diff] [blame] | 62 | return offset; |
| 63 | } |