Make LABEL a builtin opcode.
[oota-llvm.git] / lib / Target / PowerPC / PPCFrameInfo.h
1 //===-- PPCFrameInfo.h - Define TargetFrameInfo for PowerPC -----*- C++ -*-===//
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 //
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef POWERPC_FRAMEINFO_H
14 #define POWERPC_FRAMEINFO_H
15
16 #include "PPC.h"
17 #include "llvm/Target/TargetFrameInfo.h"
18 #include "llvm/Target/TargetMachine.h"
19
20 namespace llvm {
21
22 class PPCFrameInfo: public TargetFrameInfo {
23   const TargetMachine &TM;
24
25 public:
26   PPCFrameInfo(const TargetMachine &tm, bool LP64)
27     : TargetFrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), TM(tm) {
28   }
29
30   /// getReturnSaveOffset - Return the previous frame offset to save the
31   /// return address.
32   static unsigned getReturnSaveOffset(bool LP64) {
33     return LP64 ? 16 : 8;
34   }
35
36   /// getFramePointerSaveOffset - Return the previous frame offset to save the
37   /// frame pointer.
38   static unsigned getFramePointerSaveOffset(bool LP64) {
39     // Use the TOC save slot in the PowerPC linkage area for saving the frame
40     // pointer (if needed.)  LLVM does not generate code that uses the TOC (R2
41     // is treated as a caller saved register.)
42     return LP64 ? 40 : 20;
43   }
44   
45   /// getLinkageSize - Return the size of the PowerPC ABI linkage area.
46   ///
47   static unsigned getLinkageSize(bool LP64) {
48     return 6 * (LP64 ? 8 : 4);
49   }
50
51   /// getMinCallArgumentsSize - Return the size of the minium PowerPC ABI
52   /// argument area.
53   static unsigned getMinCallArgumentsSize(bool LP64) {
54    // The prolog code of the callee may store up to 8 GPR argument registers to
55    // the stack, allowing va_start to index over them in memory if its varargs.
56    // Because we cannot tell if this is needed on the caller side, we have to
57    // conservatively assume that it is needed.  As such, make sure we have at
58    // least enough stack space for the caller to store the 8 GPRs.
59     return 8 * (LP64 ? 8 : 4);
60   }
61
62   /// getMinCallFrameSize - Return the minimum size a call frame can be using
63   /// the PowerPC ABI.
64   static unsigned getMinCallFrameSize(bool LP64) {
65     // The call frame needs to be at least big enough for linkage and 8 args.
66     return getLinkageSize(LP64) + getMinCallArgumentsSize(LP64);
67   }
68   
69 };
70
71 } // End llvm namespace
72
73 #endif