blob: bb53bf14ceaa4ada288227056b6edc1eed507c15 [file] [log] [blame]
Evan Chengdc614c12006-06-06 23:30:24 +00001//====- X86MachineFuctionInfo.h - X86 machine function info -----*- C++ -*-===//
2//
3// 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.
Evan Chengdc614c12006-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 Korobeynikov3c5b3df2006-09-20 22:03:51 +000021enum NameDecorationStyle {
22 None,
23 StdCall,
24 FastCall
25};
26
Dan Gohman6f873b42009-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 Lattnerff0598d2007-04-17 17:21:52 +000029class X86MachineFunctionInfo : public MachineFunctionInfo {
Anton Korobeynikov3c5b3df2006-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 Chengbeedf822006-06-09 06:25:10 +000034 bool ForceFramePointer;
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000035
Evan Cheng9ae2eb42007-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 Chengf55b7382008-01-05 00:41:47 +000040 /// BytesToPopOnReturn - Number of bytes function pops on return.
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000041 /// Used on windows platform for stdcall & fastcall name decoration
42 unsigned BytesToPopOnReturn;
43
Evan Chengf55b7382008-01-05 00:41:47 +000044 /// DecorationStyle - If the function requires additional name decoration,
45 /// DecorationStyle holds the right way to do so.
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000046 NameDecorationStyle DecorationStyle;
Anton Korobeynikov597c8b72007-08-15 17:12:32 +000047
Evan Chengf55b7382008-01-05 00:41:47 +000048 /// ReturnAddrIndex - FrameIndex for return slot.
Anton Korobeynikov597c8b72007-08-15 17:12:32 +000049 int ReturnAddrIndex;
Arnold Schwaighofer9ccea992007-10-11 19:40:01 +000050
Evan Chengd064aef2010-02-06 03:28:46 +000051 /// TailCallReturnAddrDelta - The number of bytes by which return address
52 /// stack slot is moved as the result of tail call optimization.
Arnold Schwaighofer9ccea992007-10-11 19:40:01 +000053 int TailCallReturnAddrDelta;
54
Dan Gohmanf166d2d2008-04-21 23:59:07 +000055 /// SRetReturnReg - Some subtargets require that sret lowering includes
56 /// returning the value of the returned struct in a register. This field
57 /// holds the virtual register into which the sret argument is passed.
58 unsigned SRetReturnReg;
59
Dan Gohman0d1e9a82008-10-03 15:45:36 +000060 /// GlobalBaseReg - keeps track of the virtual register initialized for
61 /// use as the global base register. This is used for PIC in some PIC
62 /// relocation models.
Dan Gohman6ebe7342008-09-30 00:58:23 +000063 unsigned GlobalBaseReg;
64
Evan Chengdc614c12006-06-06 23:30:24 +000065public:
Chris Lattnerff0598d2007-04-17 17:21:52 +000066 X86MachineFunctionInfo() : ForceFramePointer(false),
Evan Cheng9ae2eb42007-07-17 07:59:08 +000067 CalleeSavedFrameSize(0),
Chris Lattnerff0598d2007-04-17 17:21:52 +000068 BytesToPopOnReturn(0),
Anton Korobeynikov597c8b72007-08-15 17:12:32 +000069 DecorationStyle(None),
Arnold Schwaighofer9ccea992007-10-11 19:40:01 +000070 ReturnAddrIndex(0),
Dan Gohmanf166d2d2008-04-21 23:59:07 +000071 TailCallReturnAddrDelta(0),
Dan Gohman6ebe7342008-09-30 00:58:23 +000072 SRetReturnReg(0),
73 GlobalBaseReg(0) {}
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000074
Dan Gohmand185a7a2009-06-05 23:05:51 +000075 explicit X86MachineFunctionInfo(MachineFunction &MF)
76 : ForceFramePointer(false),
77 CalleeSavedFrameSize(0),
78 BytesToPopOnReturn(0),
79 DecorationStyle(None),
80 ReturnAddrIndex(0),
81 TailCallReturnAddrDelta(0),
82 SRetReturnReg(0),
83 GlobalBaseReg(0) {}
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000084
Evan Chengdc614c12006-06-06 23:30:24 +000085 bool getForceFramePointer() const { return ForceFramePointer;}
86 void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000087
Evan Cheng9ae2eb42007-07-17 07:59:08 +000088 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
89 void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
90
Anton Korobeynikov3c5b3df2006-09-20 22:03:51 +000091 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
92 void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
93
94 NameDecorationStyle getDecorationStyle() const { return DecorationStyle; }
95 void setDecorationStyle(NameDecorationStyle style) { DecorationStyle = style;}
Anton Korobeynikov597c8b72007-08-15 17:12:32 +000096
97 int getRAIndex() const { return ReturnAddrIndex; }
98 void setRAIndex(int Index) { ReturnAddrIndex = Index; }
Arnold Schwaighofer9ccea992007-10-11 19:40:01 +000099
100 int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
101 void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
Dan Gohmanf166d2d2008-04-21 23:59:07 +0000102
103 unsigned getSRetReturnReg() const { return SRetReturnReg; }
104 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohman6ebe7342008-09-30 00:58:23 +0000105
106 unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
107 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
Evan Chengdc614c12006-06-06 23:30:24 +0000108};
Dan Gohman6f873b42009-04-15 01:20:18 +0000109
Evan Chengdc614c12006-06-06 23:30:24 +0000110} // End llvm namespace
111
112#endif