Home | History | Annotate | Download | only in X86
      1 //===-- X86MachineFunctionInfo.h - X86 machine function info ----*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file declares X86-specific per-machine-function information.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #ifndef LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
     15 #define LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
     16 
     17 #include "llvm/CodeGen/CallingConvLower.h"
     18 #include "llvm/CodeGen/MachineFunction.h"
     19 #include "llvm/CodeGen/MachineValueType.h"
     20 #include <vector>
     21 
     22 namespace llvm {
     23 
     24 /// X86MachineFunctionInfo - This class is derived from MachineFunction and
     25 /// contains private X86 target-specific information for each MachineFunction.
     26 class X86MachineFunctionInfo : public MachineFunctionInfo {
     27   virtual void anchor();
     28 
     29   /// ForceFramePointer - True if the function is required to use of frame
     30   /// pointer for reasons other than it containing dynamic allocation or
     31   /// that FP eliminatation is turned off. For example, Cygwin main function
     32   /// contains stack pointer re-alignment code which requires FP.
     33   bool ForceFramePointer = false;
     34 
     35   /// RestoreBasePointerOffset - Non-zero if the function has base pointer
     36   /// and makes call to llvm.eh.sjlj.setjmp. When non-zero, the value is a
     37   /// displacement from the frame pointer to a slot where the base pointer
     38   /// is stashed.
     39   signed char RestoreBasePointerOffset = 0;
     40 
     41   /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
     42   /// stack frame in bytes.
     43   unsigned CalleeSavedFrameSize = 0;
     44 
     45   /// BytesToPopOnReturn - Number of bytes function pops on return (in addition
     46   /// to the space used by the return address).
     47   /// Used on windows platform for stdcall & fastcall name decoration
     48   unsigned BytesToPopOnReturn = 0;
     49 
     50   /// ReturnAddrIndex - FrameIndex for return slot.
     51   int ReturnAddrIndex = 0;
     52 
     53   /// \brief FrameIndex for return slot.
     54   int FrameAddrIndex = 0;
     55 
     56   /// TailCallReturnAddrDelta - The number of bytes by which return address
     57   /// stack slot is moved as the result of tail call optimization.
     58   int TailCallReturnAddrDelta = 0;
     59 
     60   /// SRetReturnReg - Some subtargets require that sret lowering includes
     61   /// returning the value of the returned struct in a register. This field
     62   /// holds the virtual register into which the sret argument is passed.
     63   unsigned SRetReturnReg = 0;
     64 
     65   /// GlobalBaseReg - keeps track of the virtual register initialized for
     66   /// use as the global base register. This is used for PIC in some PIC
     67   /// relocation models.
     68   unsigned GlobalBaseReg = 0;
     69 
     70   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
     71   int VarArgsFrameIndex = 0;
     72   /// RegSaveFrameIndex - X86-64 vararg func register save area.
     73   int RegSaveFrameIndex = 0;
     74   /// VarArgsGPOffset - X86-64 vararg func int reg offset.
     75   unsigned VarArgsGPOffset = 0;
     76   /// VarArgsFPOffset - X86-64 vararg func fp reg offset.
     77   unsigned VarArgsFPOffset = 0;
     78   /// ArgumentStackSize - The number of bytes on stack consumed by the arguments
     79   /// being passed on the stack.
     80   unsigned ArgumentStackSize = 0;
     81   /// NumLocalDynamics - Number of local-dynamic TLS accesses.
     82   unsigned NumLocalDynamics = 0;
     83   /// HasPushSequences - Keeps track of whether this function uses sequences
     84   /// of pushes to pass function parameters.
     85   bool HasPushSequences = false;
     86 
     87   /// True if the function recovers from an SEH exception, and therefore needs
     88   /// to spill and restore the frame pointer.
     89   bool HasSEHFramePtrSave = false;
     90 
     91   /// The frame index of a stack object containing the original frame pointer
     92   /// used to address arguments in a function using a base pointer.
     93   int SEHFramePtrSaveIndex = 0;
     94 
     95 private:
     96   /// ForwardedMustTailRegParms - A list of virtual and physical registers
     97   /// that must be forwarded to every musttail call.
     98   SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
     99 
    100 public:
    101   X86MachineFunctionInfo() = default;
    102 
    103   explicit X86MachineFunctionInfo(MachineFunction &MF) {}
    104 
    105   bool getForceFramePointer() const { return ForceFramePointer;}
    106   void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
    107 
    108   bool getHasPushSequences() const { return HasPushSequences; }
    109   void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; }
    110 
    111   bool getRestoreBasePointer() const { return RestoreBasePointerOffset!=0; }
    112   void setRestoreBasePointer(const MachineFunction *MF);
    113   int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset; }
    114 
    115   unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
    116   void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
    117 
    118   unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
    119   void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
    120 
    121   int getRAIndex() const { return ReturnAddrIndex; }
    122   void setRAIndex(int Index) { ReturnAddrIndex = Index; }
    123 
    124   int getFAIndex() const { return FrameAddrIndex; }
    125   void setFAIndex(int Index) { FrameAddrIndex = Index; }
    126 
    127   int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
    128   void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
    129 
    130   unsigned getSRetReturnReg() const { return SRetReturnReg; }
    131   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
    132 
    133   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
    134   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
    135 
    136   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
    137   void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; }
    138 
    139   int getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
    140   void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; }
    141 
    142   unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; }
    143   void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; }
    144 
    145   unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; }
    146   void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; }
    147 
    148   unsigned getArgumentStackSize() const { return ArgumentStackSize; }
    149   void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
    150 
    151   unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
    152   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
    153 
    154   bool getHasSEHFramePtrSave() const { return HasSEHFramePtrSave; }
    155   void setHasSEHFramePtrSave(bool V) { HasSEHFramePtrSave = V; }
    156 
    157   int getSEHFramePtrSaveIndex() const { return SEHFramePtrSaveIndex; }
    158   void setSEHFramePtrSaveIndex(int Index) { SEHFramePtrSaveIndex = Index; }
    159 
    160   SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {
    161     return ForwardedMustTailRegParms;
    162   }
    163 };
    164 
    165 } // End llvm namespace
    166 
    167 #endif
    168