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