xref: /netbsd-src/external/apache2/llvm/dist/llvm/lib/Target/Mips/MipsMachineFunction.h (revision 82d56013d7b633d116a93943de88e08335357a7c)
17330f729Sjoerg //===- MipsMachineFunctionInfo.h - Private data used for Mips ---*- C++ -*-===//
27330f729Sjoerg //
37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67330f729Sjoerg //
77330f729Sjoerg //===----------------------------------------------------------------------===//
87330f729Sjoerg //
97330f729Sjoerg // This file declares the Mips specific subclass of MachineFunctionInfo.
107330f729Sjoerg //
117330f729Sjoerg //===----------------------------------------------------------------------===//
127330f729Sjoerg 
137330f729Sjoerg #ifndef LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
147330f729Sjoerg #define LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
157330f729Sjoerg 
167330f729Sjoerg #include "Mips16HardFloatInfo.h"
177330f729Sjoerg #include "llvm/CodeGen/MachineFunction.h"
187330f729Sjoerg #include "llvm/CodeGen/MachineMemOperand.h"
197330f729Sjoerg #include <map>
207330f729Sjoerg 
217330f729Sjoerg namespace llvm {
227330f729Sjoerg 
237330f729Sjoerg /// MipsFunctionInfo - This class is derived from MachineFunction private
247330f729Sjoerg /// Mips target-specific information for each MachineFunction.
257330f729Sjoerg class MipsFunctionInfo : public MachineFunctionInfo {
267330f729Sjoerg public:
MipsFunctionInfo(MachineFunction & MF)27*82d56013Sjoerg   MipsFunctionInfo(MachineFunction &MF) {}
287330f729Sjoerg 
297330f729Sjoerg   ~MipsFunctionInfo() override;
307330f729Sjoerg 
getSRetReturnReg()317330f729Sjoerg   unsigned getSRetReturnReg() const { return SRetReturnReg; }
setSRetReturnReg(unsigned Reg)327330f729Sjoerg   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
337330f729Sjoerg 
347330f729Sjoerg   bool globalBaseRegSet() const;
35*82d56013Sjoerg   Register getGlobalBaseReg(MachineFunction &MF);
36*82d56013Sjoerg   Register getGlobalBaseRegForGlobalISel(MachineFunction &MF);
377330f729Sjoerg 
387330f729Sjoerg   // Insert instructions to initialize the global base register in the
397330f729Sjoerg   // first MBB of the function.
40*82d56013Sjoerg   void initGlobalBaseReg(MachineFunction &MF);
417330f729Sjoerg 
getVarArgsFrameIndex()427330f729Sjoerg   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
setVarArgsFrameIndex(int Index)437330f729Sjoerg   void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
447330f729Sjoerg 
hasByvalArg()457330f729Sjoerg   bool hasByvalArg() const { return HasByvalArg; }
setFormalArgInfo(unsigned Size,bool HasByval)467330f729Sjoerg   void setFormalArgInfo(unsigned Size, bool HasByval) {
477330f729Sjoerg     IncomingArgSize = Size;
487330f729Sjoerg     HasByvalArg = HasByval;
497330f729Sjoerg   }
507330f729Sjoerg 
getIncomingArgSize()517330f729Sjoerg   unsigned getIncomingArgSize() const { return IncomingArgSize; }
527330f729Sjoerg 
callsEhReturn()537330f729Sjoerg   bool callsEhReturn() const { return CallsEhReturn; }
setCallsEhReturn()547330f729Sjoerg   void setCallsEhReturn() { CallsEhReturn = true; }
557330f729Sjoerg 
56*82d56013Sjoerg   void createEhDataRegsFI(MachineFunction &MF);
getEhDataRegFI(unsigned Reg)577330f729Sjoerg   int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
587330f729Sjoerg   bool isEhDataRegFI(int FI) const;
597330f729Sjoerg 
607330f729Sjoerg   /// Create a MachinePointerInfo that has an ExternalSymbolPseudoSourceValue
617330f729Sjoerg   /// object representing a GOT entry for an external function.
62*82d56013Sjoerg   MachinePointerInfo callPtrInfo(MachineFunction &MF, const char *ES);
637330f729Sjoerg 
647330f729Sjoerg   // Functions with the "interrupt" attribute require special prologues,
657330f729Sjoerg   // epilogues and additional spill slots.
isISR()667330f729Sjoerg   bool isISR() const { return IsISR; }
setISR()677330f729Sjoerg   void setISR() { IsISR = true; }
68*82d56013Sjoerg   void createISRRegFI(MachineFunction &MF);
getISRRegFI(Register Reg)69*82d56013Sjoerg   int getISRRegFI(Register Reg) const { return ISRDataRegFI[Reg]; }
707330f729Sjoerg   bool isISRRegFI(int FI) const;
717330f729Sjoerg 
727330f729Sjoerg   /// Create a MachinePointerInfo that has a GlobalValuePseudoSourceValue object
737330f729Sjoerg   /// representing a GOT entry for a global function.
74*82d56013Sjoerg   MachinePointerInfo callPtrInfo(MachineFunction &MF, const GlobalValue *GV);
757330f729Sjoerg 
setSaveS2()767330f729Sjoerg   void setSaveS2() { SaveS2 = true; }
hasSaveS2()777330f729Sjoerg   bool hasSaveS2() const { return SaveS2; }
787330f729Sjoerg 
79*82d56013Sjoerg   int getMoveF64ViaSpillFI(MachineFunction &MF, const TargetRegisterClass *RC);
807330f729Sjoerg 
817330f729Sjoerg   std::map<const char *, const Mips16HardFloatInfo::FuncSignature *>
827330f729Sjoerg   StubsNeeded;
837330f729Sjoerg 
847330f729Sjoerg private:
857330f729Sjoerg   virtual void anchor();
867330f729Sjoerg 
877330f729Sjoerg   /// SRetReturnReg - Some subtargets require that sret lowering includes
887330f729Sjoerg   /// returning the value of the returned struct in a register. This field
897330f729Sjoerg   /// holds the virtual register into which the sret argument is passed.
90*82d56013Sjoerg   Register SRetReturnReg;
917330f729Sjoerg 
927330f729Sjoerg   /// GlobalBaseReg - keeps track of the virtual register initialized for
937330f729Sjoerg   /// use as the global base register. This is used for PIC in some PIC
947330f729Sjoerg   /// relocation models.
95*82d56013Sjoerg   Register GlobalBaseReg;
967330f729Sjoerg 
977330f729Sjoerg   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
987330f729Sjoerg   int VarArgsFrameIndex = 0;
997330f729Sjoerg 
1007330f729Sjoerg   /// True if function has a byval argument.
1017330f729Sjoerg   bool HasByvalArg;
1027330f729Sjoerg 
1037330f729Sjoerg   /// Size of incoming argument area.
1047330f729Sjoerg   unsigned IncomingArgSize;
1057330f729Sjoerg 
1067330f729Sjoerg   /// CallsEhReturn - Whether the function calls llvm.eh.return.
1077330f729Sjoerg   bool CallsEhReturn = false;
1087330f729Sjoerg 
1097330f729Sjoerg   /// Frame objects for spilling eh data registers.
1107330f729Sjoerg   int EhDataRegFI[4];
1117330f729Sjoerg 
1127330f729Sjoerg   /// ISR - Whether the function is an Interrupt Service Routine.
1137330f729Sjoerg   bool IsISR = false;
1147330f729Sjoerg 
1157330f729Sjoerg   /// Frame objects for spilling C0_STATUS, C0_EPC
1167330f729Sjoerg   int ISRDataRegFI[2];
1177330f729Sjoerg 
1187330f729Sjoerg   // saveS2
1197330f729Sjoerg   bool SaveS2 = false;
1207330f729Sjoerg 
1217330f729Sjoerg   /// FrameIndex for expanding BuildPairF64 nodes to spill and reload when the
1227330f729Sjoerg   /// O32 FPXX ABI is enabled. -1 is used to denote invalid index.
1237330f729Sjoerg   int MoveF64ViaSpillFI = -1;
1247330f729Sjoerg };
1257330f729Sjoerg 
1267330f729Sjoerg } // end namespace llvm
1277330f729Sjoerg 
1287330f729Sjoerg #endif // LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
129