35 #define GET_REGINFO_TARGET_DESC 36 #include "AArch64GenRegisterInfo.inc" 45 assert(MF &&
"Invalid MachineFunction pointer.");
47 return CSR_Win_AArch64_CFGuard_Check_SaveList;
49 return CSR_Win_AArch64_AAPCS_SaveList;
53 return CSR_AArch64_NoRegs_SaveList;
55 return CSR_AArch64_AllRegs_SaveList;
57 return CSR_AArch64_AAVPCS_SaveList;
59 return CSR_AArch64_SVE_AAPCS_SaveList;
62 CSR_AArch64_CXX_TLS_Darwin_PE_SaveList :
63 CSR_AArch64_CXX_TLS_Darwin_SaveList;
67 Attribute::SwiftError))
68 return CSR_AArch64_AAPCS_SwiftError_SaveList;
70 return CSR_AArch64_RT_MostRegs_SaveList;
72 return CSR_Darwin_AArch64_AAPCS_SaveList;
73 return CSR_AArch64_AAPCS_SaveList;
78 assert(MF &&
"Invalid MachineFunction pointer.");
81 return CSR_AArch64_CXX_TLS_Darwin_ViaCopy_SaveList;
92 for (
size_t i = 0; i < AArch64::GPR64commonRegClass.getNumRegs(); ++i) {
94 UpdatedCSRs.
push_back(AArch64::GPR64commonRegClass.getRegister(i));
104 unsigned Idx)
const {
106 if (RC == &AArch64::GPR32allRegClass && Idx == AArch64::hsub)
107 return &AArch64::FPR32RegClass;
108 else if (RC == &AArch64::GPR64allRegClass && Idx == AArch64::hsub)
109 return &AArch64::FPR64RegClass;
112 return AArch64GenRegisterInfo::getSubClassWithSubReg(RC, Idx);
121 return SCS ? CSR_AArch64_NoRegs_SCS_RegMask : CSR_AArch64_NoRegs_RegMask;
123 return SCS ? CSR_AArch64_AllRegs_SCS_RegMask : CSR_AArch64_AllRegs_RegMask;
125 return SCS ? CSR_AArch64_CXX_TLS_Darwin_SCS_RegMask
126 : CSR_AArch64_CXX_TLS_Darwin_RegMask;
128 return SCS ? CSR_AArch64_AAVPCS_SCS_RegMask : CSR_AArch64_AAVPCS_RegMask;
130 return SCS ? CSR_AArch64_SVE_AAPCS_SCS_RegMask
131 : CSR_AArch64_SVE_AAPCS_RegMask;
133 return CSR_Win_AArch64_CFGuard_Check_RegMask;
137 return SCS ? CSR_AArch64_AAPCS_SwiftError_SCS_RegMask
138 : CSR_AArch64_AAPCS_SwiftError_RegMask;
140 return SCS ? CSR_AArch64_RT_MostRegs_SCS_RegMask
141 : CSR_AArch64_RT_MostRegs_RegMask;
143 return SCS ? CSR_AArch64_AAPCS_SCS_RegMask : CSR_AArch64_AAPCS_RegMask;
148 return CSR_AArch64_TLS_Darwin_RegMask;
151 return CSR_AArch64_TLS_ELF_RegMask;
158 memcpy(UpdatedMask, *Mask,
sizeof(UpdatedMask[0]) * RegMaskSize);
160 for (
size_t i = 0; i < AArch64::GPR64commonRegClass.getNumRegs(); ++i) {
175 return CSR_AArch64_NoRegs_RegMask;
189 return CSR_AArch64_AAPCS_ThisReturn_RegMask;
193 return CSR_AArch64_StackProbe_Windows_RegMask;
202 markSuperRegs(Reserved, AArch64::WSP);
203 markSuperRegs(Reserved, AArch64::WZR);
206 markSuperRegs(Reserved, AArch64::W29);
208 for (
size_t i = 0; i < AArch64::GPR32commonRegClass.getNumRegs(); ++i) {
210 markSuperRegs(Reserved, AArch64::GPR32commonRegClass.getRegister(i));
214 markSuperRegs(Reserved, AArch64::W19);
218 markSuperRegs(Reserved, AArch64::W16);
220 assert(checkAllSuperRegsMarked(Reserved));
225 unsigned Reg)
const {
231 std::end(*AArch64::GPR64argRegClass.MC),
239 " function calls if any of the argument registers is reserved."});
243 unsigned PhysReg)
const {
248 return PhysReg == AArch64::WZR || PhysReg == AArch64::XZR;
253 unsigned Kind)
const {
254 return &AArch64::GPR64spRegClass;
259 if (RC == &AArch64::CCRRegClass)
260 return &AArch64::GPR64RegClass;
278 if (needsStackRealignment(MF))
296 return TFI->
hasFP(MF) ? AArch64::FP : AArch64::SP;
317 return TFI.
hasFP(MF);
340 assert(i < MI->getNumOperands() &&
341 "Instr doesn't have FrameIndex operand!");
367 int64_t FPOffset = Offset - 16 * 20;
400 assert(MI &&
"Unable to get the legal offset for nil instruction.");
413 if (Ins != MBB->
end())
414 DL = Ins->getDebugLoc();
418 const MCInstrDesc &MCID = TII->get(AArch64::ADDXri);
423 BuildMI(*MBB, Ins, DL, MCID, BaseReg)
444 assert(Done &&
"Unable to resolve frame index!");
449 int SPAdj,
unsigned FIOperandNum,
451 assert(SPAdj == 0 &&
"Unexpected");
468 MI.
getOpcode() == TargetOpcode::PATCHPOINT) {
479 if (MI.
getOpcode() == TargetOpcode::LOCAL_ESCAPE) {
487 if (MI.
getOpcode() == AArch64::TAGPstack) {
503 MF, FrameIndex, FrameReg,
false,
true);
516 FrameReg = AArch64::SP;
521 MF, FrameIndex, FrameReg,
false,
true);
529 "Emergency spill slot is out of reach");
544 switch (RC->
getID()) {
547 case AArch64::GPR32RegClassID:
548 case AArch64::GPR32spRegClassID:
549 case AArch64::GPR32allRegClassID:
550 case AArch64::GPR64spRegClassID:
551 case AArch64::GPR64allRegClassID:
552 case AArch64::GPR64RegClassID:
553 case AArch64::GPR32commonRegClassID:
554 case AArch64::GPR64commonRegClassID:
559 case AArch64::FPR8RegClassID:
560 case AArch64::FPR16RegClassID:
561 case AArch64::FPR32RegClassID:
562 case AArch64::FPR64RegClassID:
563 case AArch64::FPR128RegClassID:
566 case AArch64::DDRegClassID:
567 case AArch64::DDDRegClassID:
568 case AArch64::DDDDRegClassID:
569 case AArch64::QQRegClassID:
570 case AArch64::QQQRegClassID:
571 case AArch64::QQQQRegClassID:
574 case AArch64::FPR128_loRegClassID:
584 else if (needsStackRealignment(MF))
unsigned getTargetFlags() const
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (macOS, iOS, tvOS or watchOS).
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
const_iterator end(StringRef path)
Get end iterator over path.
bool isScavengingFrameIndex(int FI) const
Query whether a frame index is a scavenging frame index.
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
StackOffset is a wrapper around scalable and non-scalable offsets and is used in several functions su...
Diagnostic information for unsupported feature in backend.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
MO_TAGGED - With MO_PAGE, indicates that the page includes a memory tag in bits 56-63.
void emitFrameOffset(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, StackOffset Offset, const TargetInstrInfo *TII, MachineInstr::MIFlag=MachineInstr::NoFlags, bool SetNZCV=false, bool NeedsWinCFI=false, bool *HasWinCFI=nullptr)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
bool cannotEliminateFrame(const MachineFunction &MF) const
Describe properties that are true of each instruction in the target description file.
int64_t getLocalFrameSize() const
Get the size of the local object blob.
Offset can apply, at least partly.
bool isFrameOffsetLegal(const MachineInstr *MI, unsigned BaseReg, int64_t Offset) const override
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
Calling convention between AArch64 SVE functions.
bool isAnyArgRegReserved(const MachineFunction &MF) const
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
int isAArch64FrameOffsetLegal(const MachineInstr &MI, StackOffset &Offset, bool *OutUseUnscaledOp=nullptr, unsigned *OutUnscaledOp=nullptr, int64_t *EmittableOffset=nullptr)
Check if the Offset is a valid frame offset for MI.
bool isTargetDarwin() const
const HexagonInstrInfo * TII
unsigned getNumOperands() const
Retuns the total number of operands.
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
unsigned getID() const
Return the register class ID number.
const uint32_t * getNoPreservedMask() const override
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
AArch64RegisterInfo(const Triple &TT)
AttributeList getAttributes() const
Return the attribute list for this Function.
bool isXRegisterReserved(size_t i) const
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
int64_t getBytes() const
Returns the non-scalable part of the offset in bytes.
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
static unsigned getShifterImm(AArch64_AM::ShiftExtendType ST, unsigned Imm)
getShifterImm - Encode the shift type and amount: imm: 6-bit shift amount shifter: 000 ==> lsl 001 ==...
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
bool isTargetWindows() const
int getNonLocalFrameIndexReference(const MachineFunction &MF, int FI) const override
getNonLocalFrameIndexReference - This method returns the offset used to reference a frame index locat...
void materializeFrameBaseRegister(MachineBasicBlock *MBB, unsigned BaseReg, int FrameIdx, int64_t Offset) const override
Insert defining instruction(s) for BaseReg to be a pointer to FrameIdx at the beginning of the basic ...
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
const AArch64TargetLowering * getTargetLowering() const override
const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
StackOffset resolveFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg, bool PreferFP, bool ForSimm) const
This file declares the machine register scavenger class.
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool hasEHFunclets() const
void eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const uint32_t * getThisReturnPreservedMask(const MachineFunction &MF, CallingConv::ID) const
getThisReturnPreservedMask - Returns a call preserved mask specific to the case that 'returned' is on...
Register getFrameRegister(const MachineFunction &MF) const override
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
void setCalleeSavedRegs(ArrayRef< MCPhysReg > CSRs)
Sets the updated Callee Saved Registers list.
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
const MachineInstrBuilder & addFrameIndex(int Idx) const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
MCSubRegIterator enumerates all sub-registers of Reg.
Triple - Helper class for working with autoconf configuration names.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool isDebugValue() const
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
void resolveFrameIndex(MachineInstr &MI, unsigned BaseReg, int64_t Offset) const override
const Function & getFunction() const
Return the LLVM function that this machine code represents.
const TargetRegisterClass * getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const override
unsigned getNumXRegisterReserved() const
void UpdateCustomCallPreservedMask(MachineFunction &MF, const uint32_t **Mask) const
const uint32_t * getWindowsStackProbePreservedMask() const
Stack probing calls preserve different CSRs to the normal CC.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
void initLLVMToCVRegMapping(MCRegisterInfo *MRI)
bool isReservedReg(const MachineFunction &MF, unsigned Reg) const
Representation of each machine instruction.
BitVector getReservedRegs(const MachineFunction &MF) const override
void UpdateCustomCalleeSavedRegs(MachineFunction &MF) const
bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override
void emitReservedArgRegCallError(const MachineFunction &MF) const
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
unsigned getLocalAddressRegister(const MachineFunction &MF) const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void ChangeToRegister(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
bool useFPForScavengingIndex(const MachineFunction &MF) const override
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
unsigned getTaggedBasePointerOffset() const
bool requiresRegisterScavenging(const MachineFunction &MF) const override
const uint32_t * getTLSCallPreservedMask() const
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
bool isConstantPhysReg(unsigned PhysReg) const override
bool hasBasePointer(const MachineFunction &MF) const
bool isXRegCustomCalleeSaved(size_t i) const
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override
needsFrameBaseReg - Returns true if the instruction's frame index reference would be better served by...
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
bool rewriteAArch64FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, StackOffset &Offset, const AArch64InstrInfo *TII)
rewriteAArch64FrameIndex - Rewrite MI to access 'Offset' bytes from the FP.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
unsigned getBaseRegister() const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool isAsmClobberable(const MachineFunction &MF, unsigned PhysReg) const override
Wrapper class representing virtual and physical registers.