blob: fafcf7e3d79ac8b49395a42f65842ef7cc0460a1 [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
Anton Korobeynikovf8248682006-09-20 22:03:51 +000021enum NameDecorationStyle {
22 None,
23 StdCall,
24 FastCall
25};
26
Dan Gohman6288b932009-04-15 01:20:18 +000027/// X86MachineFunctionInfo - This class is derived from MachineFunction and
28/// contains private X86 target-specific information for each MachineFunction.
Chris Lattnerd15dff22007-04-17 17:21:52 +000029class X86MachineFunctionInfo : public MachineFunctionInfo {
Anton Korobeynikovf8248682006-09-20 22:03:51 +000030 /// ForceFramePointer - True if the function is required to use of frame
31 /// pointer for reasons other than it containing dynamic allocation or
32 /// that FP eliminatation is turned off. For example, Cygwin main function
33 /// contains stack pointer re-alignment code which requires FP.
Evan Chenge5e228d2006-06-09 06:25:10 +000034 bool ForceFramePointer;
Anton Korobeynikovf8248682006-09-20 22:03:51 +000035
Evan Cheng89d16592007-07-17 07:59:08 +000036 /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
37 /// stack frame in bytes.
38 unsigned CalleeSavedFrameSize;
39
Evan Cheng0475ab52008-01-05 00:41:47 +000040 /// BytesToPopOnReturn - Number of bytes function pops on return.
Anton Korobeynikovf8248682006-09-20 22:03:51 +000041 /// Used on windows platform for stdcall & fastcall name decoration
42 unsigned BytesToPopOnReturn;
43
Evan Cheng0475ab52008-01-05 00:41:47 +000044 /// DecorationStyle - If the function requires additional name decoration,
45 /// DecorationStyle holds the right way to do so.
Anton Korobeynikovf8248682006-09-20 22:03:51 +000046 NameDecorationStyle DecorationStyle;
Anton Korobeynikova2780e12007-08-15 17:12:32 +000047
Evan Cheng0475ab52008-01-05 00:41:47 +000048 /// ReturnAddrIndex - FrameIndex for return slot.
Anton Korobeynikova2780e12007-08-15 17:12:32 +000049 int ReturnAddrIndex;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000050
Evan Cheng0475ab52008-01-05 00:41:47 +000051 /// TailCallReturnAddrDelta - Delta the ReturnAddr stack slot is moved
52 /// Used for creating an area before the register spill area on the stack
53 /// the returnaddr can be savely move to this area
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000054 int TailCallReturnAddrDelta;
55
Dan Gohman61a92132008-04-21 23:59:07 +000056 /// SRetReturnReg - Some subtargets require that sret lowering includes
57 /// returning the value of the returned struct in a register. This field
58 /// holds the virtual register into which the sret argument is passed.
59 unsigned SRetReturnReg;
60
Dan Gohmand735b802008-10-03 15:45:36 +000061 /// GlobalBaseReg - keeps track of the virtual register initialized for
62 /// use as the global base register. This is used for PIC in some PIC
63 /// relocation models.
Dan Gohman57c3dac2008-09-30 00:58:23 +000064 unsigned GlobalBaseReg;
65
Evan Chenge8bd0a32006-06-06 23:30:24 +000066public:
Chris Lattnerd15dff22007-04-17 17:21:52 +000067 X86MachineFunctionInfo() : ForceFramePointer(false),
Evan Cheng89d16592007-07-17 07:59:08 +000068 CalleeSavedFrameSize(0),
Chris Lattnerd15dff22007-04-17 17:21:52 +000069 BytesToPopOnReturn(0),
Anton Korobeynikova2780e12007-08-15 17:12:32 +000070 DecorationStyle(None),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000071 ReturnAddrIndex(0),
Dan Gohman61a92132008-04-21 23:59:07 +000072 TailCallReturnAddrDelta(0),
Dan Gohman57c3dac2008-09-30 00:58:23 +000073 SRetReturnReg(0),
74 GlobalBaseReg(0) {}
Anton Korobeynikovf8248682006-09-20 22:03:51 +000075
Dan Gohman2392efe2009-06-05 23:05:51 +000076 explicit X86MachineFunctionInfo(MachineFunction &MF)
77 : ForceFramePointer(false),
78 CalleeSavedFrameSize(0),
79 BytesToPopOnReturn(0),
80 DecorationStyle(None),
81 ReturnAddrIndex(0),
82 TailCallReturnAddrDelta(0),
83 SRetReturnReg(0),
84 GlobalBaseReg(0) {}
Anton Korobeynikovf8248682006-09-20 22:03:51 +000085
Evan Chenge8bd0a32006-06-06 23:30:24 +000086 bool getForceFramePointer() const { return ForceFramePointer;}
87 void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
Anton Korobeynikovf8248682006-09-20 22:03:51 +000088
Evan Cheng89d16592007-07-17 07:59:08 +000089 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
90 void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
91
Anton Korobeynikovf8248682006-09-20 22:03:51 +000092 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
93 void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
94
95 NameDecorationStyle getDecorationStyle() const { return DecorationStyle; }
96 void setDecorationStyle(NameDecorationStyle style) { DecorationStyle = style;}
Anton Korobeynikova2780e12007-08-15 17:12:32 +000097
98 int getRAIndex() const { return ReturnAddrIndex; }
99 void setRAIndex(int Index) { ReturnAddrIndex = Index; }
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000100
101 int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
102 void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
Dan Gohman61a92132008-04-21 23:59:07 +0000103
104 unsigned getSRetReturnReg() const { return SRetReturnReg; }
105 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohman57c3dac2008-09-30 00:58:23 +0000106
107 unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
108 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
Evan Chenge8bd0a32006-06-06 23:30:24 +0000109};
Dan Gohman6288b932009-04-15 01:20:18 +0000110
Evan Chenge8bd0a32006-06-06 23:30:24 +0000111} // End llvm namespace
112
113#endif