• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
15 #define LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
16 
17 #include "Mips16HardFloatInfo.h"
18 #include "llvm/CodeGen/MachineFrameInfo.h"
19 #include "llvm/CodeGen/MachineFunction.h"
20 #include "llvm/CodeGen/MachineMemOperand.h"
21 #include "llvm/CodeGen/PseudoSourceValue.h"
22 #include "llvm/Target/TargetFrameLowering.h"
23 #include "llvm/Target/TargetMachine.h"
24 #include <map>
25 
26 namespace llvm {
27 
28 /// MipsFunctionInfo - This class is derived from MachineFunction private
29 /// Mips target-specific information for each MachineFunction.
30 class MipsFunctionInfo : public MachineFunctionInfo {
31 public:
MipsFunctionInfo(MachineFunction & MF)32   MipsFunctionInfo(MachineFunction &MF)
33       : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), VarArgsFrameIndex(0),
34         CallsEhReturn(false), IsISR(false), SaveS2(false),
35         MoveF64ViaSpillFI(-1) {}
36 
37   ~MipsFunctionInfo();
38 
getSRetReturnReg()39   unsigned getSRetReturnReg() const { return SRetReturnReg; }
setSRetReturnReg(unsigned Reg)40   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
41 
42   bool globalBaseRegSet() const;
43   unsigned getGlobalBaseReg();
44 
getVarArgsFrameIndex()45   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
setVarArgsFrameIndex(int Index)46   void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
47 
hasByvalArg()48   bool hasByvalArg() const { return HasByvalArg; }
setFormalArgInfo(unsigned Size,bool HasByval)49   void setFormalArgInfo(unsigned Size, bool HasByval) {
50     IncomingArgSize = Size;
51     HasByvalArg = HasByval;
52   }
53 
getIncomingArgSize()54   unsigned getIncomingArgSize() const { return IncomingArgSize; }
55 
callsEhReturn()56   bool callsEhReturn() const { return CallsEhReturn; }
setCallsEhReturn()57   void setCallsEhReturn() { CallsEhReturn = true; }
58 
59   void createEhDataRegsFI();
getEhDataRegFI(unsigned Reg)60   int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
61   bool isEhDataRegFI(int FI) const;
62 
63   /// Create a MachinePointerInfo that has an ExternalSymbolPseudoSourceValue
64   /// object representing a GOT entry for an external function.
65   MachinePointerInfo callPtrInfo(const char *ES);
66 
67   // Functions with the "interrupt" attribute require special prologues,
68   // epilogues and additional spill slots.
isISR()69   bool isISR() const { return IsISR; }
setISR()70   void setISR() { IsISR = true; }
71   void createISRRegFI();
getISRRegFI(unsigned Reg)72   int getISRRegFI(unsigned Reg) const { return ISRDataRegFI[Reg]; }
73   bool isISRRegFI(int FI) const;
74 
75   /// Create a MachinePointerInfo that has a GlobalValuePseudoSourceValue object
76   /// representing a GOT entry for a global function.
77   MachinePointerInfo callPtrInfo(const GlobalValue *GV);
78 
setSaveS2()79   void setSaveS2() { SaveS2 = true; }
hasSaveS2()80   bool hasSaveS2() const { return SaveS2; }
81 
82   int getMoveF64ViaSpillFI(const TargetRegisterClass *RC);
83 
84   std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
85   StubsNeeded;
86 
87 private:
88   virtual void anchor();
89 
90   MachineFunction& MF;
91   /// SRetReturnReg - Some subtargets require that sret lowering includes
92   /// returning the value of the returned struct in a register. This field
93   /// holds the virtual register into which the sret argument is passed.
94   unsigned SRetReturnReg;
95 
96   /// GlobalBaseReg - keeps track of the virtual register initialized for
97   /// use as the global base register. This is used for PIC in some PIC
98   /// relocation models.
99   unsigned GlobalBaseReg;
100 
101   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
102   int VarArgsFrameIndex;
103 
104   /// True if function has a byval argument.
105   bool HasByvalArg;
106 
107   /// Size of incoming argument area.
108   unsigned IncomingArgSize;
109 
110   /// CallsEhReturn - Whether the function calls llvm.eh.return.
111   bool CallsEhReturn;
112 
113   /// Frame objects for spilling eh data registers.
114   int EhDataRegFI[4];
115 
116   /// ISR - Whether the function is an Interrupt Service Routine.
117   bool IsISR;
118 
119   /// Frame objects for spilling C0_STATUS, C0_EPC
120   int ISRDataRegFI[2];
121 
122   // saveS2
123   bool SaveS2;
124 
125   /// FrameIndex for expanding BuildPairF64 nodes to spill and reload when the
126   /// O32 FPXX ABI is enabled. -1 is used to denote invalid index.
127   int MoveF64ViaSpillFI;
128 };
129 
130 } // end of namespace llvm
131 
132 #endif
133