PPCMachineFunctionInfo.h revision 251662
143967Sache//===-- PPCMachineFunctionInfo.h - Private data used for PowerPC --*- C++ -*-=//
26527Sache//
36527Sache//                     The LLVM Compiler Infrastructure
46527Sache//
56527Sache// This file is distributed under the University of Illinois Open Source
66527Sache// License. See LICENSE.TXT for details.
76527Sache//
86527Sache//===----------------------------------------------------------------------===//
96527Sache//
106527Sache// This file declares the PowerPC specific subclass of MachineFunctionInfo.
116527Sache//
126527Sache//===----------------------------------------------------------------------===//
136527Sache
146527Sache#ifndef PPC_MACHINE_FUNCTION_INFO_H
156527Sache#define PPC_MACHINE_FUNCTION_INFO_H
166527Sache
176527Sache#include "llvm/CodeGen/MachineFunction.h"
186527Sache
196527Sachenamespace llvm {
206527Sache
216527Sache/// PPCFunctionInfo - This class is derived from MachineFunction private
226527Sache/// PowerPC target-specific information for each MachineFunction.
236527Sacheclass PPCFunctionInfo : public MachineFunctionInfo {
246527Sache  virtual void anchor();
256527Sache
266527Sache  /// FramePointerSaveIndex - Frame index of where the old frame pointer is
276527Sache  /// stored.  Also used as an anchor for instructions that need to be altered
286527Sache  /// when using frame pointers (dyna_add, dyna_sub.)
2943967Sache  int FramePointerSaveIndex;
306527Sache
316527Sache  /// ReturnAddrSaveIndex - Frame index of where the return address is stored.
3218950Sache  ///
336527Sache  int ReturnAddrSaveIndex;
346527Sache
356527Sache  /// MustSaveLR - Indicates whether LR is defined (or clobbered) in the current
366527Sache  /// function.  This is only valid after the initial scan of the function by
376527Sache  /// PEI.
3816073Sphk  bool MustSaveLR;
396527Sache
4043967Sache  /// Does this function have any stack spills.
416527Sache  bool HasSpills;
426527Sache
4318950Sache  /// Does this function spill using instructions with only r+r (not r+i)
4418955Sache  /// forms.
456527Sache  bool HasNonRISpills;
466527Sache
476527Sache  /// SpillsCR - Indicates whether CR is spilled in the current function.
486527Sache  bool SpillsCR;
496527Sache
506527Sache  /// Indicates whether VRSAVE is spilled in the current function.
5143967Sache  bool SpillsVRSAVE;
5243967Sache
5343967Sache  /// LRStoreRequired - The bool indicates whether there is some explicit use of
5443967Sache  /// the LR/LR8 stack slot that is not obvious from scanning the code.  This
556527Sache  /// requires that the code generator produce a store of LR to the stack on
566527Sache  /// entry, even though LR may otherwise apparently not be used.
5718950Sache  bool LRStoreRequired;
5843967Sache
5943967Sache  /// MinReservedArea - This is the frame size that is at least reserved in a
6043967Sache  /// potential caller (parameter+linkage area).
6143967Sache  unsigned MinReservedArea;
6243967Sache
6343967Sache  /// TailCallSPDelta - Stack pointer delta used when tail calling. Maximum
6443967Sache  /// amount the stack pointer is adjusted to make the frame bigger for tail
6543967Sache  /// calls. Used for creating an area before the register spill area.
6643967Sache  int TailCallSPDelta;
6718950Sache
6818950Sache  /// HasFastCall - Does this function contain a fast call. Used to determine
6918950Sache  /// how the caller's stack pointer should be calculated (epilog/dynamicalloc).
7018950Sache  bool HasFastCall;
7118950Sache
7218950Sache  /// VarArgsFrameIndex - FrameIndex for start of varargs area.
7318950Sache  int VarArgsFrameIndex;
7418950Sache  /// VarArgsStackOffset - StackOffset for start of stack
7518950Sache  /// arguments.
7618950Sache  int VarArgsStackOffset;
7718950Sache  /// VarArgsNumGPR - Index of the first unused integer
7818950Sache  /// register for parameter passing.
7918950Sache  unsigned VarArgsNumGPR;
8018950Sache  /// VarArgsNumFPR - Index of the first unused double
8143967Sache  /// register for parameter passing.
8218950Sache  unsigned VarArgsNumFPR;
8318950Sache
8418950Sache  /// CRSpillFrameIndex - FrameIndex for CR spill slot for 32-bit SVR4.
8543967Sache  int CRSpillFrameIndex;
866527Sache
876527Sache  /// If any of CR[2-4] need to be saved in the prologue and restored in the
886527Sache  /// epilogue then they are added to this array. This is used for the
896527Sache  /// 64-bit SVR4 ABI.
906527Sache  SmallVector<unsigned, 3> MustSaveCRs;
916527Sache
9243967Sachepublic:
936527Sache  explicit PPCFunctionInfo(MachineFunction &MF)
946527Sache    : FramePointerSaveIndex(0),
956527Sache      ReturnAddrSaveIndex(0),
966527Sache      HasSpills(false),
976527Sache      HasNonRISpills(false),
986527Sache      SpillsCR(false),
9918950Sache      SpillsVRSAVE(false),
1006527Sache      LRStoreRequired(false),
1016527Sache      MinReservedArea(0),
1026527Sache      TailCallSPDelta(0),
1036527Sache      HasFastCall(false),
1046527Sache      VarArgsFrameIndex(0),
10543940Sache      VarArgsStackOffset(0),
1066527Sache      VarArgsNumGPR(0),
1076527Sache      VarArgsNumFPR(0),
1086527Sache      CRSpillFrameIndex(0) {}
1096527Sache
11043967Sache  int getFramePointerSaveIndex() const { return FramePointerSaveIndex; }
11118950Sache  void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; }
11218950Sache
11318950Sache  int getReturnAddrSaveIndex() const { return ReturnAddrSaveIndex; }
11418950Sache  void setReturnAddrSaveIndex(int idx) { ReturnAddrSaveIndex = idx; }
11518950Sache
11618950Sache  unsigned getMinReservedArea() const { return MinReservedArea; }
11718950Sache  void setMinReservedArea(unsigned size) { MinReservedArea = size; }
11818950Sache
11918950Sache  int getTailCallSPDelta() const { return TailCallSPDelta; }
12018950Sache  void setTailCallSPDelta(int size) { TailCallSPDelta = size; }
12118950Sache
12218950Sache  /// MustSaveLR - This is set when the prolog/epilog inserter does its initial
12318950Sache  /// scan of the function. It is true if the LR/LR8 register is ever explicitly
1246527Sache  /// defined/clobbered in the machine function (e.g. by calls and movpctolr,
12543940Sache  /// which is used in PIC generation), or if the LR stack slot is explicitly
1266527Sache  /// referenced by builtin_return_address.
12718950Sache  void setMustSaveLR(bool U) { MustSaveLR = U; }
12818950Sache  bool mustSaveLR() const    { return MustSaveLR; }
12918950Sache
13018950Sache  void setHasSpills()      { HasSpills = true; }
13143940Sache  bool hasSpills() const   { return HasSpills; }
13218950Sache
1336527Sache  void setHasNonRISpills()    { HasNonRISpills = true; }
1346527Sache  bool hasNonRISpills() const { return HasNonRISpills; }
1356527Sache
1366527Sache  void setSpillsCR()       { SpillsCR = true; }
13743940Sache  bool isCRSpilled() const { return SpillsCR; }
1386527Sache
1396527Sache  void setSpillsVRSAVE()       { SpillsVRSAVE = true; }
1406527Sache  bool isVRSAVESpilled() const { return SpillsVRSAVE; }
1416527Sache
14218955Sache  void setLRStoreRequired() { LRStoreRequired = true; }
14318955Sache  bool isLRStoreRequired() const { return LRStoreRequired; }
14418950Sache
14518955Sache  void setHasFastCall() { HasFastCall = true; }
14618950Sache  bool hasFastCall() const { return HasFastCall;}
1476527Sache
14818955Sache  int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
14918955Sache  void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
15018955Sache
15118955Sache  int getVarArgsStackOffset() const { return VarArgsStackOffset; }
15218955Sache  void setVarArgsStackOffset(int Offset) { VarArgsStackOffset = Offset; }
15318955Sache
15418955Sache  unsigned getVarArgsNumGPR() const { return VarArgsNumGPR; }
15543967Sache  void setVarArgsNumGPR(unsigned Num) { VarArgsNumGPR = Num; }
15643967Sache
15743967Sache  unsigned getVarArgsNumFPR() const { return VarArgsNumFPR; }
15843967Sache  void setVarArgsNumFPR(unsigned Num) { VarArgsNumFPR = Num; }
15918955Sache
1606527Sache  int getCRSpillFrameIndex() const { return CRSpillFrameIndex; }
1616527Sache  void setCRSpillFrameIndex(int idx) { CRSpillFrameIndex = idx; }
1626527Sache
1636527Sache  const SmallVector<unsigned, 3> &
16443967Sache    getMustSaveCRs() const { return MustSaveCRs; }
1656527Sache  void addMustSaveCR(unsigned Reg) { MustSaveCRs.push_back(Reg); }
1666527Sache};
16718950Sache
16818950Sache} // end of namespace llvm
16918950Sache
17018950Sache
17118950Sache#endif
17218950Sache