LLVM API Documentation

SparcV9FrameInfo.cpp

Go to the documentation of this file.
00001 //===-- SparcV9FrameInfo.cpp - Stack frame layout info for SparcV9 --------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // Interface to stack frame layout info for the UltraSPARC.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "llvm/CodeGen/MachineFunction.h"
00015 #include "llvm/Target/TargetFrameInfo.h"
00016 #include "MachineFunctionInfo.h"
00017 #include "SparcV9FrameInfo.h"
00018 
00019 using namespace llvm;
00020 
00021 int
00022 SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const
00023 {
00024   // ensure no more auto vars are added
00025   mcInfo.getInfo<SparcV9FunctionInfo>()->freezeAutomaticVarsArea();
00026 
00027   pos = false;                          // static stack area grows downwards
00028   unsigned autoVarsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getAutomaticVarsSize();
00029   return StaticAreaOffsetFromFP - autoVarsSize;
00030 }
00031 
00032 int SparcV9FrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const {
00033   SparcV9FunctionInfo *MFI = mcInfo.getInfo<SparcV9FunctionInfo>();
00034   MFI->freezeAutomaticVarsArea();     // ensure no more auto vars are added
00035   MFI->freezeSpillsArea();            // ensure no more spill slots are added
00036 
00037   pos = false;                          // static stack area grows downwards
00038   unsigned autoVarsSize = MFI->getAutomaticVarsSize();
00039   unsigned spillAreaSize = MFI->getRegSpillsSize();
00040   int offset = autoVarsSize + spillAreaSize;
00041   return StaticAreaOffsetFromFP - offset;
00042 }
00043 
00044 int
00045 SparcV9FrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo, bool& pos) const {
00046   // Dynamic stack area grows downwards starting at top of opt-args area.
00047   // The opt-args, required-args, and register-save areas are empty except
00048   // during calls and traps, so they are shifted downwards on each
00049   // dynamic-size alloca.
00050   pos = false;
00051   unsigned optArgsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getMaxOptionalArgsSize();
00052   if (int extra = optArgsSize % 16)
00053     optArgsSize += (16 - extra);
00054   int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
00055   assert((offset - OFFSET) % 16 == 0);
00056   return offset;
00057 }