51 #define DEBUG_TYPE "arm-register-info" 53 #define GET_REGINFO_TARGET_DESC 54 #include "ARMGenRegisterInfo.inc" 72 : (UseSplitPush ? CSR_AAPCS_SplitPush_SaveList : CSR_AAPCS_SaveList);
78 return CSR_NoRegs_SaveList;
83 return UseSplitPush ? CSR_AAPCS_SplitPush_SaveList : CSR_AAPCS_SaveList;
87 return CSR_FIQ_SaveList;
91 return CSR_GenericInt_SaveList;
98 return CSR_iOS_SwiftError_SaveList;
100 return UseSplitPush ? CSR_AAPCS_SplitPush_SwiftError_SaveList :
101 CSR_AAPCS_SwiftError_SaveList;
106 ? CSR_iOS_CXX_TLS_PE_SaveList
107 : CSR_iOS_CXX_TLS_SaveList;
113 assert(MF &&
"Invalid MachineFunction pointer.");
116 return CSR_iOS_CXX_TLS_ViaCopy_SaveList;
126 return CSR_NoRegs_RegMask;
131 : CSR_AAPCS_SwiftError_RegMask;
134 return CSR_iOS_CXX_TLS_RegMask;
135 return STI.
isTargetDarwin() ? CSR_iOS_RegMask : CSR_AAPCS_RegMask;
140 return CSR_NoRegs_RegMask;
146 "only know about special TLS call on Darwin");
147 return CSR_iOS_TLSCall_RegMask;
154 return CSR_NoRegs_RegMask;
156 return CSR_FPRegs_RegMask;
175 : CSR_AAPCS_ThisReturn_RegMask;
185 markSuperRegs(Reserved, ARM::SP);
186 markSuperRegs(Reserved, ARM::PC);
187 markSuperRegs(Reserved, ARM::FPSCR);
188 markSuperRegs(Reserved, ARM::APSR_NZCV);
192 markSuperRegs(Reserved,
BasePtr);
195 markSuperRegs(Reserved, ARM::R9);
198 static_assert(ARM::D31 == ARM::D16 + 15,
"Register list not consecutive!");
199 for (
unsigned R = 0; R < 16; ++R)
200 markSuperRegs(Reserved, ARM::D16 + R);
203 for (
unsigned Reg : RC)
206 markSuperRegs(Reserved,
Reg);
208 assert(checkAllSuperRegsMarked(Reserved));
218 switch (Super->
getID()) {
219 case ARM::GPRRegClassID:
220 case ARM::SPRRegClassID:
221 case ARM::DPRRegClassID:
222 case ARM::QPRRegClassID:
223 case ARM::QQPRRegClassID:
224 case ARM::QQQQPRRegClassID:
225 case ARM::GPRPairRegClassID:
236 return &ARM::GPRRegClass;
241 if (RC == &ARM::CCRRegClass)
242 return &ARM::rGPRRegClass;
252 switch (RC->
getID()) {
255 case ARM::tGPRRegClassID: {
260 ? TFI->hasFP(MF) :
true;
263 case ARM::GPRRegClassID: {
265 ? TFI->hasFP(MF) :
true;
268 case ARM::SPRRegClassID:
269 case ARM::DPRRegClassID:
277 if (ARM::GPRPairRegClass.
contains(*Supers))
278 return RI->
getSubReg(*Supers, Odd ? ARM::gsub_1 : ARM::gsub_0);
294 switch (Hint.first) {
309 unsigned Paired = Hint.second;
313 unsigned PairedPhys = 0;
316 }
else if (VRM && VRM->
hasPhys(Paired)) {
325 for (
unsigned Reg : Order) {
326 if (
Reg == PairedPhys || (getEncodingValue(
Reg) & 1) != Odd)
349 unsigned OtherReg = Hint.second;
352 if (Hint.second == Reg) {
370 if (needsStackRealignment(MF) && !TFI->hasReservedCallFrame(MF))
420 || needsStackRealignment(MF);
437 const DebugLoc &dl,
unsigned DestReg,
unsigned SubIdx,
int Val,
448 .addConstantPoolIndex(Idx)
478 int64_t InstrOffs = 0;
493 InstrOffs = -InstrOffs;
501 InstrOffs = -InstrOffs;
507 InstrOffs = -InstrOffs;
518 return InstrOffs * Scale;
528 assert(i < MI->getNumOperands() &&
"Instr doesn't have FrameIndex operand!");
542 case ARM::LDRi12:
case ARM::LDRH:
case ARM::LDRBi12:
543 case ARM::STRi12:
case ARM::STRH:
case ARM::STRBi12:
544 case ARM::t2LDRi12:
case ARM::t2LDRi8:
545 case ARM::t2STRi12:
case ARM::t2STRi8:
546 case ARM::VLDRS:
case ARM::VLDRD:
547 case ARM::VSTRS:
case ARM::VSTRD:
548 case ARM::tSTRspi:
case ARM::tLDRspi:
568 int64_t FPOffset = Offset - 8;
587 if (TFI->
hasFP(MF) &&
608 unsigned BaseReg,
int FrameIdx,
616 if (Ins != MBB->
end())
617 DL = Ins->getDebugLoc();
643 "This resolveFrameIndex does not support Thumb1!");
656 assert(Done &&
"Unable to resolve frame index!");
672 unsigned NumBits = 0;
701 NumBits = (BaseReg == ARM::SP ? 8 : 5);
712 if ((Offset & (Scale-1)) != 0)
715 if (isSigned && Offset < 0)
718 unsigned Mask = (1 << NumBits) - 1;
719 if ((
unsigned)Offset <= Mask * Scale)
727 int SPAdj,
unsigned FIOperandNum,
737 "This eliminateFrameIndex does not support Thumb1!");
750 "Cannot use SP to access the emergency spill slot in " 751 "functions without a reserved call frame");
753 "Cannot use SP to access the emergency spill slot in " 754 "functions with variable sized frame objects");
758 assert(!MI.
isDebugValue() &&
"DBG_VALUEs should be handled in target-independent code");
777 "This code isn't needed if offset already handled!");
779 unsigned ScratchReg = 0;
817 if (getRegSizeInBits(*NewRC) < 256 && getRegSizeInBits(*DstRC) < 256 &&
818 getRegSizeInBits(*SrcRC) < 256)
829 if (SrcRCWeight.RegWeight > NewRCWeight.RegWeight)
831 if (DstRCWeight.RegWeight > NewRCWeight.RegWeight)
842 << It->second <<
"\n");
844 << NewRCWeight.RegWeight <<
"\n");
852 unsigned SizeMultiplier = MBB->size()/100;
853 SizeMultiplier = SizeMultiplier ? SizeMultiplier : 1;
854 if (It->second < NewRCWeight.WeightLimit * SizeMultiplier) {
855 It->second += NewRCWeight.RegWeight;
virtual bool getRegAllocationHints(unsigned VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM=nullptr, const LiveRegMatrix *Matrix=nullptr) const
Get a list of 'hint' registers that the register allocator should try first when allocating a physica...
void push_back(const T &Elt)
const MachineInstrBuilder & add(const MachineOperand &MO) const
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
bool isScavengingFrameIndex(int FI) const
Query whether a frame index is a scavenging frame index.
void materializeFrameBaseRegister(MachineBasicBlock *MBB, unsigned BaseReg, int FrameIdx, int64_t Offset) const override
materializeFrameBaseRegister - Insert defining instruction(s) for BaseReg to be a pointer to FrameIdx...
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
int findFirstPredOperandIdx() const
Find the index of the first operand in the operand list that is used to represent the predicate...
Compute iterated dominance frontiers using a linear time algorithm.
void ChangeToRegister(unsigned 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...
const uint32_t * getTLSCallPreservedMask(const MachineFunction &MF) const
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
int64_t getLocalFrameSize() const
Get the size of the local object blob.
const ARMTargetLowering * getTargetLowering() const override
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
bool test(unsigned Idx) const
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.
bool isThumb1Only() const
void updateRegAllocHint(unsigned Reg, unsigned NewReg, MachineFunction &MF) const override
void eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
return AArch64::GPR64RegClass contains(Reg)
bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override
needsFrameBaseReg - Returns true if the instruction's frame index reference would be better served by...
const uint32_t * getNoPreservedMask() const override
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
static unsigned getPairedGPR(unsigned Reg, bool Odd, const MCRegisterInfo *RI)
MCSuperRegIterator enumerates all super-registers of Reg.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
const HexagonInstrInfo * TII
unsigned getNumOperands() const
Access to explicit operands of the instruction.
const TargetRegisterClass * getRegClass(const MCInstrDesc &MCID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const
Given a machine instruction descriptor, returns the register class constraint for OpNum...
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
unsigned getFrameRegister(const MachineFunction &MF) const override
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
void emitT2RegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, unsigned DestReg, unsigned BaseReg, int NumBytes, ARMCC::CondCodes Pred, unsigned PredReg, const ARMBaseInstrInfo &TII, unsigned MIFlags=0)
bool rewriteARMFrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, int &Offset, const ARMBaseInstrInfo &TII)
rewriteARMFrameIndex / rewriteT2FrameIndex - Rewrite MI to access 'Offset' bytes from the FP...
This file contains the simple types necessary to represent the attributes associated with functions a...
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.
virtual bool canRealignStack(const MachineFunction &MF) const
True if the stack can be realigned for the target.
const TargetRegisterClass *const * sc_iterator
bool rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, int &Offset, const ARMBaseInstrInfo &TII)
unsigned getID() const
Return the register class ID number.
bool isFrameOffsetLegal(const MachineInstr *MI, unsigned BaseReg, int64_t Offset) const override
BitVector getReservedRegs(const MachineFunction &MF) const override
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
unsigned char getAM3Offset(unsigned AM3Opc)
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
bool splitFramePushPop(const MachineFunction &MF) const
Returns true if the frame setup is split into two separate pushes (first r0-r7,lr then r8-r11)...
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
bool canReserveReg(unsigned PhysReg) const
canReserveReg - Returns true if PhysReg can be used as a reserved register.
bool isTargetDarwin() const
bool isThumb2Function() const
AttributeList getAttributes() const
Return the attribute list for this Function.
virtual const TargetInstrInfo * getInstrInfo() const
const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override
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...
bool useR7AsFramePointer() const
bool isR9Reserved() const
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
TargetInstrInfo - Interface to description of machine instruction set.
bool shouldCoalesce(MachineInstr *MI, const TargetRegisterClass *SrcRC, unsigned SubReg, const TargetRegisterClass *DstRC, unsigned DstSubReg, const TargetRegisterClass *NewRC, LiveIntervals &LIS) const override
SrcRC and DstRC will be morphed into NewRC if this returns true.
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
AddrOpc getAM2Op(unsigned AM2Opc)
unsigned getDefRegState(bool B)
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.
sc_iterator getSuperClasses() const
Returns a NULL-terminated list of super-classes.
int ResolveFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg, int SPAdj) const
unsigned char getAM5Offset(unsigned AM5Opc)
This file declares the machine register scavenger class.
const TargetRegisterInfo * getTargetRegisterInfo() const
AddrOpc getAM3Op(unsigned AM3Opc)
bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override
unsigned const MachineRegisterInfo * MRI
bool requiresRegisterScavenging(const MachineFunction &MF) const override
Code Generation virtual methods...
const uint32_t * getThisReturnPreservedMask(const MachineFunction &MF, CallingConv::ID) const
getThisReturnPreservedMask - Returns a call preserved mask specific to the case that 'returned' is on...
int64_t getFrameIndexInstrOffset(const MachineInstr *MI, int Idx) const override
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool cannotEliminateFrame(const MachineFunction &MF) const
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
bool hasBasePointer(const MachineFunction &MF) const
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
const MachineInstrBuilder & addFrameIndex(int Idx) const
bool isThumb1OnlyFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
void emitARMRegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, unsigned DestReg, unsigned BaseReg, int NumBytes, ARMCC::CondCodes Pred, unsigned PredReg, const ARMBaseInstrInfo &TII, unsigned MIFlags=0)
emitARMRegPlusImmediate / emitT2RegPlusImmediate - Emits a series of instructions to materializea des...
static unsigned getFramePointerReg(const ARMSubtarget &STI)
MCSubRegIterator enumerates all sub-registers of Reg.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
bool useSoftFloat() const
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool isDebugValue() const
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
MachineOperand class - Representation of each machine instruction operand.
virtual const RegClassWeight & getRegClassWeight(const TargetRegisterClass *RC) const =0
Get the weight in units of pressure for this register class.
void setRegAllocationHint(unsigned VReg, unsigned Type, unsigned PrefReg)
setRegAllocationHint - Specify a register allocation hint for the specified virtual register...
unsigned getAM2Offset(unsigned AM2Opc)
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool canRealignStack(const MachineFunction &MF) const override
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
AddrMode
ARM Addressing Modes.
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 resolveFrameIndex(MachineInstr &MI, unsigned BaseReg, int64_t Offset) const override
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const uint32_t * getSjLjDispatchPreservedMask(const MachineFunction &MF) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
std::pair< unsigned, unsigned > getRegAllocationHint(unsigned VReg) const
getRegAllocationHint - Return the register allocation hint for the specified virtual register...
static MachineOperand condCodeOp(unsigned CCReg=0)
Get the operand corresponding to the conditional code result.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static IntegerType * getInt32Ty(LLVMContext &C)
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
StringRef getValueAsString() const
Return the attribute's value as a string.
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
static bool isSigned(Value *V)
Can the given value generate sign bits.
unsigned getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
bool hasPhys(unsigned virtReg) const
returns true if the specified virtual register is mapped to a physical register
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
unsigned BasePtr
BasePtr - ARM physical register used as a base ptr in complex stack frames.
unsigned getPhys(unsigned virtReg) const
returns the physical register mapped to the specified virtual register
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &MF) const override
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.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
bool isMaxCallFrameSizeComputed() const
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override
bool getRegAllocationHints(unsigned VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
AddrOpc getAM5Op(unsigned AM5Opc)
const MachineOperand & getOperand(unsigned i) const
DenseMap< const MachineBasicBlock *, unsigned >::iterator getCoalescedWeight(MachineBasicBlock *MBB)
bool isThumbFunction() const
unsigned getConstantPoolIndex(const Constant *C, unsigned Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one...
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool isReserved(unsigned PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
virtual void emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, unsigned DestReg, unsigned SubIdx, int Val, ARMCC::CondCodes Pred=ARMCC::AL, unsigned PredReg=0, unsigned MIFlags=MachineInstr::NoFlags) const
emitLoadConstPool - Emits a load from constpool to materialize the specified immediate.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.