LLVM API Documentation

X86MachineFunctionInfo.h
Go to the documentation of this file.
00001 //===-- X86MachineFuctionInfo.h - X86 machine function info -----*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares X86-specific per-machine-function information.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
00015 #define LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
00016 
00017 #include "llvm/CodeGen/MachineFunction.h"
00018 #include "llvm/CodeGen/MachineValueType.h"
00019 #include <vector>
00020 
00021 namespace llvm {
00022 
00023 /// X86MachineFunctionInfo - This class is derived from MachineFunction and
00024 /// contains private X86 target-specific information for each MachineFunction.
00025 class X86MachineFunctionInfo : public MachineFunctionInfo {
00026   virtual void anchor();
00027 
00028   /// ForceFramePointer - True if the function is required to use of frame
00029   /// pointer for reasons other than it containing dynamic allocation or
00030   /// that FP eliminatation is turned off. For example, Cygwin main function
00031   /// contains stack pointer re-alignment code which requires FP.
00032   bool ForceFramePointer;
00033 
00034   /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
00035   /// stack frame in bytes.
00036   unsigned CalleeSavedFrameSize;
00037 
00038   /// BytesToPopOnReturn - Number of bytes function pops on return (in addition
00039   /// to the space used by the return address).
00040   /// Used on windows platform for stdcall & fastcall name decoration
00041   unsigned BytesToPopOnReturn;
00042 
00043   /// ReturnAddrIndex - FrameIndex for return slot.
00044   int ReturnAddrIndex;
00045 
00046   /// TailCallReturnAddrDelta - The number of bytes by which return address
00047   /// stack slot is moved as the result of tail call optimization.
00048   int TailCallReturnAddrDelta;
00049 
00050   /// SRetReturnReg - Some subtargets require that sret lowering includes
00051   /// returning the value of the returned struct in a register. This field
00052   /// holds the virtual register into which the sret argument is passed.
00053   unsigned SRetReturnReg;
00054 
00055   /// GlobalBaseReg - keeps track of the virtual register initialized for
00056   /// use as the global base register. This is used for PIC in some PIC
00057   /// relocation models.
00058   unsigned GlobalBaseReg;
00059 
00060   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
00061   int VarArgsFrameIndex;
00062   /// RegSaveFrameIndex - X86-64 vararg func register save area.
00063   int RegSaveFrameIndex;
00064   /// VarArgsGPOffset - X86-64 vararg func int reg offset.
00065   unsigned VarArgsGPOffset;
00066   /// VarArgsFPOffset - X86-64 vararg func fp reg offset.
00067   unsigned VarArgsFPOffset;
00068   /// ArgumentStackSize - The number of bytes on stack consumed by the arguments
00069   /// being passed on the stack.
00070   unsigned ArgumentStackSize;
00071   /// NumLocalDynamics - Number of local-dynamic TLS accesses.
00072   unsigned NumLocalDynamics;
00073 
00074 public:
00075   /// Describes a register that needs to be forwarded from the prologue to a
00076   /// musttail call.
00077   struct Forward {
00078     Forward(unsigned VReg, MCPhysReg PReg, MVT VT)
00079         : VReg(VReg), PReg(PReg), VT(VT) {}
00080     unsigned VReg;
00081     MCPhysReg PReg;
00082     MVT VT;
00083   };
00084 
00085 private:
00086   /// ForwardedMustTailRegParms - A list of virtual and physical registers
00087   /// that must be forwarded to every musttail call.
00088   std::vector<Forward> ForwardedMustTailRegParms;
00089 
00090 public:
00091   X86MachineFunctionInfo() : ForceFramePointer(false),
00092                              CalleeSavedFrameSize(0),
00093                              BytesToPopOnReturn(0),
00094                              ReturnAddrIndex(0),
00095                              TailCallReturnAddrDelta(0),
00096                              SRetReturnReg(0),
00097                              GlobalBaseReg(0),
00098                              VarArgsFrameIndex(0),
00099                              RegSaveFrameIndex(0),
00100                              VarArgsGPOffset(0),
00101                              VarArgsFPOffset(0),
00102                              ArgumentStackSize(0),
00103                              NumLocalDynamics(0) {}
00104 
00105   explicit X86MachineFunctionInfo(MachineFunction &MF)
00106     : ForceFramePointer(false),
00107       CalleeSavedFrameSize(0),
00108       BytesToPopOnReturn(0),
00109       ReturnAddrIndex(0),
00110       TailCallReturnAddrDelta(0),
00111       SRetReturnReg(0),
00112       GlobalBaseReg(0),
00113       VarArgsFrameIndex(0),
00114       RegSaveFrameIndex(0),
00115       VarArgsGPOffset(0),
00116       VarArgsFPOffset(0),
00117       ArgumentStackSize(0),
00118       NumLocalDynamics(0) {}
00119 
00120   bool getForceFramePointer() const { return ForceFramePointer;}
00121   void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
00122 
00123   unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
00124   void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
00125 
00126   unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
00127   void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
00128 
00129   int getRAIndex() const { return ReturnAddrIndex; }
00130   void setRAIndex(int Index) { ReturnAddrIndex = Index; }
00131 
00132   int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
00133   void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
00134 
00135   unsigned getSRetReturnReg() const { return SRetReturnReg; }
00136   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
00137 
00138   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
00139   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
00140 
00141   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
00142   void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; }
00143 
00144   int getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
00145   void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; }
00146 
00147   unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; }
00148   void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; }
00149 
00150   unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; }
00151   void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; }
00152 
00153   unsigned getArgumentStackSize() const { return ArgumentStackSize; }
00154   void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
00155 
00156   unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
00157   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
00158 
00159   std::vector<Forward> &getForwardedMustTailRegParms() {
00160     return ForwardedMustTailRegParms;
00161   }
00162 };
00163 
00164 } // End llvm namespace
00165 
00166 #endif