30#define GET_REGINFO_TARGET_DESC
31#include "LoongArchGenRegisterInfo.inc"
43 return CSR_NoRegs_SaveList;
45 return CSR_MostRegs_SaveList;
46 switch (Subtarget.getTargetABI()) {
51 return CSR_ILP32S_LP64S_SaveList;
54 return CSR_ILP32F_LP64F_SaveList;
57 return CSR_ILP32D_LP64D_SaveList;
67 return CSR_NoRegs_RegMask;
69 return CSR_MostRegs_RegMask;
70 switch (Subtarget.getTargetABI()) {
75 return CSR_ILP32S_LP64S_RegMask;
78 return CSR_ILP32F_LP64F_RegMask;
81 return CSR_ILP32D_LP64D_RegMask;
86 return CSR_NoRegs_RegMask;
95 markSuperRegs(
Reserved, LoongArch::R0);
96 markSuperRegs(
Reserved, LoongArch::R2);
97 markSuperRegs(
Reserved, LoongArch::R3);
98 markSuperRegs(
Reserved, LoongArch::R21);
100 markSuperRegs(
Reserved, LoongArch::R22);
113 return TFI->
hasFP(MF) ? LoongArch::R22 : LoongArch::R3;
118 unsigned FIOperandNum,
123 assert(SPAdj == 0 &&
"Unexpected non-zero SPAdj value");
126 assert(
MI.getOperand(FIOperandNum + 1).isImm() &&
127 "Unexpected FI-consuming insn");
137 unsigned MIOpc =
MI.getOpcode();
139 int FrameIndex =
MI.getOperand(FIOperandNum).getIndex();
145 bool FrameRegIsKill =
false;
147 int FixedOffset =
Offset.getFixed();
148 bool OffsetLegal =
true;
152 case LoongArch::VSTELM_B:
153 case LoongArch::XVSTELM_B:
154 OffsetLegal =
isInt<8>(FixedOffset);
156 case LoongArch::VSTELM_H:
157 case LoongArch::XVSTELM_H:
160 case LoongArch::VSTELM_W:
161 case LoongArch::XVSTELM_W:
164 case LoongArch::VSTELM_D:
165 case LoongArch::XVSTELM_D:
170 if (!OffsetLegal &&
isInt<12>(FixedOffset)) {
171 unsigned Addi = IsLA64 ? LoongArch::ADDI_D : LoongArch::ADDI_W;
175 Register ScratchReg =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
180 FrameReg = ScratchReg;
181 FrameRegIsKill =
true;
185 unsigned Addi = IsLA64 ? LoongArch::ADDI_D : LoongArch::ADDI_W;
186 unsigned Add = IsLA64 ? LoongArch::ADD_D : LoongArch::ADD_W;
190 Register ScratchReg =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
196 MI.eraseFromParent();
203 FrameReg = ScratchReg;
204 FrameRegIsKill =
true;
208 if (MIOpc == LoongArch::PseudoST_CFR) {
209 Register ScratchReg =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
211 .
add(
MI.getOperand(0));
216 MI.eraseFromParent();
221 if (MIOpc == LoongArch::PseudoLD_CFR) {
222 Register ScratchReg =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
228 .
add(
MI.getOperand(0))
230 MI.eraseFromParent();
234 MI.getOperand(FIOperandNum)
235 .ChangeToRegister(FrameReg,
false,
false, FrameRegIsKill);
236 MI.getOperand(FIOperandNum + 1).ChangeToImmediate(
Offset.getFixed());
249 if (!
MRI->canReserveReg(LoongArch::R22))
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const HexagonInstrInfo * TII
uint64_t IntrinsicInst * II
This file declares the machine register scavenger class.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
bool hasBP(const MachineFunction &MF) const
const LoongArchInstrInfo * getInstrInfo() const override
MachineInstrBundleIterator< MachineInstr > iterator
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
StackOffset holds a fixed and a scalable offset in bytes.
int64_t getFixed() const
Returns the fixed component of the stack.
Information about stack frame layout on the target.
bool hasFP(const MachineFunction &MF) const
hasFP - Return true if the specified function should have a dedicated frame pointer register.
virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
virtual bool canRealignStack(const MachineFunction &MF) const
True if the stack can be realigned for the target.
virtual const TargetFrameLowering * getFrameLowering() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ PreserveMost
Used for runtime calls that preserves most registers.
@ GHC
Used by the Glasgow Haskell Compiler (GHC).
@ Kill
The last use of a register.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
constexpr bool isShiftedInt(int64_t x)
Checks if a signed integer is an N bit number shifted left by S.
bool eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Register getFrameRegister(const MachineFunction &MF) const override
const uint32_t * getNoPreservedMask() const override
BitVector getReservedRegs(const MachineFunction &MF) const override
bool canRealignStack(const MachineFunction &MF) const override
LoongArchRegisterInfo(unsigned HwMode)