LLVM 23.0.0git
LoongArchMachineFunctionInfo.h
Go to the documentation of this file.
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/ADT/DenseMap.h"
20
21namespace llvm {
22
23/// LoongArchMachineFunctionInfo - This class is derived from
24/// MachineFunctionInfo and contains private LoongArch-specific information for
25/// each MachineFunction.
27private:
28 /// FrameIndex for start of varargs area
29 int VarArgsFrameIndex = 0;
30 /// Size of the save area used for varargs
31 int VarArgsSaveSize = 0;
32
33 /// Size of stack frame to save callee saved registers
34 unsigned CalleeSavedStackSize = 0;
35
36 /// Incoming indirect argument pointers saved as virtual registers, keyed by
37 /// formal parameter index. Used for musttail forwarding of indirect args.
38 /// Virtual registers (not SDValues) are used because the SelectionDAG is
39 /// cleared between basic blocks, and musttail calls may be in non-entry
40 /// blocks.
41 DenseMap<unsigned, Register> IncomingIndirectArgs;
42
43 /// FrameIndex of the spill slot when there is no scavenged register in
44 /// insertIndirectBranch.
45 int BranchRelaxationSpillFrameIndex = -1;
46
47 /// Registers that have been sign extended from i32.
48 SmallVector<Register, 8> SExt32Registers;
49
50 /// Pairs of `jr` instructions and corresponding JTI operands, used for the
51 /// `annotate-tablejump` option.
53
54 bool HasDynamicAllocation = false;
55
56public:
59
63 const override {
64 return DestMF.cloneInfo<LoongArchMachineFunctionInfo>(*this);
65 }
66
67 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
68 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
69
70 unsigned getVarArgsSaveSize() const { return VarArgsSaveSize; }
71 void setVarArgsSaveSize(int Size) { VarArgsSaveSize = Size; }
72
73 unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; }
74 void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; }
75
76 void setIncomingIndirectArg(unsigned ArgIndex, Register Reg) {
77 IncomingIndirectArgs[ArgIndex] = Reg;
78 }
79 Register getIncomingIndirectArg(unsigned ArgIndex) const {
80 auto It = IncomingIndirectArgs.find(ArgIndex);
81 assert(It != IncomingIndirectArgs.end() && "No incoming indirect arg");
82 return It->second;
83 }
84
86 return BranchRelaxationSpillFrameIndex;
87 }
89 BranchRelaxationSpillFrameIndex = Index;
90 }
91
92 void addSExt32Register(Register Reg) { SExt32Registers.push_back(Reg); }
93
95 return is_contained(SExt32Registers, Reg);
96 }
97
98 void setJumpInfo(MachineInstr *JrMI, int JTIIdx) {
99 JumpInfos.push_back(std::make_pair(JrMI, JTIIdx));
100 }
101 unsigned getJumpInfoSize() { return JumpInfos.size(); }
102 MachineInstr *getJumpInfoJrMI(unsigned Idx) { return JumpInfos[Idx].first; }
103 int getJumpInfoJTIIndex(unsigned Idx) { return JumpInfos[Idx].second; }
104
105 bool hasDynamicAllocation() const { return HasDynamicAllocation; }
106 void setDynamicAllocation() { HasDynamicAllocation = true; }
107};
108
109} // end namespace llvm
110
111#endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHMACHINEFUNCTIONINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the DenseMap class.
#define F(x, y, z)
Definition MD5.cpp:54
Register Reg
Basic Register Allocator
void setIncomingIndirectArg(unsigned ArgIndex, Register Reg)
LoongArchMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI)
MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const override
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
Register getIncomingIndirectArg(unsigned ArgIndex) const
void setJumpInfo(MachineInstr *JrMI, int JTIIdx)
Ty * cloneInfo(const Ty &Old)
Representation of each machine instruction.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetSubtargetInfo - Generic base class for all target subtargets.
This is an optimization pass for GlobalISel generic memory operations.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1946
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...