LLVM API Documentation

PPCMachineFunctionInfo.h
Go to the documentation of this file.
00001 //===-- PPCMachineFunctionInfo.h - Private data used for PowerPC --*- 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 the PowerPC specific subclass of MachineFunctionInfo.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_LIB_TARGET_POWERPC_PPCMACHINEFUNCTIONINFO_H
00015 #define LLVM_LIB_TARGET_POWERPC_PPCMACHINEFUNCTIONINFO_H
00016 
00017 #include "llvm/CodeGen/MachineFunction.h"
00018 
00019 namespace llvm {
00020 
00021 /// PPCFunctionInfo - This class is derived from MachineFunction private
00022 /// PowerPC target-specific information for each MachineFunction.
00023 class PPCFunctionInfo : public MachineFunctionInfo {
00024   virtual void anchor();
00025 
00026   /// FramePointerSaveIndex - Frame index of where the old frame pointer is
00027   /// stored.  Also used as an anchor for instructions that need to be altered
00028   /// when using frame pointers (dyna_add, dyna_sub.)
00029   int FramePointerSaveIndex;
00030   
00031   /// ReturnAddrSaveIndex - Frame index of where the return address is stored.
00032   ///
00033   int ReturnAddrSaveIndex;
00034 
00035   /// Frame index where the old base pointer is stored.
00036   int BasePointerSaveIndex;
00037 
00038   /// MustSaveLR - Indicates whether LR is defined (or clobbered) in the current
00039   /// function.  This is only valid after the initial scan of the function by
00040   /// PEI.
00041   bool MustSaveLR;
00042 
00043   /// Does this function have any stack spills.
00044   bool HasSpills;
00045 
00046   /// Does this function spill using instructions with only r+r (not r+i)
00047   /// forms.
00048   bool HasNonRISpills;
00049 
00050   /// SpillsCR - Indicates whether CR is spilled in the current function.
00051   bool SpillsCR;
00052 
00053   /// Indicates whether VRSAVE is spilled in the current function.
00054   bool SpillsVRSAVE;
00055 
00056   /// LRStoreRequired - The bool indicates whether there is some explicit use of
00057   /// the LR/LR8 stack slot that is not obvious from scanning the code.  This
00058   /// requires that the code generator produce a store of LR to the stack on
00059   /// entry, even though LR may otherwise apparently not be used.
00060   bool LRStoreRequired;
00061 
00062   /// MinReservedArea - This is the frame size that is at least reserved in a
00063   /// potential caller (parameter+linkage area).
00064   unsigned MinReservedArea;
00065 
00066   /// TailCallSPDelta - Stack pointer delta used when tail calling. Maximum
00067   /// amount the stack pointer is adjusted to make the frame bigger for tail
00068   /// calls. Used for creating an area before the register spill area.
00069   int TailCallSPDelta;
00070 
00071   /// HasFastCall - Does this function contain a fast call. Used to determine
00072   /// how the caller's stack pointer should be calculated (epilog/dynamicalloc).
00073   bool HasFastCall;
00074 
00075   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
00076   int VarArgsFrameIndex;
00077   /// VarArgsStackOffset - StackOffset for start of stack
00078   /// arguments.
00079   int VarArgsStackOffset;
00080   /// VarArgsNumGPR - Index of the first unused integer
00081   /// register for parameter passing.
00082   unsigned VarArgsNumGPR;
00083   /// VarArgsNumFPR - Index of the first unused double
00084   /// register for parameter passing.
00085   unsigned VarArgsNumFPR;
00086 
00087   /// CRSpillFrameIndex - FrameIndex for CR spill slot for 32-bit SVR4.
00088   int CRSpillFrameIndex;
00089 
00090   /// If any of CR[2-4] need to be saved in the prologue and restored in the
00091   /// epilogue then they are added to this array. This is used for the
00092   /// 64-bit SVR4 ABI.
00093   SmallVector<unsigned, 3> MustSaveCRs;
00094 
00095   /// Hold onto our MachineFunction context.
00096   MachineFunction &MF;
00097 
00098   /// Whether this uses the PIC Base register or not.
00099   bool UsesPICBase;
00100 
00101 public:
00102   explicit PPCFunctionInfo(MachineFunction &MF) 
00103     : FramePointerSaveIndex(0),
00104       ReturnAddrSaveIndex(0),
00105       BasePointerSaveIndex(0),
00106       HasSpills(false),
00107       HasNonRISpills(false),
00108       SpillsCR(false),
00109       SpillsVRSAVE(false),
00110       LRStoreRequired(false),
00111       MinReservedArea(0),
00112       TailCallSPDelta(0),
00113       HasFastCall(false),
00114       VarArgsFrameIndex(0),
00115       VarArgsStackOffset(0),
00116       VarArgsNumGPR(0),
00117       VarArgsNumFPR(0),
00118       CRSpillFrameIndex(0),
00119       MF(MF),
00120       UsesPICBase(0) {}
00121 
00122   int getFramePointerSaveIndex() const { return FramePointerSaveIndex; }
00123   void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; }
00124   
00125   int getReturnAddrSaveIndex() const { return ReturnAddrSaveIndex; }
00126   void setReturnAddrSaveIndex(int idx) { ReturnAddrSaveIndex = idx; }
00127 
00128   int getBasePointerSaveIndex() const { return BasePointerSaveIndex; }
00129   void setBasePointerSaveIndex(int Idx) { BasePointerSaveIndex = Idx; }
00130 
00131   unsigned getMinReservedArea() const { return MinReservedArea; }
00132   void setMinReservedArea(unsigned size) { MinReservedArea = size; }
00133 
00134   int getTailCallSPDelta() const { return TailCallSPDelta; }
00135   void setTailCallSPDelta(int size) { TailCallSPDelta = size; }
00136 
00137   /// MustSaveLR - This is set when the prolog/epilog inserter does its initial
00138   /// scan of the function. It is true if the LR/LR8 register is ever explicitly
00139   /// defined/clobbered in the machine function (e.g. by calls and movpctolr,
00140   /// which is used in PIC generation), or if the LR stack slot is explicitly
00141   /// referenced by builtin_return_address.
00142   void setMustSaveLR(bool U) { MustSaveLR = U; }
00143   bool mustSaveLR() const    { return MustSaveLR; }
00144 
00145   void setHasSpills()      { HasSpills = true; }
00146   bool hasSpills() const   { return HasSpills; }
00147 
00148   void setHasNonRISpills()    { HasNonRISpills = true; }
00149   bool hasNonRISpills() const { return HasNonRISpills; }
00150 
00151   void setSpillsCR()       { SpillsCR = true; }
00152   bool isCRSpilled() const { return SpillsCR; }
00153 
00154   void setSpillsVRSAVE()       { SpillsVRSAVE = true; }
00155   bool isVRSAVESpilled() const { return SpillsVRSAVE; }
00156 
00157   void setLRStoreRequired() { LRStoreRequired = true; }
00158   bool isLRStoreRequired() const { return LRStoreRequired; }
00159 
00160   void setHasFastCall() { HasFastCall = true; }
00161   bool hasFastCall() const { return HasFastCall;}
00162 
00163   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
00164   void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
00165 
00166   int getVarArgsStackOffset() const { return VarArgsStackOffset; }
00167   void setVarArgsStackOffset(int Offset) { VarArgsStackOffset = Offset; }
00168 
00169   unsigned getVarArgsNumGPR() const { return VarArgsNumGPR; }
00170   void setVarArgsNumGPR(unsigned Num) { VarArgsNumGPR = Num; }
00171 
00172   unsigned getVarArgsNumFPR() const { return VarArgsNumFPR; }
00173   void setVarArgsNumFPR(unsigned Num) { VarArgsNumFPR = Num; }
00174 
00175   int getCRSpillFrameIndex() const { return CRSpillFrameIndex; }
00176   void setCRSpillFrameIndex(int idx) { CRSpillFrameIndex = idx; }
00177 
00178   const SmallVectorImpl<unsigned> &
00179     getMustSaveCRs() const { return MustSaveCRs; }
00180   void addMustSaveCR(unsigned Reg) { MustSaveCRs.push_back(Reg); }
00181 
00182   void setUsesPICBase(bool uses) { UsesPICBase = uses; }
00183   bool usesPICBase() const { return UsesPICBase; }
00184 
00185   MCSymbol *getPICOffsetSymbol() const;
00186 };
00187 
00188 } // end of namespace llvm
00189 
00190 
00191 #endif