30#define GET_REGINFO_TARGET_DESC
31#include "LoongArchGenRegisterInfo.inc"
44 return CSR_NoRegs_SaveList;
46 return CSR_NoneRegs_SaveList;
48 return CSR_MostRegs_SaveList;
54 return CSR_ILP32S_LP64S_SaveList;
57 return CSR_ILP32F_LP64F_SaveList;
60 return CSR_ILP32D_LP64D_SaveList;
70 return CSR_NoRegs_RegMask;
72 return CSR_NoneRegs_RegMask;
74 return CSR_MostRegs_RegMask;
80 return CSR_ILP32S_LP64S_RegMask;
83 return CSR_ILP32F_LP64F_RegMask;
86 return CSR_ILP32D_LP64D_RegMask;
91 return CSR_NoRegs_RegMask;
100 markSuperRegs(
Reserved, LoongArch::R0);
101 markSuperRegs(
Reserved, LoongArch::R2);
102 markSuperRegs(
Reserved, LoongArch::R3);
103 markSuperRegs(
Reserved, LoongArch::R21);
105 markSuperRegs(
Reserved, LoongArch::R22);
118 return TFI->
hasFP(MF) ? LoongArch::R22 : LoongArch::R3;
123 unsigned FIOperandNum,
128 assert(SPAdj == 0 &&
"Unexpected non-zero SPAdj value");
131 assert(
MI.getOperand(FIOperandNum + 1).isImm() &&
132 "Unexpected FI-consuming insn");
142 unsigned MIOpc =
MI.getOpcode();
144 int FrameIndex =
MI.getOperand(FIOperandNum).getIndex();
150 bool FrameRegIsKill =
false;
152 int FixedOffset =
Offset.getFixed();
161 case LoongArch::LDPTR_W:
162 NewOpc = LoongArch::LD_W;
164 case LoongArch::LDPTR_D:
165 NewOpc = LoongArch::LD_D;
167 case LoongArch::STPTR_W:
168 NewOpc = LoongArch::ST_W;
170 case LoongArch::STPTR_D:
171 NewOpc = LoongArch::ST_D;
175 MI.setDesc(
TII->get(NewOpc));
180 bool OffsetLegal =
true;
182 bool HasSimm12Field =
false;
187 case LoongArch::LDPTR_W:
188 case LoongArch::LDPTR_D:
189 case LoongArch::STPTR_W:
190 case LoongArch::STPTR_D:
193 case LoongArch::LD_W:
194 HasSimm12Field =
true;
195 PtrOpc = LoongArch::LDPTR_W;
197 case LoongArch::LD_D:
198 HasSimm12Field =
true;
199 PtrOpc = LoongArch::LDPTR_D;
201 case LoongArch::ST_W:
202 HasSimm12Field =
true;
203 PtrOpc = LoongArch::STPTR_W;
205 case LoongArch::ST_D:
206 HasSimm12Field =
true;
207 PtrOpc = LoongArch::STPTR_D;
209 case LoongArch::LD_B:
210 case LoongArch::LD_H:
211 case LoongArch::LD_BU:
212 case LoongArch::LD_HU:
213 case LoongArch::LD_WU:
214 case LoongArch::ST_B:
215 case LoongArch::ST_H:
216 case LoongArch::FLD_S:
217 case LoongArch::FLD_D:
218 case LoongArch::FST_S:
219 case LoongArch::FST_D:
222 case LoongArch::XVLD:
223 case LoongArch::XVST:
224 case LoongArch::VLDREPL_B:
225 case LoongArch::XVLDREPL_B:
226 HasSimm12Field =
true;
232 case LoongArch::VLDREPL_H:
233 case LoongArch::XVLDREPL_H:
236 case LoongArch::VLDREPL_W:
237 case LoongArch::XVLDREPL_W:
240 case LoongArch::VLDREPL_D:
241 case LoongArch::XVLDREPL_D:
244 case LoongArch::VSTELM_B:
245 case LoongArch::XVSTELM_B:
246 OffsetLegal =
isInt<8>(FixedOffset);
248 case LoongArch::VSTELM_H:
249 case LoongArch::XVSTELM_H:
252 case LoongArch::VSTELM_W:
253 case LoongArch::XVSTELM_W:
256 case LoongArch::VSTELM_D:
257 case LoongArch::XVSTELM_D:
262 if (!OffsetLegal &&
isInt<12>(FixedOffset)) {
263 unsigned Addi = IsLA64 ? LoongArch::ADDI_D : LoongArch::ADDI_W;
267 Register ScratchReg =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
272 FrameReg = ScratchReg;
273 FrameRegIsKill =
true;
280 MI.setDesc(
TII->get(PtrOpc));
281 MI.getOperand(FIOperandNum)
282 .ChangeToRegister(FrameReg,
false,
false, FrameRegIsKill);
283 MI.getOperand(FIOperandNum + 1).ChangeToImmediate(FixedOffset);
289 unsigned Addi = IsLA64 ? LoongArch::ADDI_D : LoongArch::ADDI_W;
290 unsigned Add = IsLA64 ? LoongArch::ADD_D : LoongArch::ADD_W;
291 int64_t Val = FixedOffset;
295 uint64_t HiVal = (uint64_t)Val - (uint64_t)Lo12;
299 Register ScratchReg =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
306 .
addImm(
static_cast<int64_t
>(HiVal) >> 12);
313 MI.eraseFromParent();
320 FrameReg = ScratchReg;
321 FrameRegIsKill =
true;
325 if (MIOpc == LoongArch::PseudoST_CFR) {
326 Register ScratchReg =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
328 .
add(
MI.getOperand(0));
333 MI.eraseFromParent();
338 if (MIOpc == LoongArch::PseudoLD_CFR) {
339 Register ScratchReg =
MRI.createVirtualRegister(&LoongArch::GPRRegClass);
345 .
add(
MI.getOperand(0))
347 MI.eraseFromParent();
351 MI.getOperand(FIOperandNum)
352 .ChangeToRegister(FrameReg,
false,
false, FrameRegIsKill);
353 MI.getOperand(FIOperandNum + 1).ChangeToImmediate(
Offset.getFixed());
366 if (!
MRI->canReserveReg(LoongArch::R22))
const AArch64Subtarget & Subtarget
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const HexagonInstrInfo * TII
uint64_t IntrinsicInst * II
MachineRegisterInfo & MRI
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 & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
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).
@ PreserveNone
Used for runtime calls that preserves none general registers.
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.
@ Kill
The last use of a register.
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.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
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)