Remove VectorExtras. This unused helper was written for a type of API that is discour...
[oota-llvm.git] / lib / Target / Mips / MipsMachineFunction.h
1 //===-- MipsMachineFunctionInfo.h - Private data used for Mips ----*- 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 the Mips specific subclass of MachineFunctionInfo.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef MIPS_MACHINE_FUNCTION_INFO_H
15 #define MIPS_MACHINE_FUNCTION_INFO_H
16
17 #include <utility>
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/CodeGen/MachineFunction.h"
20 #include "llvm/CodeGen/MachineFrameInfo.h"
21
22 namespace llvm {
23
24 /// MipsFunctionInfo - This class is derived from MachineFunction private
25 /// Mips target-specific information for each MachineFunction.
26 class MipsFunctionInfo : public MachineFunctionInfo {
27   virtual void anchor();
28
29   MachineFunction& MF;
30   /// SRetReturnReg - Some subtargets require that sret lowering includes
31   /// returning the value of the returned struct in a register. This field
32   /// holds the virtual register into which the sret argument is passed.
33   unsigned SRetReturnReg;
34
35   /// GlobalBaseReg - keeps track of the virtual register initialized for
36   /// use as the global base register. This is used for PIC in some PIC
37   /// relocation models.
38   unsigned GlobalBaseReg;
39
40   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
41   int VarArgsFrameIndex;
42
43   // Range of frame object indices.
44   // InArgFIRange: Range of indices of all frame objects created during call to
45   //               LowerFormalArguments.
46   // OutArgFIRange: Range of indices of all frame objects created during call to
47   //                LowerCall except for the frame object for restoring $gp. 
48   std::pair<int, int> InArgFIRange, OutArgFIRange;
49   int GPFI; // Index of the frame object for restoring $gp 
50   mutable int DynAllocFI; // Frame index of dynamically allocated stack area.   
51   unsigned MaxCallFrameSize;
52
53 public:
54   MipsFunctionInfo(MachineFunction& MF)
55   : MF(MF), SRetReturnReg(0), GlobalBaseReg(0),
56     VarArgsFrameIndex(0), InArgFIRange(std::make_pair(-1, 0)),
57     OutArgFIRange(std::make_pair(-1, 0)), GPFI(0), DynAllocFI(0),
58     MaxCallFrameSize(0)
59   {}
60
61   bool isInArgFI(int FI) const {
62     return FI <= InArgFIRange.first && FI >= InArgFIRange.second;
63   }
64   void setLastInArgFI(int FI) { InArgFIRange.second = FI; }
65
66   bool isOutArgFI(int FI) const { 
67     return FI <= OutArgFIRange.first && FI >= OutArgFIRange.second;
68   }
69   void extendOutArgFIRange(int FirstFI, int LastFI) {
70     if (!OutArgFIRange.second)
71       // this must be the first time this function was called.
72       OutArgFIRange.first = FirstFI;
73     OutArgFIRange.second = LastFI;
74   }
75
76   int getGPFI() const { return GPFI; }
77   void setGPFI(int FI) { GPFI = FI; }
78   bool needGPSaveRestore() const { return getGPFI(); }
79   bool isGPFI(int FI) const { return GPFI && GPFI == FI; }
80
81   // The first call to this function creates a frame object for dynamically
82   // allocated stack area.
83   int getDynAllocFI() const {
84     if (!DynAllocFI)
85       DynAllocFI = MF.getFrameInfo()->CreateFixedObject(4, 0, true);
86
87     return DynAllocFI;
88   }
89   bool isDynAllocFI(int FI) const { return DynAllocFI && DynAllocFI == FI; }
90
91   unsigned getSRetReturnReg() const { return SRetReturnReg; }
92   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
93
94   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
95   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
96
97   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
98   void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
99
100   unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
101   void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
102 };
103
104 } // end of namespace llvm
105
106 #endif // MIPS_MACHINE_FUNCTION_INFO_H