Change StackDirection from StackGrowsUp to StackGrowsDown.
[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   /// At each function entry, two special bitmask directives must be emitted
31   /// to help debugging, for CPU and FPU callee saved registers. Both need
32   /// the negative offset from the final stack size and its higher registers
33   /// location on the stack.
34   int CPUTopSavedRegOff;
35   int FPUTopSavedRegOff;
36
37   /// SRetReturnReg - Some subtargets require that sret lowering includes
38   /// returning the value of the returned struct in a register. This field
39   /// holds the virtual register into which the sret argument is passed.
40   unsigned SRetReturnReg;
41
42   /// GlobalBaseReg - keeps track of the virtual register initialized for
43   /// use as the global base register. This is used for PIC in some PIC
44   /// relocation models.
45   unsigned GlobalBaseReg;
46
47   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
48   int VarArgsFrameIndex;
49
50   // Range of frame object indices.
51   // InArgFIRange: Range of indices of all frame objects created during call to
52   //               LowerFormalArguments.
53   // OutArgFIRange: Range of indices of all frame objects created during call to
54   //                LowerCall except for the frame object for restoring $gp. 
55   std::pair<int, int> InArgFIRange, OutArgFIRange;
56   int GPFI; // Index of the frame object for restoring $gp 
57   bool HasCall; // True if function has a function call.
58   int MaxCallFrameSize;
59 public:
60   MipsFunctionInfo(MachineFunction& MF)
61   : CPUTopSavedRegOff(0),
62     FPUTopSavedRegOff(0), SRetReturnReg(0), GlobalBaseReg(0),
63     VarArgsFrameIndex(0), InArgFIRange(std::make_pair(-1, 0)),
64     OutArgFIRange(std::make_pair(-1, 0)), GPFI(0), HasCall(false),
65     MaxCallFrameSize(-1)
66   {}
67
68   int getCPUTopSavedRegOff() const { return CPUTopSavedRegOff; }
69   void setCPUTopSavedRegOff(int Off) { CPUTopSavedRegOff = Off; }
70
71   int getFPUTopSavedRegOff() const { return FPUTopSavedRegOff; }
72   void setFPUTopSavedRegOff(int Off) { FPUTopSavedRegOff = Off; }
73
74   bool isInArgFI(int FI) const {
75     return FI <= InArgFIRange.first && FI >= InArgFIRange.second;
76   }
77   void setLastInArgFI(int FI) { InArgFIRange.second = FI; }
78
79   bool isOutArgFI(int FI) const { 
80     return FI <= OutArgFIRange.first && FI >= OutArgFIRange.second;
81   }
82   void extendOutArgFIRange(int FirstFI, int LastFI) {
83     if (!OutArgFIRange.second)
84       // this must be the first time this function was called.
85       OutArgFIRange.first = FirstFI;
86     OutArgFIRange.second = LastFI;
87   }
88
89   int getGPFI() const { return GPFI; }
90   void setGPFI(int FI) { GPFI = FI; }
91   bool needGPSaveRestore() const { return getGPFI(); }
92   bool isGPFI(int FI) const { return GPFI && GPFI == FI; }
93
94   unsigned getSRetReturnReg() const { return SRetReturnReg; }
95   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
96
97   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
98   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
99
100   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
101   void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
102
103   bool hasCall() const { return HasCall; }
104   void setHasCall() { HasCall = true; }
105
106   int getMaxCallFrameSize() const { return MaxCallFrameSize; }
107   void setMaxCallFrameSize(int S) { MaxCallFrameSize = S; }
108 };
109
110 } // end of namespace llvm
111
112 #endif // MIPS_MACHINE_FUNCTION_INFO_H