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
17 #include "llvm/CodeGen/MachineFunction.h"
18 #include "llvm/CodeGen/MachineFrameInfo.h"
23 /// MipsFunctionInfo - This class is derived from MachineFunction private
24 /// Mips target-specific information for each MachineFunction.
25 class MipsFunctionInfo : public MachineFunctionInfo {
26 virtual void anchor();
29 /// SRetReturnReg - Some subtargets require that sret lowering includes
30 /// returning the value of the returned struct in a register. This field
31 /// holds the virtual register into which the sret argument is passed.
32 unsigned SRetReturnReg;
34 /// GlobalBaseReg - keeps track of the virtual register initialized for
35 /// use as the global base register. This is used for PIC in some PIC
36 /// relocation models.
37 unsigned GlobalBaseReg;
39 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
40 int VarArgsFrameIndex;
42 // Range of frame object indices.
43 // InArgFIRange: Range of indices of all frame objects created during call to
44 // LowerFormalArguments.
45 // OutArgFIRange: Range of indices of all frame objects created during call to
46 // LowerCall except for the frame object for restoring $gp.
47 std::pair<int, int> InArgFIRange, OutArgFIRange;
48 int GPFI; // Index of the frame object for restoring $gp
49 mutable int DynAllocFI; // Frame index of dynamically allocated stack area.
50 unsigned MaxCallFrameSize;
53 MipsFunctionInfo(MachineFunction& MF)
54 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0),
55 VarArgsFrameIndex(0), InArgFIRange(std::make_pair(-1, 0)),
56 OutArgFIRange(std::make_pair(-1, 0)), GPFI(0), DynAllocFI(0),
60 bool isInArgFI(int FI) const {
61 return FI <= InArgFIRange.first && FI >= InArgFIRange.second;
63 void setLastInArgFI(int FI) { InArgFIRange.second = FI; }
65 bool isOutArgFI(int FI) const {
66 return FI <= OutArgFIRange.first && FI >= OutArgFIRange.second;
68 void extendOutArgFIRange(int FirstFI, int LastFI) {
69 if (!OutArgFIRange.second)
70 // this must be the first time this function was called.
71 OutArgFIRange.first = FirstFI;
72 OutArgFIRange.second = LastFI;
75 int getGPFI() const { return GPFI; }
76 void setGPFI(int FI) { GPFI = FI; }
77 bool needGPSaveRestore() const { return getGPFI(); }
78 bool isGPFI(int FI) const { return GPFI && GPFI == FI; }
80 // The first call to this function creates a frame object for dynamically
81 // allocated stack area.
82 int getDynAllocFI() const {
84 DynAllocFI = MF.getFrameInfo()->CreateFixedObject(4, 0, true);
88 bool isDynAllocFI(int FI) const { return DynAllocFI && DynAllocFI == FI; }
90 unsigned getSRetReturnReg() const { return SRetReturnReg; }
91 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
93 bool globalBaseRegFixed() const;
94 bool globalBaseRegSet() const;
95 unsigned getGlobalBaseReg();
97 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
98 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
100 unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
101 void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
104 } // end of namespace llvm
106 #endif // MIPS_MACHINE_FUNCTION_INFO_H