1 //===-- MipsMachineFunctionInfo.h - Private data used for Mips ----*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the Mips specific subclass of MachineFunctionInfo.
12 //===----------------------------------------------------------------------===//
14 #ifndef MIPS_MACHINE_FUNCTION_INFO_H
15 #define MIPS_MACHINE_FUNCTION_INFO_H
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/VectorExtras.h"
20 #include "llvm/CodeGen/MachineFunction.h"
21 #include "llvm/CodeGen/MachineFrameInfo.h"
25 /// MipsFunctionInfo - This class is derived from MachineFunction private
26 /// Mips target-specific information for each MachineFunction.
27 class MipsFunctionInfo : public MachineFunctionInfo {
31 /// SRetReturnReg - Some subtargets require that sret lowering includes
32 /// returning the value of the returned struct in a register. This field
33 /// holds the virtual register into which the sret argument is passed.
34 unsigned SRetReturnReg;
36 /// GlobalBaseReg - keeps track of the virtual register initialized for
37 /// use as the global base register. This is used for PIC in some PIC
38 /// relocation models.
39 unsigned GlobalBaseReg;
41 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
42 int VarArgsFrameIndex;
44 // Range of frame object indices.
45 // InArgFIRange: Range of indices of all frame objects created during call to
46 // LowerFormalArguments.
47 // OutArgFIRange: Range of indices of all frame objects created during call to
48 // LowerCall except for the frame object for restoring $gp.
49 std::pair<int, int> InArgFIRange, OutArgFIRange;
50 int GPFI; // Index of the frame object for restoring $gp
51 mutable int DynAllocFI; // Frame index of dynamically allocated stack area.
52 unsigned MaxCallFrameSize;
55 MipsFunctionInfo(MachineFunction& MF)
56 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0),
57 VarArgsFrameIndex(0), InArgFIRange(std::make_pair(-1, 0)),
58 OutArgFIRange(std::make_pair(-1, 0)), GPFI(0), DynAllocFI(0),
62 bool isInArgFI(int FI) const {
63 return FI <= InArgFIRange.first && FI >= InArgFIRange.second;
65 void setLastInArgFI(int FI) { InArgFIRange.second = FI; }
67 bool isOutArgFI(int FI) const {
68 return FI <= OutArgFIRange.first && FI >= OutArgFIRange.second;
70 void extendOutArgFIRange(int FirstFI, int LastFI) {
71 if (!OutArgFIRange.second)
72 // this must be the first time this function was called.
73 OutArgFIRange.first = FirstFI;
74 OutArgFIRange.second = LastFI;
77 int getGPFI() const { return GPFI; }
78 void setGPFI(int FI) { GPFI = FI; }
79 bool needGPSaveRestore() const { return getGPFI(); }
80 bool isGPFI(int FI) const { return GPFI && GPFI == FI; }
82 // The first call to this function creates a frame object for dynamically
83 // allocated stack area.
84 int getDynAllocFI() const {
86 DynAllocFI = MF.getFrameInfo()->CreateFixedObject(4, 0, true);
90 bool isDynAllocFI(int FI) const { return DynAllocFI && DynAllocFI == FI; }
92 unsigned getSRetReturnReg() const { return SRetReturnReg; }
93 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
95 unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
96 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
98 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
99 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
101 unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
102 void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
105 } // end of namespace llvm
107 #endif // MIPS_MACHINE_FUNCTION_INFO_H