Move [get|set]BasePtrStackAdjustment() from MachineFrameInfo to
[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   virtual void anchor();
25
26   /// ForceFramePointer - True if the function is required to use of frame
27   /// pointer for reasons other than it containing dynamic allocation or 
28   /// that FP eliminatation is turned off. For example, Cygwin main function
29   /// contains stack pointer re-alignment code which requires FP.
30   bool ForceFramePointer;
31
32   /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
33   /// stack frame in bytes.
34   unsigned CalleeSavedFrameSize;
35
36   /// BytesToPopOnReturn - Number of bytes function pops on return (in addition
37   /// to the space used by the return address).
38   /// Used on windows platform for stdcall & fastcall name decoration
39   unsigned BytesToPopOnReturn;
40
41   /// ReturnAddrIndex - FrameIndex for return slot.
42   int ReturnAddrIndex;
43
44   /// TailCallReturnAddrDelta - The number of bytes by which return address
45   /// stack slot is moved as the result of tail call optimization.
46   int TailCallReturnAddrDelta;
47
48   /// SRetReturnReg - Some subtargets require that sret lowering includes
49   /// returning the value of the returned struct in a register. This field
50   /// holds the virtual register into which the sret argument is passed.
51   unsigned SRetReturnReg;
52
53   /// GlobalBaseReg - keeps track of the virtual register initialized for
54   /// use as the global base register. This is used for PIC in some PIC
55   /// relocation models.
56   unsigned GlobalBaseReg;
57
58   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
59   int VarArgsFrameIndex;
60   /// RegSaveFrameIndex - X86-64 vararg func register save area.
61   int RegSaveFrameIndex;
62   /// VarArgsGPOffset - X86-64 vararg func int reg offset.
63   unsigned VarArgsGPOffset;
64   /// VarArgsFPOffset - X86-64 vararg func fp reg offset.
65   unsigned VarArgsFPOffset;
66   /// ArgumentStackSize - The number of bytes on stack consumed by the arguments
67   /// being passed on the stack.
68   unsigned ArgumentStackSize;
69   /// NumLocalDynamics - Number of local-dynamic TLS accesses.
70   unsigned NumLocalDynamics;
71
72   /// After the stack pointer has been restore from the base pointer we
73   /// use a cached adjusment.
74   int64_t BPAdj;
75
76 public:
77   X86MachineFunctionInfo() : ForceFramePointer(false),
78                              CalleeSavedFrameSize(0),
79                              BytesToPopOnReturn(0),
80                              ReturnAddrIndex(0),
81                              TailCallReturnAddrDelta(0),
82                              SRetReturnReg(0),
83                              GlobalBaseReg(0),
84                              VarArgsFrameIndex(0),
85                              RegSaveFrameIndex(0),
86                              VarArgsGPOffset(0),
87                              VarArgsFPOffset(0),
88                              ArgumentStackSize(0),
89                              NumLocalDynamics(0) {}
90   
91   explicit X86MachineFunctionInfo(MachineFunction &MF)
92     : ForceFramePointer(false),
93       CalleeSavedFrameSize(0),
94       BytesToPopOnReturn(0),
95       ReturnAddrIndex(0),
96       TailCallReturnAddrDelta(0),
97       SRetReturnReg(0),
98       GlobalBaseReg(0),
99       VarArgsFrameIndex(0),
100       RegSaveFrameIndex(0),
101       VarArgsGPOffset(0),
102       VarArgsFPOffset(0),
103       ArgumentStackSize(0),
104       NumLocalDynamics(0),
105       BPAdj(0) {}
106
107   bool getForceFramePointer() const { return ForceFramePointer;} 
108   void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
109
110   unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
111   void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
112
113   unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
114   void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
115
116   int getRAIndex() const { return ReturnAddrIndex; }
117   void setRAIndex(int Index) { ReturnAddrIndex = Index; }
118
119   int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
120   void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
121
122   unsigned getSRetReturnReg() const { return SRetReturnReg; }
123   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
124
125   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
126   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
127
128   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
129   void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; }
130
131   int getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
132   void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; }
133
134   unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; }
135   void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; }
136
137   unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; }
138   void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; }
139
140   unsigned getArgumentStackSize() const { return ArgumentStackSize; }
141   void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
142
143   unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
144   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
145
146   /// setBasePtrStackAdjustment - If we're restoring the stack pointer from the
147   /// base pointer, due to dynamic stack realignment + VLAs, we cache the
148   /// number of bytes initially allocated for the stack frame.  In obscure
149   /// cases (e.g., tail calls with byval argument and no stack protector), the
150   /// stack gets adjusted outside of the prolog, but these shouldn't be 
151   /// considered when restoring from the base pointer.  Currently, this is only
152   /// needed for x86.
153   void setBasePtrStackAdjustment(int64_t adj) { BPAdj = adj; }
154   int64_t getBasePtrStackAdjustment() const { return BPAdj; }
155 };
156
157 } // End llvm namespace
158
159 #endif