1 //=- LoongArchMachineFunctionInfo.h - LoongArch machine function info -----===// 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 LoongArch-specific per-machine-function information. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHMACHINEFUNCTIONINFO_H 14 #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHMACHINEFUNCTIONINFO_H 15 16 #include "LoongArchSubtarget.h" 17 #include "llvm/CodeGen/MachineFrameInfo.h" 18 #include "llvm/CodeGen/MachineFunction.h" 19 20 namespace llvm { 21 22 /// LoongArchMachineFunctionInfo - This class is derived from 23 /// MachineFunctionInfo and contains private LoongArch-specific information for 24 /// each MachineFunction. 25 class LoongArchMachineFunctionInfo : public MachineFunctionInfo { 26 private: 27 /// FrameIndex for start of varargs area 28 int VarArgsFrameIndex = 0; 29 /// Size of the save area used for varargs 30 int VarArgsSaveSize = 0; 31 32 /// Size of stack frame to save callee saved registers 33 unsigned CalleeSavedStackSize = 0; 34 35 /// FrameIndex of the spill slot when there is no scavenged register in 36 /// insertIndirectBranch. 37 int BranchRelaxationSpillFrameIndex = -1; 38 39 /// Registers that have been sign extended from i32. 40 SmallVector<Register, 8> SExt32Registers; 41 42 /// Pairs of `jr` instructions and corresponding JTI operands, used for the 43 /// `annotate-tablejump` option. 44 SmallVector<std::pair<MachineInstr *, int>, 4> JumpInfos; 45 46 public: LoongArchMachineFunctionInfo(const Function & F,const TargetSubtargetInfo * STI)47 LoongArchMachineFunctionInfo(const Function &F, 48 const TargetSubtargetInfo *STI) {} 49 50 MachineFunctionInfo * clone(BumpPtrAllocator & Allocator,MachineFunction & DestMF,const DenseMap<MachineBasicBlock *,MachineBasicBlock * > & Src2DstMBB)51 clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, 52 const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB) 53 const override { 54 return DestMF.cloneInfo<LoongArchMachineFunctionInfo>(*this); 55 } 56 getVarArgsFrameIndex()57 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } setVarArgsFrameIndex(int Index)58 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } 59 getVarArgsSaveSize()60 unsigned getVarArgsSaveSize() const { return VarArgsSaveSize; } setVarArgsSaveSize(int Size)61 void setVarArgsSaveSize(int Size) { VarArgsSaveSize = Size; } 62 getCalleeSavedStackSize()63 unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; } setCalleeSavedStackSize(unsigned Size)64 void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; } 65 getBranchRelaxationSpillFrameIndex()66 int getBranchRelaxationSpillFrameIndex() { 67 return BranchRelaxationSpillFrameIndex; 68 } setBranchRelaxationSpillFrameIndex(int Index)69 void setBranchRelaxationSpillFrameIndex(int Index) { 70 BranchRelaxationSpillFrameIndex = Index; 71 } 72 addSExt32Register(Register Reg)73 void addSExt32Register(Register Reg) { SExt32Registers.push_back(Reg); } 74 isSExt32Register(Register Reg)75 bool isSExt32Register(Register Reg) const { 76 return is_contained(SExt32Registers, Reg); 77 } 78 setJumpInfo(MachineInstr * JrMI,int JTIIdx)79 void setJumpInfo(MachineInstr *JrMI, int JTIIdx) { 80 JumpInfos.push_back(std::make_pair(JrMI, JTIIdx)); 81 } getJumpInfoSize()82 unsigned getJumpInfoSize() { return JumpInfos.size(); } getJumpInfoJrMI(unsigned Idx)83 MachineInstr *getJumpInfoJrMI(unsigned Idx) { return JumpInfos[Idx].first; } getJumpInfoJTIIndex(unsigned Idx)84 int getJumpInfoJTIIndex(unsigned Idx) { return JumpInfos[Idx].second; } 85 }; 86 87 } // end namespace llvm 88 89 #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHMACHINEFUNCTIONINFO_H 90