blob: cdf907b8c0473992a4e7bd3cda2fc151120efe4c [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- X86MachineFuctionInfo.h - X86 machine function info -----*- C++ -*-===//
2//
Evan Chenge8bd0a32006-06-06 23:30:24 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jia Liu31d157a2012-02-18 12:03:15 +00007//
Evan Chenge8bd0a32006-06-06 23:30:24 +00008//===----------------------------------------------------------------------===//
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
19namespace llvm {
20
Dan Gohman6288b932009-04-15 01:20:18 +000021/// X86MachineFunctionInfo - This class is derived from MachineFunction and
22/// contains private X86 target-specific information for each MachineFunction.
Chris Lattnerd15dff22007-04-17 17:21:52 +000023class X86MachineFunctionInfo : public MachineFunctionInfo {
David Blaikie2d24e2a2011-12-20 02:50:00 +000024 virtual void anchor();
25
Anton Korobeynikovf8248682006-09-20 22:03:51 +000026 /// 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.
Evan Chenge5e228d2006-06-09 06:25:10 +000030 bool ForceFramePointer;
Anton Korobeynikovf8248682006-09-20 22:03:51 +000031
Evan Cheng89d16592007-07-17 07:59:08 +000032 /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
33 /// stack frame in bytes.
34 unsigned CalleeSavedFrameSize;
35
Dan Gohman1e93df62010-04-17 14:41:14 +000036 /// BytesToPopOnReturn - Number of bytes function pops on return (in addition
37 /// to the space used by the return address).
Anton Korobeynikovf8248682006-09-20 22:03:51 +000038 /// Used on windows platform for stdcall & fastcall name decoration
39 unsigned BytesToPopOnReturn;
40
Evan Cheng0475ab52008-01-05 00:41:47 +000041 /// ReturnAddrIndex - FrameIndex for return slot.
Anton Korobeynikova2780e12007-08-15 17:12:32 +000042 int ReturnAddrIndex;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000043
Evan Chengf22f9b32010-02-06 03:28:46 +000044 /// TailCallReturnAddrDelta - The number of bytes by which return address
45 /// stack slot is moved as the result of tail call optimization.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000046 int TailCallReturnAddrDelta;
47
Dan Gohman61a92132008-04-21 23:59:07 +000048 /// 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
Dan Gohmand735b802008-10-03 15:45:36 +000053 /// 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.
Dan Gohman57c3dac2008-09-30 00:58:23 +000056 unsigned GlobalBaseReg;
57
Dan Gohman1e93df62010-04-17 14:41:14 +000058 /// 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;
Rafael Espindola76927d752011-08-30 19:39:58 +000066 /// ArgumentStackSize - The number of bytes on stack consumed by the arguments
67 /// being passed on the stack.
68 unsigned ArgumentStackSize;
Hans Wennborgf0234fc2012-06-01 16:27:21 +000069 /// NumLocalDynamics - Number of local-dynamic TLS accesses.
70 unsigned NumLocalDynamics;
Dan Gohman1e93df62010-04-17 14:41:14 +000071
Chad Rosier2b026882012-07-10 18:27:15 +000072 /// After the stack pointer has been restore from the base pointer we
73 /// use a cached adjusment.
74 int64_t BPAdj;
75
Evan Chenge8bd0a32006-06-06 23:30:24 +000076public:
Chris Lattnerd15dff22007-04-17 17:21:52 +000077 X86MachineFunctionInfo() : ForceFramePointer(false),
Evan Cheng89d16592007-07-17 07:59:08 +000078 CalleeSavedFrameSize(0),
Chris Lattnerd15dff22007-04-17 17:21:52 +000079 BytesToPopOnReturn(0),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000080 ReturnAddrIndex(0),
Dan Gohman61a92132008-04-21 23:59:07 +000081 TailCallReturnAddrDelta(0),
Dan Gohman57c3dac2008-09-30 00:58:23 +000082 SRetReturnReg(0),
Dan Gohman1e93df62010-04-17 14:41:14 +000083 GlobalBaseReg(0),
84 VarArgsFrameIndex(0),
85 RegSaveFrameIndex(0),
86 VarArgsGPOffset(0),
Rafael Espindola76927d752011-08-30 19:39:58 +000087 VarArgsFPOffset(0),
Hans Wennborgf0234fc2012-06-01 16:27:21 +000088 ArgumentStackSize(0),
89 NumLocalDynamics(0) {}
Anton Korobeynikovf8248682006-09-20 22:03:51 +000090
Dan Gohman2392efe2009-06-05 23:05:51 +000091 explicit X86MachineFunctionInfo(MachineFunction &MF)
92 : ForceFramePointer(false),
93 CalleeSavedFrameSize(0),
94 BytesToPopOnReturn(0),
Dan Gohman2392efe2009-06-05 23:05:51 +000095 ReturnAddrIndex(0),
96 TailCallReturnAddrDelta(0),
97 SRetReturnReg(0),
Jim Grosbachfa85eb62010-04-06 20:26:37 +000098 GlobalBaseReg(0),
Dan Gohman1e93df62010-04-17 14:41:14 +000099 VarArgsFrameIndex(0),
100 RegSaveFrameIndex(0),
101 VarArgsGPOffset(0),
Rafael Espindola76927d752011-08-30 19:39:58 +0000102 VarArgsFPOffset(0),
Hans Wennborgf0234fc2012-06-01 16:27:21 +0000103 ArgumentStackSize(0),
Chad Rosier2b026882012-07-10 18:27:15 +0000104 NumLocalDynamics(0),
105 BPAdj(0) {}
106
Evan Chenge8bd0a32006-06-06 23:30:24 +0000107 bool getForceFramePointer() const { return ForceFramePointer;}
108 void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
Anton Korobeynikovf8248682006-09-20 22:03:51 +0000109
Evan Cheng89d16592007-07-17 07:59:08 +0000110 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
111 void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
112
Anton Korobeynikovf8248682006-09-20 22:03:51 +0000113 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
114 void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
115
Anton Korobeynikova2780e12007-08-15 17:12:32 +0000116 int getRAIndex() const { return ReturnAddrIndex; }
117 void setRAIndex(int Index) { ReturnAddrIndex = Index; }
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000118
119 int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
120 void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
Dan Gohman61a92132008-04-21 23:59:07 +0000121
122 unsigned getSRetReturnReg() const { return SRetReturnReg; }
123 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohman57c3dac2008-09-30 00:58:23 +0000124
125 unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
126 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
Jim Grosbachfa85eb62010-04-06 20:26:37 +0000127
Dan Gohman1e93df62010-04-17 14:41:14 +0000128 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; }
Rafael Espindola76927d752011-08-30 19:39:58 +0000139
140 unsigned getArgumentStackSize() const { return ArgumentStackSize; }
141 void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
Hans Wennborgf0234fc2012-06-01 16:27:21 +0000142
143 unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
144 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
Chad Rosier2b026882012-07-10 18:27:15 +0000145
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; }
Evan Chenge8bd0a32006-06-06 23:30:24 +0000155};
Dan Gohman6288b932009-04-15 01:20:18 +0000156
Evan Chenge8bd0a32006-06-06 23:30:24 +0000157} // End llvm namespace
158
159#endif