blob: d517d82537a7804797373b6911e05b3e2c8f8338 [file] [log] [blame]
Nick Lewyckyc3890d22015-07-29 22:32:47 +00001//===-- X86MachineFunctionInfo.h - X86 machine function info ----*- C++ -*-===//
Jia Liub22310f2012-02-18 12:03:15 +00002//
Evan Chengdc614c12006-06-06 23:30:24 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Liub22310f2012-02-18 12:03:15 +00007//
Evan Chengdc614c12006-06-06 23:30:24 +00008//===----------------------------------------------------------------------===//
9//
10// This file declares X86-specific per-machine-function information.
11//
12//===----------------------------------------------------------------------===//
13
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
15#define LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
Evan Chengdc614c12006-06-06 23:30:24 +000016
Reid Klecknerce009332014-12-22 23:58:37 +000017#include "llvm/CodeGen/CallingConvLower.h"
Evan Chengdc614c12006-06-06 23:30:24 +000018#include "llvm/CodeGen/MachineFunction.h"
Reid Kleckner16e55412014-08-29 21:42:08 +000019#include "llvm/CodeGen/MachineValueType.h"
Evan Chengdc614c12006-06-06 23:30:24 +000020
21namespace llvm {
22
Dan Gohman6f873b42009-04-15 01:20:18 +000023/// X86MachineFunctionInfo - This class is derived from MachineFunction and
24/// contains private X86 target-specific information for each MachineFunction.
Chris Lattnerff0598d2007-04-17 17:21:52 +000025class X86MachineFunctionInfo : public MachineFunctionInfo {
David Blaikiea379b1812011-12-20 02:50:00 +000026 virtual void anchor();
27
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000028 /// ForceFramePointer - True if the function is required to use of frame
Chad Rosier24c19d22012-08-01 18:39:17 +000029 /// pointer for reasons other than it containing dynamic allocation or
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000030 /// that FP eliminatation is turned off. For example, Cygwin main function
31 /// contains stack pointer re-alignment code which requires FP.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000032 bool ForceFramePointer = false;
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000033
Michael Liao5bf95782014-12-04 05:20:33 +000034 /// RestoreBasePointerOffset - Non-zero if the function has base pointer
35 /// and makes call to llvm.eh.sjlj.setjmp. When non-zero, the value is a
36 /// displacement from the frame pointer to a slot where the base pointer
37 /// is stashed.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000038 signed char RestoreBasePointerOffset = 0;
Michael Liao5bf95782014-12-04 05:20:33 +000039
Evan Cheng9ae2eb42007-07-17 07:59:08 +000040 /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
41 /// stack frame in bytes.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000042 unsigned CalleeSavedFrameSize = 0;
Evan Cheng9ae2eb42007-07-17 07:59:08 +000043
Dan Gohman31ae5862010-04-17 14:41:14 +000044 /// BytesToPopOnReturn - Number of bytes function pops on return (in addition
45 /// to the space used by the return address).
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000046 /// Used on windows platform for stdcall & fastcall name decoration
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000047 unsigned BytesToPopOnReturn = 0;
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000048
Evan Chengf55b7382008-01-05 00:41:47 +000049 /// ReturnAddrIndex - FrameIndex for return slot.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000050 int ReturnAddrIndex = 0;
Arnold Schwaighofer9ccea992007-10-11 19:40:01 +000051
David Majnemer13d0b112015-02-10 21:22:05 +000052 /// \brief FrameIndex for return slot.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000053 int FrameAddrIndex = 0;
David Majnemer13d0b112015-02-10 21:22:05 +000054
Evan Chengd064aef2010-02-06 03:28:46 +000055 /// TailCallReturnAddrDelta - The number of bytes by which return address
56 /// stack slot is moved as the result of tail call optimization.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000057 int TailCallReturnAddrDelta = 0;
Arnold Schwaighofer9ccea992007-10-11 19:40:01 +000058
Dan Gohmanf166d2d2008-04-21 23:59:07 +000059 /// SRetReturnReg - Some subtargets require that sret lowering includes
60 /// returning the value of the returned struct in a register. This field
61 /// holds the virtual register into which the sret argument is passed.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000062 unsigned SRetReturnReg = 0;
Dan Gohmanf166d2d2008-04-21 23:59:07 +000063
Dan Gohman0d1e9a82008-10-03 15:45:36 +000064 /// GlobalBaseReg - keeps track of the virtual register initialized for
65 /// use as the global base register. This is used for PIC in some PIC
66 /// relocation models.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000067 unsigned GlobalBaseReg = 0;
Dan Gohman6ebe7342008-09-30 00:58:23 +000068
Dan Gohman31ae5862010-04-17 14:41:14 +000069 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000070 int VarArgsFrameIndex = 0;
Dan Gohman31ae5862010-04-17 14:41:14 +000071 /// RegSaveFrameIndex - X86-64 vararg func register save area.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000072 int RegSaveFrameIndex = 0;
Dan Gohman31ae5862010-04-17 14:41:14 +000073 /// VarArgsGPOffset - X86-64 vararg func int reg offset.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000074 unsigned VarArgsGPOffset = 0;
Dan Gohman31ae5862010-04-17 14:41:14 +000075 /// VarArgsFPOffset - X86-64 vararg func fp reg offset.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000076 unsigned VarArgsFPOffset = 0;
Rafael Espindolac2174212011-08-30 19:39:58 +000077 /// ArgumentStackSize - The number of bytes on stack consumed by the arguments
78 /// being passed on the stack.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000079 unsigned ArgumentStackSize = 0;
Hans Wennborg789acfb2012-06-01 16:27:21 +000080 /// NumLocalDynamics - Number of local-dynamic TLS accesses.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000081 unsigned NumLocalDynamics = 0;
Michael Kuperstein13fbd452015-02-01 16:56:04 +000082 /// HasPushSequences - Keeps track of whether this function uses sequences
83 /// of pushes to pass function parameters.
Reid Kleckneraf04c2a2015-07-07 18:12:06 +000084 bool HasPushSequences = false;
Dan Gohman31ae5862010-04-17 14:41:14 +000085
Reid Klecknerd7045fa2015-12-15 21:41:34 +000086 /// True if the function recovers from an SEH exception, and therefore needs
87 /// to spill and restore the frame pointer.
Reid Klecknere69bdb82015-07-07 23:45:58 +000088 bool HasSEHFramePtrSave = false;
89
90 /// The frame index of a stack object containing the original frame pointer
91 /// used to address arguments in a function using a base pointer.
92 int SEHFramePtrSaveIndex = 0;
93
Manman Rened967f32016-01-12 01:08:46 +000094 /// True if this function has a subset of CSRs that is handled explicitly via
95 /// copies.
96 bool IsSplitCSR = false;
97
Hans Wennborg4ae51192016-03-25 01:10:56 +000098 /// True if this function uses the red zone.
99 bool UsesRedZone = false;
100
Hans Wennborg8eb336c2016-05-18 16:10:17 +0000101 /// True if this function has WIN_ALLOCA instructions.
102 bool HasWinAlloca = false;
103
Reid Kleckner16e55412014-08-29 21:42:08 +0000104private:
105 /// ForwardedMustTailRegParms - A list of virtual and physical registers
106 /// that must be forwarded to every musttail call.
Reid Klecknerce009332014-12-22 23:58:37 +0000107 SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
Reid Kleckner16e55412014-08-29 21:42:08 +0000108
109public:
Reid Kleckneraf04c2a2015-07-07 18:12:06 +0000110 X86MachineFunctionInfo() = default;
Chad Rosier24c19d22012-08-01 18:39:17 +0000111
Hans Wennborg13958b72015-07-22 20:46:11 +0000112 explicit X86MachineFunctionInfo(MachineFunction &MF) {}
Chad Rosier97c22142012-07-10 18:27:15 +0000113
Chad Rosier24c19d22012-08-01 18:39:17 +0000114 bool getForceFramePointer() const { return ForceFramePointer;}
Evan Chengdc614c12006-06-06 23:30:24 +0000115 void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +0000116
Michael Kuperstein13fbd452015-02-01 16:56:04 +0000117 bool getHasPushSequences() const { return HasPushSequences; }
118 void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; }
119
Michael Liaod8faa612014-12-04 00:56:38 +0000120 bool getRestoreBasePointer() const { return RestoreBasePointerOffset!=0; }
121 void setRestoreBasePointer(const MachineFunction *MF);
122 int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset; }
123
Evan Cheng9ae2eb42007-07-17 07:59:08 +0000124 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
125 void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
126
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +0000127 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
128 void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
129
Anton Korobeynikov597c8b72007-08-15 17:12:32 +0000130 int getRAIndex() const { return ReturnAddrIndex; }
131 void setRAIndex(int Index) { ReturnAddrIndex = Index; }
Arnold Schwaighofer9ccea992007-10-11 19:40:01 +0000132
David Majnemer13d0b112015-02-10 21:22:05 +0000133 int getFAIndex() const { return FrameAddrIndex; }
134 void setFAIndex(int Index) { FrameAddrIndex = Index; }
135
Arnold Schwaighofer9ccea992007-10-11 19:40:01 +0000136 int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
137 void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
Dan Gohmanf166d2d2008-04-21 23:59:07 +0000138
139 unsigned getSRetReturnReg() const { return SRetReturnReg; }
140 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohman6ebe7342008-09-30 00:58:23 +0000141
142 unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
143 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
Jim Grosbach4dac8902010-04-06 20:26:37 +0000144
Dan Gohman31ae5862010-04-17 14:41:14 +0000145 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
146 void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; }
147
148 int getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
149 void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; }
150
151 unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; }
152 void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; }
153
154 unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; }
155 void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; }
Rafael Espindolac2174212011-08-30 19:39:58 +0000156
157 unsigned getArgumentStackSize() const { return ArgumentStackSize; }
158 void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
Hans Wennborg789acfb2012-06-01 16:27:21 +0000159
160 unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
161 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
Chad Rosier97c22142012-07-10 18:27:15 +0000162
Reid Klecknere69bdb82015-07-07 23:45:58 +0000163 bool getHasSEHFramePtrSave() const { return HasSEHFramePtrSave; }
164 void setHasSEHFramePtrSave(bool V) { HasSEHFramePtrSave = V; }
165
166 int getSEHFramePtrSaveIndex() const { return SEHFramePtrSaveIndex; }
167 void setSEHFramePtrSaveIndex(int Index) { SEHFramePtrSaveIndex = Index; }
168
Reid Klecknerce009332014-12-22 23:58:37 +0000169 SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {
Reid Kleckner16e55412014-08-29 21:42:08 +0000170 return ForwardedMustTailRegParms;
171 }
Manman Rened967f32016-01-12 01:08:46 +0000172
173 bool isSplitCSR() const { return IsSplitCSR; }
174 void setIsSplitCSR(bool s) { IsSplitCSR = s; }
Hans Wennborg4ae51192016-03-25 01:10:56 +0000175
176 bool getUsesRedZone() const { return UsesRedZone; }
177 void setUsesRedZone(bool V) { UsesRedZone = V; }
Hans Wennborg8eb336c2016-05-18 16:10:17 +0000178
179 bool hasWinAlloca() const { return HasWinAlloca; }
180 void setHasWinAlloca(bool v) { HasWinAlloca = v; }
Evan Chengdc614c12006-06-06 23:30:24 +0000181};
Dan Gohman6f873b42009-04-15 01:20:18 +0000182
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000183} // End llvm namespace
Evan Chengdc614c12006-06-06 23:30:24 +0000184
185#endif