LLVM API Documentation
00001 //===-- SparcV9FrameInfo.h - Define TargetFrameInfo for SparcV9 -*- C++ -*-===// 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 #ifndef SPARC_FRAMEINFO_H 00015 #define SPARC_FRAMEINFO_H 00016 00017 #include "llvm/Target/TargetFrameInfo.h" 00018 #include "llvm/Target/TargetMachine.h" 00019 #include "SparcV9RegInfo.h" 00020 00021 namespace llvm { 00022 00023 class SparcV9FrameInfo: public TargetFrameInfo { 00024 const TargetMachine ⌖ 00025 public: 00026 SparcV9FrameInfo(const TargetMachine &TM) 00027 : TargetFrameInfo(StackGrowsDown, StackFrameSizeAlignment, 0), target(TM) {} 00028 00029 // This method adjusts a stack offset to meet alignment rules of target. 00030 // The fixed OFFSET (0x7ff) must be subtracted and the result aligned. 00031 virtual int adjustAlignment(int unalignedOffset, bool growUp, 00032 unsigned int align) const { 00033 return unalignedOffset + (growUp? +1:-1)*((unalignedOffset-OFFSET) % align); 00034 } 00035 00036 // These methods compute offsets using the frame contents for a 00037 // particular function. The frame contents are obtained from the 00038 // MachineCodeInfoForMethod object for the given function. 00039 // 00040 int getFirstAutomaticVarOffset(MachineFunction& mcInfo, bool& growUp) const { 00041 growUp = false; 00042 return StaticAreaOffsetFromFP; 00043 } 00044 int getRegSpillAreaOffset(MachineFunction& mcInfo, bool& growUp) const; 00045 int getTmpAreaOffset(MachineFunction& mcInfo, bool& growUp) const; 00046 int getDynamicAreaOffset(MachineFunction& mcInfo, bool& growUp) const; 00047 00048 virtual int getIncomingArgOffset(MachineFunction& mcInfo, 00049 unsigned argNum) const { 00050 unsigned relativeOffset = argNum * SizeOfEachArgOnStack; 00051 int firstArg = FirstIncomingArgOffsetFromFP; 00052 return firstArg + relativeOffset; 00053 } 00054 00055 virtual int getOutgoingArgOffset(MachineFunction& mcInfo, 00056 unsigned argNum) const { 00057 return FirstOutgoingArgOffsetFromSP + argNum * SizeOfEachArgOnStack; 00058 } 00059 00060 /*---------------------------------------------------------------------- 00061 This diagram shows the stack frame layout used by llc on SparcV9 V9. 00062 Note that only the location of automatic variables, spill area, 00063 temporary storage, and dynamically allocated stack area are chosen 00064 by us. The rest conform to the SparcV9 V9 ABI. 00065 All stack addresses are offset by OFFSET = 0x7ff (2047). 00066 00067 Alignment assumptions and other invariants: 00068 (1) %sp+OFFSET and %fp+OFFSET are always aligned on 16-byte boundary 00069 (2) Variables in automatic, spill, temporary, or dynamic regions 00070 are aligned according to their size as in all memory accesses. 00071 (3) Everything below the dynamically allocated stack area is only used 00072 during a call to another function, so it is never needed when 00073 the current function is active. This is why space can be allocated 00074 dynamically by incrementing %sp any time within the function. 00075 00076 STACK FRAME LAYOUT: 00077 00078 ... 00079 %fp+OFFSET+176 Optional extra incoming arguments# 1..N 00080 %fp+OFFSET+168 Incoming argument #6 00081 ... ... 00082 %fp+OFFSET+128 Incoming argument #1 00083 ... ... 00084 ---%fp+OFFSET-0--------Bottom of caller's stack frame-------------------- 00085 %fp+OFFSET-8 Automatic variables <-- ****TOP OF STACK FRAME**** 00086 Spill area 00087 Temporary storage 00088 ... 00089 00090 %sp+OFFSET+176+8N Bottom of dynamically allocated stack area 00091 %sp+OFFSET+168+8N Optional extra outgoing argument# N 00092 ... ... 00093 %sp+OFFSET+176 Optional extra outgoing argument# 1 00094 %sp+OFFSET+168 Outgoing argument #6 00095 ... ... 00096 %sp+OFFSET+128 Outgoing argument #1 00097 %sp+OFFSET+120 Save area for %i7 00098 ... ... 00099 %sp+OFFSET+0 Save area for %l0 <-- ****BOTTOM OF STACK FRAME**** 00100 00101 *----------------------------------------------------------------------*/ 00102 00103 // All stack addresses must be offset by 0x7ff (2047) on SparcV9 V9. 00104 static const int OFFSET = (int) 0x7ff; 00105 static const int StackFrameSizeAlignment = 16; 00106 static const int MinStackFrameSize = 176; 00107 static const int SizeOfEachArgOnStack = 8; 00108 static const int FirstIncomingArgOffsetFromFP = 128 + OFFSET; 00109 static const int FirstOptionalIncomingArgOffsetFromFP = 176 + OFFSET; 00110 static const int StaticAreaOffsetFromFP = 0 + OFFSET; 00111 static const int FirstOutgoingArgOffsetFromSP = 128 + OFFSET; 00112 static const int FirstOptionalOutgoingArgOffsetFromSP = 176 + OFFSET; 00113 }; 00114 00115 } // End llvm namespace 00116 00117 #endif