Fix PR6696 and PR6663
[oota-llvm.git] / lib / Target / X86 / X86MachineFunctionInfo.h
1 //====- X86MachineFuctionInfo.h - X86 machine function info -----*- 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 //
10 // This file declares X86-specific per-machine-function information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef X86MACHINEFUNCTIONINFO_H
15 #define X86MACHINEFUNCTIONINFO_H
16
17 #include "llvm/CodeGen/MachineFunction.h"
18
19 namespace llvm {
20
21 /// X86MachineFunctionInfo - This class is derived from MachineFunction and
22 /// contains private X86 target-specific information for each MachineFunction.
23 class X86MachineFunctionInfo : public MachineFunctionInfo {
24   /// ForceFramePointer - True if the function is required to use of frame
25   /// pointer for reasons other than it containing dynamic allocation or 
26   /// that FP eliminatation is turned off. For example, Cygwin main function
27   /// contains stack pointer re-alignment code which requires FP.
28   bool ForceFramePointer;
29
30   /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
31   /// stack frame in bytes.
32   unsigned CalleeSavedFrameSize;
33
34   /// BytesToPopOnReturn - Number of bytes function pops on return.
35   /// Used on windows platform for stdcall & fastcall name decoration
36   unsigned BytesToPopOnReturn;
37
38   /// ReturnAddrIndex - FrameIndex for return slot.
39   int ReturnAddrIndex;
40
41   /// TailCallReturnAddrDelta - The number of bytes by which return address
42   /// stack slot is moved as the result of tail call optimization.
43   int TailCallReturnAddrDelta;
44
45   /// SRetReturnReg - Some subtargets require that sret lowering includes
46   /// returning the value of the returned struct in a register. This field
47   /// holds the virtual register into which the sret argument is passed.
48   unsigned SRetReturnReg;
49
50   /// GlobalBaseReg - keeps track of the virtual register initialized for
51   /// use as the global base register. This is used for PIC in some PIC
52   /// relocation models.
53   unsigned GlobalBaseReg;
54
55   /// ReserveFP - whether the function should reserve the frame pointer
56   /// when allocating, even if there may not actually be a frame pointer used.
57   bool ReserveFP;
58
59 public:
60   X86MachineFunctionInfo() : ForceFramePointer(false),
61                              CalleeSavedFrameSize(0),
62                              BytesToPopOnReturn(0),
63                              ReturnAddrIndex(0),
64                              TailCallReturnAddrDelta(0),
65                              SRetReturnReg(0),
66                              GlobalBaseReg(0) {}
67   
68   explicit X86MachineFunctionInfo(MachineFunction &MF)
69     : ForceFramePointer(false),
70       CalleeSavedFrameSize(0),
71       BytesToPopOnReturn(0),
72       ReturnAddrIndex(0),
73       TailCallReturnAddrDelta(0),
74       SRetReturnReg(0),
75       GlobalBaseReg(0),
76       ReserveFP(false) {}
77   
78   bool getForceFramePointer() const { return ForceFramePointer;} 
79   void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
80
81   unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
82   void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
83
84   unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
85   void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
86
87   int getRAIndex() const { return ReturnAddrIndex; }
88   void setRAIndex(int Index) { ReturnAddrIndex = Index; }
89
90   int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
91   void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
92
93   unsigned getSRetReturnReg() const { return SRetReturnReg; }
94   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
95
96   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
97   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
98
99   bool getReserveFP() const { return ReserveFP; }
100   void setReserveFP(bool reserveFP) { ReserveFP = reserveFP; }
101 };
102
103 } // End llvm namespace
104
105 #endif