xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchMachineFunctionInfo.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
181ad6265SDimitry Andric //=- LoongArchMachineFunctionInfo.h - LoongArch machine function info -----===//
281ad6265SDimitry Andric //
381ad6265SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
481ad6265SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
581ad6265SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
681ad6265SDimitry Andric //
781ad6265SDimitry Andric //===----------------------------------------------------------------------===//
881ad6265SDimitry Andric //
981ad6265SDimitry Andric // This file declares LoongArch-specific per-machine-function information.
1081ad6265SDimitry Andric //
1181ad6265SDimitry Andric //===----------------------------------------------------------------------===//
1281ad6265SDimitry Andric 
1381ad6265SDimitry Andric #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHMACHINEFUNCTIONINFO_H
1481ad6265SDimitry Andric #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHMACHINEFUNCTIONINFO_H
1581ad6265SDimitry Andric 
1681ad6265SDimitry Andric #include "LoongArchSubtarget.h"
1781ad6265SDimitry Andric #include "llvm/CodeGen/MachineFrameInfo.h"
1881ad6265SDimitry Andric #include "llvm/CodeGen/MachineFunction.h"
1981ad6265SDimitry Andric 
2081ad6265SDimitry Andric namespace llvm {
2181ad6265SDimitry Andric 
2281ad6265SDimitry Andric /// LoongArchMachineFunctionInfo - This class is derived from
2381ad6265SDimitry Andric /// MachineFunctionInfo and contains private LoongArch-specific information for
2481ad6265SDimitry Andric /// each MachineFunction.
2581ad6265SDimitry Andric class LoongArchMachineFunctionInfo : public MachineFunctionInfo {
2681ad6265SDimitry Andric private:
2781ad6265SDimitry Andric   /// FrameIndex for start of varargs area
2881ad6265SDimitry Andric   int VarArgsFrameIndex = 0;
2981ad6265SDimitry Andric   /// Size of the save area used for varargs
3081ad6265SDimitry Andric   int VarArgsSaveSize = 0;
3181ad6265SDimitry Andric 
3281ad6265SDimitry Andric   /// Size of stack frame to save callee saved registers
3381ad6265SDimitry Andric   unsigned CalleeSavedStackSize = 0;
3481ad6265SDimitry Andric 
35bdd1243dSDimitry Andric   /// FrameIndex of the spill slot when there is no scavenged register in
36bdd1243dSDimitry Andric   /// insertIndirectBranch.
37bdd1243dSDimitry Andric   int BranchRelaxationSpillFrameIndex = -1;
38bdd1243dSDimitry Andric 
39*0fca6ea1SDimitry Andric   /// Registers that have been sign extended from i32.
40*0fca6ea1SDimitry Andric   SmallVector<Register, 8> SExt32Registers;
41*0fca6ea1SDimitry Andric 
4281ad6265SDimitry Andric public:
43bdd1243dSDimitry Andric   LoongArchMachineFunctionInfo(const Function &F,
44bdd1243dSDimitry Andric                                const TargetSubtargetInfo *STI) {}
4581ad6265SDimitry Andric 
4681ad6265SDimitry Andric   MachineFunctionInfo *
4781ad6265SDimitry Andric   clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF,
4881ad6265SDimitry Andric         const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
4981ad6265SDimitry Andric       const override {
5081ad6265SDimitry Andric     return DestMF.cloneInfo<LoongArchMachineFunctionInfo>(*this);
5181ad6265SDimitry Andric   }
5281ad6265SDimitry Andric 
5381ad6265SDimitry Andric   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
5481ad6265SDimitry Andric   void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
5581ad6265SDimitry Andric 
5681ad6265SDimitry Andric   unsigned getVarArgsSaveSize() const { return VarArgsSaveSize; }
5781ad6265SDimitry Andric   void setVarArgsSaveSize(int Size) { VarArgsSaveSize = Size; }
5881ad6265SDimitry Andric 
5981ad6265SDimitry Andric   unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; }
6081ad6265SDimitry Andric   void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; }
61bdd1243dSDimitry Andric 
62bdd1243dSDimitry Andric   int getBranchRelaxationSpillFrameIndex() {
63bdd1243dSDimitry Andric     return BranchRelaxationSpillFrameIndex;
64bdd1243dSDimitry Andric   }
65bdd1243dSDimitry Andric   void setBranchRelaxationSpillFrameIndex(int Index) {
66bdd1243dSDimitry Andric     BranchRelaxationSpillFrameIndex = Index;
67bdd1243dSDimitry Andric   }
68*0fca6ea1SDimitry Andric 
69*0fca6ea1SDimitry Andric   void addSExt32Register(Register Reg) { SExt32Registers.push_back(Reg); }
70*0fca6ea1SDimitry Andric 
71*0fca6ea1SDimitry Andric   bool isSExt32Register(Register Reg) const {
72*0fca6ea1SDimitry Andric     return is_contained(SExt32Registers, Reg);
73*0fca6ea1SDimitry Andric   }
7481ad6265SDimitry Andric };
7581ad6265SDimitry Andric 
7681ad6265SDimitry Andric } // end namespace llvm
7781ad6265SDimitry Andric 
7881ad6265SDimitry Andric #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHMACHINEFUNCTIONINFO_H
79