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;
49 switch (Subtarget.getTargetABI()) {
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;
75 switch (Subtarget.getTargetABI()) {
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();
153 bool OffsetLegal =
true;
155 bool HasSimm12Field =
false;
160 case LoongArch::LDPTR_W:
161 case LoongArch::LDPTR_D:
162 case LoongArch::STPTR_W:
163 case LoongArch::STPTR_D:
166 case LoongArch::LD_W:
167 HasSimm12Field =
true;
168 PtrOpc = LoongArch::LDPTR_W;
170 case LoongArch::LD_D:
171 HasSimm12Field =
true;
172 PtrOpc = LoongArch::LDPTR_D;
174 case LoongArch::ST_W:
175 HasSimm12Field =
true;
176 PtrOpc = LoongArch::STPTR_W;
178 case LoongArch::ST_D:
179 HasSimm12Field =
true;
180 PtrOpc = LoongArch::STPTR_D;
182 case LoongArch::LD_B:
183 case LoongArch::LD_H:
184 case LoongArch::LD_BU:
185 case LoongArch::LD_HU:
186 case LoongArch::LD_WU:
187 case LoongArch::ST_B:
188 case LoongArch::ST_H:
189 case LoongArch::FLD_S:
190 case LoongArch::FLD_D:
191 case LoongArch::FST_S:
192 case LoongArch::FST_D:
195 case LoongArch::XVLD:
196 case LoongArch::XVST:
197 case LoongArch::VLDREPL_B:
198 case LoongArch::XVLDREPL_B:
199 HasSimm12Field =
true;
205 case LoongArch::VSTELM_B:
206 case LoongArch::XVSTELM_B:
207 OffsetLegal =
isInt<8>(FixedOffset);
209 case LoongArch::VSTELM_H:
210 case LoongArch::XVSTELM_H:
213 case LoongArch::VSTELM_W:
214 case LoongArch::XVSTELM_W:
217 case LoongArch::VSTELM_D:
218 case LoongArch::XVSTELM_D:
223 if (!OffsetLegal &&
isInt<12>(FixedOffset)) {
224 unsigned Addi = IsLA64 ? LoongArch::ADDI_D : LoongArch::ADDI_W;
233 FrameReg = ScratchReg;
234 FrameRegIsKill =
true;
241 MI.setDesc(
TII->get(PtrOpc));
242 MI.getOperand(FIOperandNum)
243 .ChangeToRegister(FrameReg,
false,
false, FrameRegIsKill);
244 MI.getOperand(FIOperandNum + 1).ChangeToImmediate(FixedOffset);
250 unsigned Addi = IsLA64 ? LoongArch::ADDI_D : LoongArch::ADDI_W;
251 unsigned Add = IsLA64 ? LoongArch::ADD_D : LoongArch::ADD_W;
252 int64_t Val = FixedOffset;
256 uint64_t HiVal = (uint64_t)Val - (uint64_t)Lo12;
267 .
addImm(
static_cast<int64_t
>(HiVal) >> 12);
274 MI.eraseFromParent();
281 FrameReg = ScratchReg;
282 FrameRegIsKill =
true;
286 if (MIOpc == LoongArch::PseudoST_CFR) {
289 .
add(
MI.getOperand(0));
294 MI.eraseFromParent();
299 if (MIOpc == LoongArch::PseudoLD_CFR) {
306 .
add(
MI.getOperand(0))
308 MI.eraseFromParent();
312 MI.getOperand(FIOperandNum)
313 .ChangeToRegister(FrameReg,
false,
false, FrameRegIsKill);
314 MI.getOperand(FIOperandNum + 1).ChangeToImmediate(
Offset.getFixed());
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 & 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,...
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool canReserveReg(MCRegister PhysReg) const
canReserveReg - Returns true if PhysReg can be used as a reserved register.
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)