blob: a916c6372eabb4960fb262ef7bd5ae1997f0ba52 [file] [log] [blame]
Evan Chenge8bd0a32006-06-06 23:30:24 +00001//====- X86MachineFuctionInfo.h - X86 machine function info -----*- C++ -*-===//
2//
3// 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.
Evan Chenge8bd0a32006-06-06 23:30:24 +00007//
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
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 {
Anton Korobeynikovf8248682006-09-20 22:03:51 +000024 /// 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.
Evan Chenge5e228d2006-06-09 06:25:10 +000028 bool ForceFramePointer;
Anton Korobeynikovf8248682006-09-20 22:03:51 +000029
Evan Cheng89d16592007-07-17 07:59:08 +000030 /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
31 /// stack frame in bytes.
32 unsigned CalleeSavedFrameSize;
33
Evan Cheng0475ab52008-01-05 00:41:47 +000034 /// BytesToPopOnReturn - Number of bytes function pops on return.
Anton Korobeynikovf8248682006-09-20 22:03:51 +000035 /// Used on windows platform for stdcall & fastcall name decoration
36 unsigned BytesToPopOnReturn;
37
Evan Cheng0475ab52008-01-05 00:41:47 +000038 /// ReturnAddrIndex - FrameIndex for return slot.
Anton Korobeynikova2780e12007-08-15 17:12:32 +000039 int ReturnAddrIndex;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000040
Evan Chengf22f9b32010-02-06 03:28:46 +000041 /// TailCallReturnAddrDelta - The number of bytes by which return address
42 /// stack slot is moved as the result of tail call optimization.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000043 int TailCallReturnAddrDelta;
44
Dan Gohman61a92132008-04-21 23:59:07 +000045 /// 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
Dan Gohmand735b802008-10-03 15:45:36 +000050 /// 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.
Dan Gohman57c3dac2008-09-30 00:58:23 +000053 unsigned GlobalBaseReg;
54
Jim Grosbachfa85eb62010-04-06 20:26:37 +000055 /// 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
Evan Chenge8bd0a32006-06-06 23:30:24 +000059public:
Chris Lattnerd15dff22007-04-17 17:21:52 +000060 X86MachineFunctionInfo() : ForceFramePointer(false),
Evan Cheng89d16592007-07-17 07:59:08 +000061 CalleeSavedFrameSize(0),
Chris Lattnerd15dff22007-04-17 17:21:52 +000062 BytesToPopOnReturn(0),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000063 ReturnAddrIndex(0),
Dan Gohman61a92132008-04-21 23:59:07 +000064 TailCallReturnAddrDelta(0),
Dan Gohman57c3dac2008-09-30 00:58:23 +000065 SRetReturnReg(0),
66 GlobalBaseReg(0) {}
Anton Korobeynikovf8248682006-09-20 22:03:51 +000067
Dan Gohman2392efe2009-06-05 23:05:51 +000068 explicit X86MachineFunctionInfo(MachineFunction &MF)
69 : ForceFramePointer(false),
70 CalleeSavedFrameSize(0),
71 BytesToPopOnReturn(0),
Dan Gohman2392efe2009-06-05 23:05:51 +000072 ReturnAddrIndex(0),
73 TailCallReturnAddrDelta(0),
74 SRetReturnReg(0),
Jim Grosbachfa85eb62010-04-06 20:26:37 +000075 GlobalBaseReg(0),
76 ReserveFP(false) {}
Anton Korobeynikovf8248682006-09-20 22:03:51 +000077
Evan Chenge8bd0a32006-06-06 23:30:24 +000078 bool getForceFramePointer() const { return ForceFramePointer;}
79 void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
Anton Korobeynikovf8248682006-09-20 22:03:51 +000080
Evan Cheng89d16592007-07-17 07:59:08 +000081 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
82 void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
83
Anton Korobeynikovf8248682006-09-20 22:03:51 +000084 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
85 void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
86
Anton Korobeynikova2780e12007-08-15 17:12:32 +000087 int getRAIndex() const { return ReturnAddrIndex; }
88 void setRAIndex(int Index) { ReturnAddrIndex = Index; }
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000089
90 int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
91 void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
Dan Gohman61a92132008-04-21 23:59:07 +000092
93 unsigned getSRetReturnReg() const { return SRetReturnReg; }
94 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohman57c3dac2008-09-30 00:58:23 +000095
96 unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
97 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
Jim Grosbachfa85eb62010-04-06 20:26:37 +000098
99 bool getReserveFP() const { return ReserveFP; }
100 void setReserveFP(bool reserveFP) { ReserveFP = reserveFP; }
Evan Chenge8bd0a32006-06-06 23:30:24 +0000101};
Dan Gohman6288b932009-04-15 01:20:18 +0000102
Evan Chenge8bd0a32006-06-06 23:30:24 +0000103} // End llvm namespace
104
105#endif