]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
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 | ||
1a4d82fc JJ |
14 | #ifndef LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H |
15 | #define LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H | |
223e47cc | 16 | |
1a4d82fc JJ |
17 | #include "Mips16HardFloatInfo.h" |
18 | #include "llvm/ADT/StringMap.h" | |
223e47cc | 19 | #include "llvm/CodeGen/MachineFrameInfo.h" |
970d7e83 | 20 | #include "llvm/CodeGen/MachineFunction.h" |
1a4d82fc JJ |
21 | #include "llvm/CodeGen/MachineMemOperand.h" |
22 | #include "llvm/CodeGen/PseudoSourceValue.h" | |
23 | #include "llvm/IR/GlobalValue.h" | |
24 | #include "llvm/IR/ValueMap.h" | |
223e47cc LB |
25 | #include "llvm/Target/TargetFrameLowering.h" |
26 | #include "llvm/Target/TargetMachine.h" | |
1a4d82fc JJ |
27 | #include <map> |
28 | #include <string> | |
223e47cc LB |
29 | #include <utility> |
30 | ||
31 | namespace llvm { | |
32 | ||
1a4d82fc JJ |
33 | /// \brief A class derived from PseudoSourceValue that represents a GOT entry |
34 | /// resolved by lazy-binding. | |
35 | class MipsCallEntry : public PseudoSourceValue { | |
36 | public: | |
37 | explicit MipsCallEntry(StringRef N); | |
38 | explicit MipsCallEntry(const GlobalValue *V); | |
39 | bool isConstant(const MachineFrameInfo *) const override; | |
40 | bool isAliased(const MachineFrameInfo *) const override; | |
41 | bool mayAlias(const MachineFrameInfo *) const override; | |
42 | ||
43 | private: | |
44 | void printCustom(raw_ostream &O) const override; | |
45 | #ifndef NDEBUG | |
46 | std::string Name; | |
47 | const GlobalValue *Val; | |
48 | #endif | |
49 | }; | |
50 | ||
223e47cc LB |
51 | /// MipsFunctionInfo - This class is derived from MachineFunction private |
52 | /// Mips target-specific information for each MachineFunction. | |
53 | class MipsFunctionInfo : public MachineFunctionInfo { | |
1a4d82fc JJ |
54 | public: |
55 | MipsFunctionInfo(MachineFunction &MF) | |
56 | : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0), | |
57 | VarArgsFrameIndex(0), CallsEhReturn(false), SaveS2(false), | |
58 | MoveF64ViaSpillFI(-1) {} | |
59 | ||
60 | ~MipsFunctionInfo(); | |
61 | ||
62 | unsigned getSRetReturnReg() const { return SRetReturnReg; } | |
63 | void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } | |
64 | ||
65 | bool globalBaseRegSet() const; | |
66 | unsigned getGlobalBaseReg(); | |
67 | ||
68 | bool mips16SPAliasRegSet() const; | |
69 | unsigned getMips16SPAliasReg(); | |
70 | ||
71 | int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } | |
72 | void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } | |
73 | ||
74 | bool hasByvalArg() const { return HasByvalArg; } | |
75 | void setFormalArgInfo(unsigned Size, bool HasByval) { | |
76 | IncomingArgSize = Size; | |
77 | HasByvalArg = HasByval; | |
78 | } | |
79 | ||
80 | unsigned getIncomingArgSize() const { return IncomingArgSize; } | |
81 | ||
82 | bool callsEhReturn() const { return CallsEhReturn; } | |
83 | void setCallsEhReturn() { CallsEhReturn = true; } | |
84 | ||
85 | void createEhDataRegsFI(); | |
86 | int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; } | |
87 | bool isEhDataRegFI(int FI) const; | |
88 | ||
89 | /// \brief Create a MachinePointerInfo that has a MipsCallEntr object | |
90 | /// representing a GOT entry for an external function. | |
91 | MachinePointerInfo callPtrInfo(StringRef Name); | |
92 | ||
93 | /// \brief Create a MachinePointerInfo that has a MipsCallEntr object | |
94 | /// representing a GOT entry for a global function. | |
95 | MachinePointerInfo callPtrInfo(const GlobalValue *Val); | |
96 | ||
97 | void setSaveS2() { SaveS2 = true; } | |
98 | bool hasSaveS2() const { return SaveS2; } | |
99 | ||
100 | int getMoveF64ViaSpillFI(const TargetRegisterClass *RC); | |
101 | ||
102 | std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *> | |
103 | StubsNeeded; | |
104 | ||
105 | private: | |
223e47cc LB |
106 | virtual void anchor(); |
107 | ||
108 | MachineFunction& MF; | |
109 | /// SRetReturnReg - Some subtargets require that sret lowering includes | |
110 | /// returning the value of the returned struct in a register. This field | |
111 | /// holds the virtual register into which the sret argument is passed. | |
112 | unsigned SRetReturnReg; | |
113 | ||
114 | /// GlobalBaseReg - keeps track of the virtual register initialized for | |
115 | /// use as the global base register. This is used for PIC in some PIC | |
116 | /// relocation models. | |
117 | unsigned GlobalBaseReg; | |
118 | ||
970d7e83 LB |
119 | /// Mips16SPAliasReg - keeps track of the virtual register initialized for |
120 | /// use as an alias for SP for use in load/store of halfword/byte from/to | |
121 | /// the stack | |
122 | unsigned Mips16SPAliasReg; | |
123 | ||
223e47cc LB |
124 | /// VarArgsFrameIndex - FrameIndex for start of varargs area. |
125 | int VarArgsFrameIndex; | |
126 | ||
970d7e83 LB |
127 | /// True if function has a byval argument. |
128 | bool HasByvalArg; | |
223e47cc | 129 | |
970d7e83 LB |
130 | /// Size of incoming argument area. |
131 | unsigned IncomingArgSize; | |
132 | ||
133 | /// CallsEhReturn - Whether the function calls llvm.eh.return. | |
134 | bool CallsEhReturn; | |
135 | ||
136 | /// Frame objects for spilling eh data registers. | |
137 | int EhDataRegFI[4]; | |
223e47cc | 138 | |
1a4d82fc JJ |
139 | // saveS2 |
140 | bool SaveS2; | |
970d7e83 | 141 | |
1a4d82fc JJ |
142 | /// FrameIndex for expanding BuildPairF64 nodes to spill and reload when the |
143 | /// O32 FPXX ABI is enabled. -1 is used to denote invalid index. | |
144 | int MoveF64ViaSpillFI; | |
223e47cc | 145 | |
1a4d82fc JJ |
146 | /// MipsCallEntry maps. |
147 | StringMap<const MipsCallEntry *> ExternalCallEntries; | |
148 | ValueMap<const GlobalValue *, const MipsCallEntry *> GlobalCallEntries; | |
223e47cc LB |
149 | }; |
150 | ||
151 | } // end of namespace llvm | |
152 | ||
1a4d82fc | 153 | #endif |