Speculatively revert 132758 and 132768 to try to fix the Windows buildbots.
[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/ADT/VectorExtras.h"
20 #include "llvm/CodeGen/MachineFunction.h"
21 #include "llvm/CodeGen/MachineFrameInfo.h"
22
23 namespace llvm {
24
25 /// MipsFunctionInfo - This class is derived from MachineFunction private
26 /// Mips target-specific information for each MachineFunction.
27 class MipsFunctionInfo : public MachineFunctionInfo {
28
29 private:
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   unsigned MaxCallFrameSize;
51
52   /// AtomicFrameIndex - To implement atomic.swap and atomic.cmp.swap
53   /// intrinsics, it is necessary to use a temporary stack location.
54   /// This field holds the frame index of this location.
55   int AtomicFrameIndex;
56 public:
57   MipsFunctionInfo(MachineFunction& MF)
58   : SRetReturnReg(0), GlobalBaseReg(0),
59     VarArgsFrameIndex(0), InArgFIRange(std::make_pair(-1, 0)),
60     OutArgFIRange(std::make_pair(-1, 0)), GPFI(0), MaxCallFrameSize(0),
61     AtomicFrameIndex(-1)
62   {}
63
64   bool isInArgFI(int FI) const {
65     return FI <= InArgFIRange.first && FI >= InArgFIRange.second;
66   }
67   void setLastInArgFI(int FI) { InArgFIRange.second = FI; }
68
69   bool isOutArgFI(int FI) const { 
70     return FI <= OutArgFIRange.first && FI >= OutArgFIRange.second;
71   }
72   void extendOutArgFIRange(int FirstFI, int LastFI) {
73     if (!OutArgFIRange.second)
74       // this must be the first time this function was called.
75       OutArgFIRange.first = FirstFI;
76     OutArgFIRange.second = LastFI;
77   }
78
79   int getGPFI() const { return GPFI; }
80   void setGPFI(int FI) { GPFI = FI; }
81   bool needGPSaveRestore() const { return getGPFI(); }
82   bool isGPFI(int FI) const { return GPFI && GPFI == FI; }
83
84   unsigned getSRetReturnReg() const { return SRetReturnReg; }
85   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
86
87   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
88   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
89
90   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
91   void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
92
93   unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
94   void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
95
96   int getAtomicFrameIndex() const { return AtomicFrameIndex; }
97   void setAtomicFrameIndex(int Index) { AtomicFrameIndex = Index; }
98 };
99
100 } // end of namespace llvm
101
102 #endif // MIPS_MACHINE_FUNCTION_INFO_H