50 #define DEBUG_TYPE "arm-register-info" 52 #define GET_REGINFO_TARGET_DESC 53 #include "ARMGenRegisterInfo.inc" 71 : (UseSplitPush ? CSR_AAPCS_SplitPush_SaveList : CSR_AAPCS_SaveList);
77 return CSR_NoRegs_SaveList;
79 return CSR_Win_AAPCS_CFGuard_Check_SaveList;
84 return UseSplitPush ? CSR_AAPCS_SplitPush_SaveList : CSR_AAPCS_SaveList;
88 return CSR_FIQ_SaveList;
92 return CSR_GenericInt_SaveList;
99 return CSR_iOS_SwiftError_SaveList;
101 return UseSplitPush ? CSR_AAPCS_SplitPush_SwiftError_SaveList :
102 CSR_AAPCS_SwiftError_SaveList;
107 ? CSR_iOS_CXX_TLS_PE_SaveList
108 : CSR_iOS_CXX_TLS_SaveList;
114 assert(MF &&
"Invalid MachineFunction pointer.");
117 return CSR_iOS_CXX_TLS_ViaCopy_SaveList;
127 return CSR_NoRegs_RegMask;
129 return CSR_Win_AAPCS_CFGuard_Check_RegMask;
133 : CSR_AAPCS_SwiftError_RegMask;
136 return CSR_iOS_CXX_TLS_RegMask;
137 return STI.
isTargetDarwin() ? CSR_iOS_RegMask : CSR_AAPCS_RegMask;
142 return CSR_NoRegs_RegMask;
148 "only know about special TLS call on Darwin");
149 return CSR_iOS_TLSCall_RegMask;
156 return CSR_NoRegs_RegMask;
158 return CSR_FPRegs_RegMask;
177 : CSR_AAPCS_ThisReturn_RegMask;
182 static const MCPhysReg IntraCallClobberedRegs[] = {ARM::R12};
193 markSuperRegs(Reserved, ARM::SP);
194 markSuperRegs(Reserved, ARM::PC);
195 markSuperRegs(Reserved, ARM::FPSCR);
196 markSuperRegs(Reserved, ARM::APSR_NZCV);
200 markSuperRegs(Reserved,
BasePtr);
203 markSuperRegs(Reserved, ARM::R9);
206 static_assert(ARM::D31 == ARM::D16 + 15,
"Register list not consecutive!");
207 for (
unsigned R = 0; R < 16; ++R)
208 markSuperRegs(Reserved, ARM::D16 + R);
211 for (
unsigned Reg : RC)
214 markSuperRegs(Reserved,
Reg);
216 markSuperRegs(Reserved, ARM::ZR);
218 assert(checkAllSuperRegsMarked(Reserved));
233 switch (Super->
getID()) {
234 case ARM::GPRRegClassID:
235 case ARM::SPRRegClassID:
236 case ARM::DPRRegClassID:
237 case ARM::GPRPairRegClassID:
239 case ARM::QPRRegClassID:
240 case ARM::QQPRRegClassID:
241 case ARM::QQQQPRRegClassID:
253 return &ARM::GPRRegClass;
258 if (RC == &ARM::CCRRegClass)
259 return &ARM::rGPRRegClass;
269 switch (RC->
getID()) {
272 case ARM::tGPRRegClassID: {
277 ? TFI->hasFP(MF) :
true;
280 case ARM::GPRRegClassID: {
282 ? TFI->hasFP(MF) :
true;
285 case ARM::SPRRegClassID:
286 case ARM::DPRRegClassID:
294 if (ARM::GPRPairRegClass.
contains(*Supers))
295 return RI->
getSubReg(*Supers, Odd ? ARM::gsub_1 : ARM::gsub_0);
311 switch (Hint.first) {
326 unsigned Paired = Hint.second;
330 unsigned PairedPhys = 0;
333 }
else if (VRM && VRM->
hasPhys(Paired)) {
342 for (
unsigned Reg : Order) {
343 if (
Reg == PairedPhys || (getEncodingValue(
Reg) & 1) != Odd)
366 unsigned OtherReg = Hint.second;
369 if (Hint.second == Reg) {
387 if (needsStackRealignment(MF) && !TFI->hasReservedCallFrame(MF))
443 || needsStackRealignment(MF);
460 const DebugLoc &dl,
unsigned DestReg,
unsigned SubIdx,
int Val,
471 .addConstantPoolIndex(Idx)
501 int64_t InstrOffs = 0;
516 InstrOffs = -InstrOffs;
524 InstrOffs = -InstrOffs;
530 InstrOffs = -InstrOffs;
541 return InstrOffs * Scale;
551 assert(i < MI->getNumOperands() &&
"Instr doesn't have FrameIndex operand!");
565 case ARM::LDRi12:
case ARM::LDRH:
case ARM::LDRBi12:
566 case ARM::STRi12:
case ARM::STRH:
case ARM::STRBi12:
567 case ARM::t2LDRi12:
case ARM::t2LDRi8:
568 case ARM::t2STRi12:
case ARM::t2STRi8:
569 case ARM::VLDRS:
case ARM::VLDRD:
570 case ARM::VSTRS:
case ARM::VSTRD:
571 case ARM::tSTRspi:
case ARM::tLDRspi:
591 int64_t FPOffset = Offset - 8;
610 if (TFI->
hasFP(MF) &&
631 unsigned BaseReg,
int FrameIdx,
639 if (Ins != MBB->
end())
640 DL = Ins->getDebugLoc();
666 "This resolveFrameIndex does not support Thumb1!");
679 assert(Done &&
"Unable to resolve frame index!");
695 unsigned NumBits = 0;
697 bool isSigned =
true;
724 NumBits = (BaseReg == ARM::SP ? 8 : 5);
735 if ((Offset & (Scale-1)) != 0)
738 if (isSigned && Offset < 0)
741 unsigned Mask = (1 << NumBits) - 1;
742 if ((
unsigned)Offset <= Mask * Scale)
750 int SPAdj,
unsigned FIOperandNum,
760 "This eliminateFrameIndex does not support Thumb1!");
773 "Cannot use SP to access the emergency spill slot in " 774 "functions without a reserved call frame");
776 "Cannot use SP to access the emergency spill slot in " 777 "functions with variable sized frame objects");
781 assert(!MI.
isDebugValue() &&
"DBG_VALUEs should be handled in target-independent code");
805 "This code isn't needed if offset already handled!");
807 unsigned ScratchReg = 0;
851 if (getRegSizeInBits(*NewRC) < 256 && getRegSizeInBits(*DstRC) < 256 &&
852 getRegSizeInBits(*SrcRC) < 256)
863 if (SrcRCWeight.RegWeight > NewRCWeight.RegWeight)
865 if (DstRCWeight.RegWeight > NewRCWeight.RegWeight)
876 << It->second <<
"\n");
878 << NewRCWeight.RegWeight <<
"\n");
886 unsigned SizeMultiplier = MBB->size()/100;
887 SizeMultiplier = SizeMultiplier ? SizeMultiplier : 1;
888 if (It->second < NewRCWeight.WeightLimit * SizeMultiplier) {
889 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...
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
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
bool isReserved(Register PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
int findFirstPredOperandIdx() const
Find the index of the first operand in the operand list that is used to represent the predicate...
This class represents lattice values for constants.
const uint32_t * getTLSCallPreservedMask(const MachineFunction &MF) const
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
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.
const ARMTargetLowering * getTargetLowering() const override
Register getFrameRegister(const MachineFunction &MF) const override
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
ArrayRef< MCPhysReg > getIntraCallClobberedRegs(const MachineFunction *MF) const override
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
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
Retuns the total number of operands.
virtual 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...
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
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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
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...
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
MCRegister getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
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 rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, int &Offset, const ARMBaseInstrInfo &TII, const TargetRegisterInfo *TRI)
std::pair< unsigned, unsigned > getRegAllocationHint(Register VReg) const
getRegAllocationHint - Return the register allocation hint for the specified virtual register...
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...
Promote Memory to 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.
bool isAsmClobberable(const MachineFunction &MF, unsigned PhysReg) const override
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.
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.
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)
Register getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
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...
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 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.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Align getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
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)
Register getReg() const
getReg - Returns the register number.
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...
Wrapper class representing virtual and physical registers.
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.