Hanle i8 returns
[llvm/msp430.git] / lib / Target / PowerPC / PPCFrameInfo.h
blob1b5893da0ce2db51d2ab7c0353cd30358c1e5b0e
1 //===-- PPCFrameInfo.h - Define TargetFrameInfo for PowerPC -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
11 //===----------------------------------------------------------------------===//
13 #ifndef POWERPC_FRAMEINFO_H
14 #define POWERPC_FRAMEINFO_H
16 #include "PPC.h"
17 #include "llvm/Target/TargetFrameInfo.h"
18 #include "llvm/Target/TargetMachine.h"
20 namespace llvm {
22 class PPCFrameInfo: public TargetFrameInfo {
23 const TargetMachine &TM;
25 public:
26 PPCFrameInfo(const TargetMachine &tm, bool LP64)
27 : TargetFrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), TM(tm) {
30 /// getReturnSaveOffset - Return the previous frame offset to save the
31 /// return address.
32 static unsigned getReturnSaveOffset(bool LP64, bool isMacho) {
33 if (isMacho)
34 return LP64 ? 16 : 8;
35 // For ELF 32 ABI:
36 return 4;
39 /// getFramePointerSaveOffset - Return the previous frame offset to save the
40 /// frame pointer.
41 static unsigned getFramePointerSaveOffset(bool LP64, bool isMacho) {
42 // For MachO ABI:
43 // Use the TOC save slot in the PowerPC linkage area for saving the frame
44 // pointer (if needed.) LLVM does not generate code that uses the TOC (R2
45 // is treated as a caller saved register.)
46 if (isMacho)
47 return LP64 ? 40 : 20;
49 // For ELF 32 ABI:
50 // Save it right before the link register
51 return -4U;
54 /// getLinkageSize - Return the size of the PowerPC ABI linkage area.
55 ///
56 static unsigned getLinkageSize(bool LP64, bool isMacho) {
57 if (isMacho)
58 return 6 * (LP64 ? 8 : 4);
60 // For ELF 32 ABI:
61 return 8;
64 /// getMinCallArgumentsSize - Return the size of the minium PowerPC ABI
65 /// argument area.
66 static unsigned getMinCallArgumentsSize(bool LP64, bool isMacho) {
67 // For Macho ABI:
68 // The prolog code of the callee may store up to 8 GPR argument registers to
69 // the stack, allowing va_start to index over them in memory if its varargs.
70 // Because we cannot tell if this is needed on the caller side, we have to
71 // conservatively assume that it is needed. As such, make sure we have at
72 // least enough stack space for the caller to store the 8 GPRs.
73 if (isMacho)
74 return 8 * (LP64 ? 8 : 4);
76 // For ELF 32 ABI:
77 // There is no default stack allocated for the 8 first GPR arguments.
78 return 0;
81 /// getMinCallFrameSize - Return the minimum size a call frame can be using
82 /// the PowerPC ABI.
83 static unsigned getMinCallFrameSize(bool LP64, bool isMacho) {
84 // The call frame needs to be at least big enough for linkage and 8 args.
85 return getLinkageSize(LP64, isMacho) +
86 getMinCallArgumentsSize(LP64, isMacho);
91 } // End llvm namespace
93 #endif