10b57cec5SDimitry Andric //===- MipsMachineFunctionInfo.h - Private data used for Mips ---*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file declares the Mips specific subclass of MachineFunctionInfo. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H 140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "Mips16HardFloatInfo.h" 170b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunction.h" 180b57cec5SDimitry Andric #include "llvm/CodeGen/MachineMemOperand.h" 190b57cec5SDimitry Andric #include <map> 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric namespace llvm { 220b57cec5SDimitry Andric 230b57cec5SDimitry Andric /// MipsFunctionInfo - This class is derived from MachineFunction private 240b57cec5SDimitry Andric /// Mips target-specific information for each MachineFunction. 250b57cec5SDimitry Andric class MipsFunctionInfo : public MachineFunctionInfo { 260b57cec5SDimitry Andric public: MipsFunctionInfo(const Function & F,const TargetSubtargetInfo * STI)27*bdd1243dSDimitry Andric MipsFunctionInfo(const Function &F, const TargetSubtargetInfo *STI) {} 280b57cec5SDimitry Andric 2981ad6265SDimitry Andric MachineFunctionInfo * 3081ad6265SDimitry Andric clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, 3181ad6265SDimitry Andric const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB) 3281ad6265SDimitry Andric const override; 3381ad6265SDimitry Andric 340b57cec5SDimitry Andric ~MipsFunctionInfo() override; 350b57cec5SDimitry Andric getSRetReturnReg()360b57cec5SDimitry Andric unsigned getSRetReturnReg() const { return SRetReturnReg; } setSRetReturnReg(unsigned Reg)370b57cec5SDimitry Andric void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric bool globalBaseRegSet() const; 405ffd83dbSDimitry Andric Register getGlobalBaseReg(MachineFunction &MF); 415ffd83dbSDimitry Andric Register getGlobalBaseRegForGlobalISel(MachineFunction &MF); 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric // Insert instructions to initialize the global base register in the 440b57cec5SDimitry Andric // first MBB of the function. 455ffd83dbSDimitry Andric void initGlobalBaseReg(MachineFunction &MF); 460b57cec5SDimitry Andric getVarArgsFrameIndex()470b57cec5SDimitry Andric int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } setVarArgsFrameIndex(int Index)480b57cec5SDimitry Andric void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } 490b57cec5SDimitry Andric hasByvalArg()500b57cec5SDimitry Andric bool hasByvalArg() const { return HasByvalArg; } setFormalArgInfo(unsigned Size,bool HasByval)510b57cec5SDimitry Andric void setFormalArgInfo(unsigned Size, bool HasByval) { 520b57cec5SDimitry Andric IncomingArgSize = Size; 530b57cec5SDimitry Andric HasByvalArg = HasByval; 540b57cec5SDimitry Andric } 550b57cec5SDimitry Andric getIncomingArgSize()560b57cec5SDimitry Andric unsigned getIncomingArgSize() const { return IncomingArgSize; } 570b57cec5SDimitry Andric callsEhReturn()580b57cec5SDimitry Andric bool callsEhReturn() const { return CallsEhReturn; } setCallsEhReturn()590b57cec5SDimitry Andric void setCallsEhReturn() { CallsEhReturn = true; } 600b57cec5SDimitry Andric 615ffd83dbSDimitry Andric void createEhDataRegsFI(MachineFunction &MF); getEhDataRegFI(unsigned Reg)620b57cec5SDimitry Andric int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; } 630b57cec5SDimitry Andric bool isEhDataRegFI(int FI) const; 640b57cec5SDimitry Andric 650b57cec5SDimitry Andric /// Create a MachinePointerInfo that has an ExternalSymbolPseudoSourceValue 660b57cec5SDimitry Andric /// object representing a GOT entry for an external function. 675ffd83dbSDimitry Andric MachinePointerInfo callPtrInfo(MachineFunction &MF, const char *ES); 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric // Functions with the "interrupt" attribute require special prologues, 700b57cec5SDimitry Andric // epilogues and additional spill slots. isISR()710b57cec5SDimitry Andric bool isISR() const { return IsISR; } setISR()720b57cec5SDimitry Andric void setISR() { IsISR = true; } 735ffd83dbSDimitry Andric void createISRRegFI(MachineFunction &MF); getISRRegFI(Register Reg)745ffd83dbSDimitry Andric int getISRRegFI(Register Reg) const { return ISRDataRegFI[Reg]; } 750b57cec5SDimitry Andric bool isISRRegFI(int FI) const; 760b57cec5SDimitry Andric 770b57cec5SDimitry Andric /// Create a MachinePointerInfo that has a GlobalValuePseudoSourceValue object 780b57cec5SDimitry Andric /// representing a GOT entry for a global function. 795ffd83dbSDimitry Andric MachinePointerInfo callPtrInfo(MachineFunction &MF, const GlobalValue *GV); 800b57cec5SDimitry Andric setSaveS2()810b57cec5SDimitry Andric void setSaveS2() { SaveS2 = true; } hasSaveS2()820b57cec5SDimitry Andric bool hasSaveS2() const { return SaveS2; } 830b57cec5SDimitry Andric 845ffd83dbSDimitry Andric int getMoveF64ViaSpillFI(MachineFunction &MF, const TargetRegisterClass *RC); 850b57cec5SDimitry Andric 860b57cec5SDimitry Andric std::map<const char *, const Mips16HardFloatInfo::FuncSignature *> 870b57cec5SDimitry Andric StubsNeeded; 880b57cec5SDimitry Andric 890b57cec5SDimitry Andric private: 900b57cec5SDimitry Andric virtual void anchor(); 910b57cec5SDimitry Andric 920b57cec5SDimitry Andric /// SRetReturnReg - Some subtargets require that sret lowering includes 930b57cec5SDimitry Andric /// returning the value of the returned struct in a register. This field 940b57cec5SDimitry Andric /// holds the virtual register into which the sret argument is passed. 955ffd83dbSDimitry Andric Register SRetReturnReg; 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric /// GlobalBaseReg - keeps track of the virtual register initialized for 980b57cec5SDimitry Andric /// use as the global base register. This is used for PIC in some PIC 990b57cec5SDimitry Andric /// relocation models. 1005ffd83dbSDimitry Andric Register GlobalBaseReg; 1010b57cec5SDimitry Andric 1020b57cec5SDimitry Andric /// VarArgsFrameIndex - FrameIndex for start of varargs area. 1030b57cec5SDimitry Andric int VarArgsFrameIndex = 0; 1040b57cec5SDimitry Andric 1050b57cec5SDimitry Andric /// True if function has a byval argument. 1060b57cec5SDimitry Andric bool HasByvalArg; 1070b57cec5SDimitry Andric 1080b57cec5SDimitry Andric /// Size of incoming argument area. 1090b57cec5SDimitry Andric unsigned IncomingArgSize; 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric /// CallsEhReturn - Whether the function calls llvm.eh.return. 1120b57cec5SDimitry Andric bool CallsEhReturn = false; 1130b57cec5SDimitry Andric 1140b57cec5SDimitry Andric /// Frame objects for spilling eh data registers. 1150b57cec5SDimitry Andric int EhDataRegFI[4]; 1160b57cec5SDimitry Andric 1170b57cec5SDimitry Andric /// ISR - Whether the function is an Interrupt Service Routine. 1180b57cec5SDimitry Andric bool IsISR = false; 1190b57cec5SDimitry Andric 1200b57cec5SDimitry Andric /// Frame objects for spilling C0_STATUS, C0_EPC 1210b57cec5SDimitry Andric int ISRDataRegFI[2]; 1220b57cec5SDimitry Andric 1230b57cec5SDimitry Andric // saveS2 1240b57cec5SDimitry Andric bool SaveS2 = false; 1250b57cec5SDimitry Andric 1260b57cec5SDimitry Andric /// FrameIndex for expanding BuildPairF64 nodes to spill and reload when the 1270b57cec5SDimitry Andric /// O32 FPXX ABI is enabled. -1 is used to denote invalid index. 1280b57cec5SDimitry Andric int MoveF64ViaSpillFI = -1; 1290b57cec5SDimitry Andric }; 1300b57cec5SDimitry Andric 1310b57cec5SDimitry Andric } // end namespace llvm 1320b57cec5SDimitry Andric 1330b57cec5SDimitry Andric #endif // LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H 134