1 //===-- PPCFrameInfo.h - Define TargetFrameInfo for PowerPC -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #ifndef POWERPC_FRAMEINFO_H
14 #define POWERPC_FRAMEINFO_H
17 #include "llvm/Target/TargetFrameInfo.h"
18 #include "llvm/Target/TargetMachine.h"
22 class PPCFrameInfo: public TargetFrameInfo {
23 const TargetMachine &TM;
24 std::pair<unsigned, int> LR[1];
27 PPCFrameInfo(const TargetMachine &tm, bool LP64)
28 : TargetFrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), TM(tm) {
30 LR[0].first = PPC::LR8;
33 LR[0].first = PPC::LR;
38 const std::pair<unsigned, int> *
39 getCalleeSaveSpillSlots(unsigned &NumEntries) const {
44 /// getFramePointerSaveOffset - Return the previous frame offset to save the
46 static unsigned getFramePointerSaveOffset(bool LP64) {
47 // Use the TOC save slot in the PowerPC linkage area for saving the frame
48 // pointer (if needed.) LLVM does not generate code that uses the TOC (R2
49 // is treated as a caller saved register.)
50 return LP64 ? 40 : 20;
53 /// getLinkageSize - Return the size of the PowerPC ABI linkage area.
55 static unsigned getLinkageSize(bool LP64) {
56 return 6 * (LP64 ? 8 : 4);
59 /// getMinCallArgumentsSize - Return the size of the minium PowerPC ABI
61 static unsigned getMinCallArgumentsSize(bool LP64) {
62 // The prolog code of the callee may store up to 8 GPR argument registers to
63 // the stack, allowing va_start to index over them in memory if its varargs.
64 // Because we cannot tell if this is needed on the caller side, we have to
65 // conservatively assume that it is needed. As such, make sure we have at
66 // least enough stack space for the caller to store the 8 GPRs.
67 return 8 * (LP64 ? 8 : 4);
70 /// getMinCallFrameSize - Return the minimum size a call frame can be using
72 static unsigned getMinCallFrameSize(bool LP64) {
73 // The call frame needs to be at least big enough for linkage and 8 args.
74 return getLinkageSize(LP64) + getMinCallArgumentsSize(LP64);
79 } // End llvm namespace