77 if (
MBBI->isDebugInstr()) {
81 if (
MBBI->getOpcode() == ARM::t2IT) {
82 unsigned Mask =
MBBI->getOperand(1).getImm();
84 MBBI->eraseFromParent();
86 unsigned MaskOn = 1 <<
Count;
87 unsigned MaskOff = ~(MaskOn - 1);
88 MBBI->getOperand(1).setImm((Mask & MaskOff) | MaskOn);
104 while (
MBBI->isDebugInstr()) {
117 bool PreferFalse)
const {
130 get(ARM::t2CSEL), DestReg)
131 .
add(
MI.getOperand(2))
132 .
add(
MI.getOperand(1))
133 .
add(
MI.getOperand(3));
144 bool RenamableDest,
bool RenamableSrc)
const {
146 if (!ARM::GPRRegClass.
contains(DestReg, SrcReg))
156 Register SrcReg,
bool isKill,
int FI,
161 if (
I !=
MBB.end())
DL =
I->getDebugLoc();
169 if (ARM::GPRRegClass.hasSubClassEq(RC)) {
179 if (ARM::GPRPairRegClass.hasSubClassEq(RC)) {
185 MRI->constrainRegClass(SrcReg, &ARM::GPRPairnospRegClass);
190 AddDReg(MIB, SrcReg, ARM::gsub_1, {});
211 if (
I !=
MBB.end())
DL =
I->getDebugLoc();
213 if (ARM::GPRRegClass.hasSubClassEq(RC)) {
222 if (ARM::GPRPairRegClass.hasSubClassEq(RC)) {
228 MRI->constrainRegClass(DestReg, &ARM::GPRPairnospRegClass);
244void Thumb2InstrInfo::expandLoadStackGuard(
249 if (M.getStackProtectorGuard() ==
"tls") {
257 if (
Subtarget.isTargetELF() && !GV->isDSOLocal())
261 MI, IsPIC ? ARM::t2LDRLIT_ga_pcrel : ARM::tLDRLIT_ga_abs,
272 unsigned OpIdx2)
const {
273 switch (
MI.getOpcode()) {
274 case ARM::MVE_VMAXNMAf16:
275 case ARM::MVE_VMAXNMAf32:
276 case ARM::MVE_VMINNMAf16:
277 case ARM::MVE_VMINNMAf32:
292 switch (
MI.getOpcode()) {
311 if (NumBytes == 0 && DestReg != BaseReg) {
318 bool isSub = NumBytes < 0;
319 if (isSub) NumBytes = -NumBytes;
323 if (DestReg != ARM::SP && DestReg != BaseReg &&
327 if (NumBytes < 65536) {
333 }
else if ((NumBytes & 0xffff) == 0) {
368 unsigned ThisVal = NumBytes;
370 if (DestReg == ARM::SP && BaseReg != ARM::SP) {
380 assert((DestReg != ARM::SP || BaseReg == ARM::SP) &&
381 "Writing to SP, from other register.");
384 if ((DestReg == ARM::SP) && (ThisVal < ((1 << 7) - 1) * 4)) {
385 assert((ThisVal & 3) == 0 &&
"Stack update is not multiple of 4?");
386 Opc = isSub ? ARM::tSUBspi : ARM::tADDspi;
394 bool HasCCOut =
true;
396 bool ToSP = DestReg == ARM::SP;
397 unsigned t2SUB = ToSP ? ARM::t2SUBspImm : ARM::t2SUBri;
398 unsigned t2ADD = ToSP ? ARM::t2ADDspImm : ARM::t2ADDri;
399 unsigned t2SUBi12 = ToSP ? ARM::t2SUBspImm12 : ARM::t2SUBri12;
400 unsigned t2ADDi12 = ToSP ? ARM::t2ADDspImm12 : ARM::t2ADDri12;
401 Opc = isSub ? t2SUB : t2ADD;
403 if (ImmIsT2SO != -1) {
405 }
else if (ThisVal < 4096) {
408 Opc = isSub ? t2SUBi12 : t2ADDi12;
416 NumBytes &= ~ThisVal;
418 "Bit extraction didn't work?");
438 case ARM::t2LDRi12:
return ARM::t2LDRi8;
439 case ARM::t2LDRHi12:
return ARM::t2LDRHi8;
440 case ARM::t2LDRBi12:
return ARM::t2LDRBi8;
441 case ARM::t2LDRSHi12:
return ARM::t2LDRSHi8;
442 case ARM::t2LDRSBi12:
return ARM::t2LDRSBi8;
443 case ARM::t2STRi12:
return ARM::t2STRi8;
444 case ARM::t2STRBi12:
return ARM::t2STRBi8;
445 case ARM::t2STRHi12:
return ARM::t2STRHi8;
446 case ARM::t2PLDi12:
return ARM::t2PLDi8;
447 case ARM::t2PLDWi12:
return ARM::t2PLDWi8;
448 case ARM::t2PLIi12:
return ARM::t2PLIi8;
472 case ARM::t2LDRi8:
return ARM::t2LDRi12;
473 case ARM::t2LDRHi8:
return ARM::t2LDRHi12;
474 case ARM::t2LDRBi8:
return ARM::t2LDRBi12;
475 case ARM::t2LDRSHi8:
return ARM::t2LDRSHi12;
476 case ARM::t2LDRSBi8:
return ARM::t2LDRSBi12;
477 case ARM::t2STRi8:
return ARM::t2STRi12;
478 case ARM::t2STRBi8:
return ARM::t2STRBi12;
479 case ARM::t2STRHi8:
return ARM::t2STRHi12;
480 case ARM::t2PLDi8:
return ARM::t2PLDi12;
481 case ARM::t2PLDWi8:
return ARM::t2PLDWi12;
482 case ARM::t2PLIi8:
return ARM::t2PLIi12;
487 case ARM::t2LDRSHi12:
488 case ARM::t2LDRSBi12:
506 case ARM::t2LDRs:
return ARM::t2LDRi12;
507 case ARM::t2LDRHs:
return ARM::t2LDRHi12;
508 case ARM::t2LDRBs:
return ARM::t2LDRBi12;
509 case ARM::t2LDRSHs:
return ARM::t2LDRSHi12;
510 case ARM::t2LDRSBs:
return ARM::t2LDRSBi12;
511 case ARM::t2STRs:
return ARM::t2STRi12;
512 case ARM::t2STRBs:
return ARM::t2STRBi12;
513 case ARM::t2STRHs:
return ARM::t2STRHi12;
514 case ARM::t2PLDs:
return ARM::t2PLDi12;
515 case ARM::t2PLDWs:
return ARM::t2PLDWi12;
516 case ARM::t2PLIs:
return ARM::t2PLIi12;
521 case ARM::t2LDRSHi12:
522 case ARM::t2LDRSBi12:
551 unsigned Opcode =
MI.getOpcode();
560 if (Opcode == ARM::INLINEASM || Opcode == ARM::INLINEASM_BR)
563 const bool IsSP = Opcode == ARM::t2ADDspImm12 || Opcode == ARM::t2ADDspImm;
564 if (IsSP || Opcode == ARM::t2ADDri || Opcode == ARM::t2ADDri12) {
565 Offset +=
MI.getOperand(FrameRegIdx+1).getImm();
569 !
MI.definesRegister(ARM::CPSR,
nullptr)) {
571 MI.setDesc(
TII.get(ARM::tMOVr));
572 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
574 do MI.removeOperand(FrameRegIdx+1);
575 while (
MI.getNumOperands() > FrameRegIdx+1);
581 bool HasCCOut = (Opcode != ARM::t2ADDspImm12 && Opcode != ARM::t2ADDri12);
586 MI.setDesc(IsSP ?
TII.get(ARM::t2SUBspImm) :
TII.get(ARM::t2SUBri));
588 MI.setDesc(IsSP ?
TII.get(ARM::t2ADDspImm) :
TII.get(ARM::t2ADDri));
593 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
594 MI.getOperand(FrameRegIdx+1).ChangeToImmediate(
Offset);
603 (!HasCCOut ||
MI.getOperand(
MI.getNumOperands()-1).getReg() == 0)) {
604 unsigned NewOpc = isSub ? IsSP ? ARM::t2SUBspImm12 : ARM::t2SUBri12
605 : IsSP ? ARM::t2ADDspImm12 : ARM::t2ADDri12;
606 MI.setDesc(
TII.get(NewOpc));
607 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
608 MI.getOperand(FrameRegIdx+1).ChangeToImmediate(
Offset);
611 MI.removeOperand(
MI.getNumOperands()-1);
625 "Bit extraction didn't work?");
626 MI.getOperand(FrameRegIdx+1).ChangeToImmediate(ThisImmVal);
637 unsigned NewOpc = Opcode;
639 Register OffsetReg =
MI.getOperand(FrameRegIdx + 1).getReg();
640 if (OffsetReg != 0) {
641 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
645 MI.removeOperand(FrameRegIdx+1);
646 MI.getOperand(FrameRegIdx+1).ChangeToImmediate(0);
651 unsigned NumBits = 0;
658 Offset +=
MI.getOperand(FrameRegIdx+1).getImm();
677 assert((
Offset & (Scale-1)) == 0 &&
"Can't encode this offset!");
691 assert((
Offset & (Scale-1)) == 0 &&
"Can't encode this offset!");
699 Offset +=
MI.getOperand(FrameRegIdx + 1).getImm();
704 default: NumBits = 7; OffsetMask = 0x0;
break;
708 assert((
Offset & OffsetMask) == 0 &&
"Can't encode this offset!");
711 Offset +=
MI.getOperand(FrameRegIdx + 1).getImm();
715 assert((
Offset & 3) == 0 &&
"Can't encode this offset!");
717 Offset +=
MI.getOperand(FrameRegIdx + 1).getImm() * 4;
720 assert((
Offset & 3) == 0 &&
"Can't encode this offset!");
725 if (NewOpc != Opcode)
726 MI.setDesc(
TII.get(NewOpc));
734 int ImmedOffset =
Offset / Scale;
735 unsigned Mask = (1 << NumBits) - 1;
736 if ((
unsigned)
Offset <= Mask * Scale &&
741 if (!
MRI->constrainRegClass(FrameReg, RegClass))
746 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
750 ImmedOffset |= 1 << NumBits;
752 ImmedOffset = -ImmedOffset;
760 ImmedOffset = ImmedOffset & Mask;
764 ImmedOffset |= 1 << NumBits;
766 ImmedOffset = -ImmedOffset;
767 if (ImmedOffset == 0)
782 unsigned Opc =
MI.getOpcode();
783 if (
Opc == ARM::tBcc ||
Opc == ARM::t2Bcc)
791 for (
unsigned i = 0, e =
MCID.getNumOperands(); i != e; ++i)
801 for (
unsigned i = 0, e =
MCID.getNumOperands(); i != e; ++i)
803 return i + ARM::SUBOP_vpred_r_inactive;
816 PredReg =
MI.getOperand(PIdx+1).getReg();
824 assert(MaskOp.
isImm() &&
"Operand 0 is not the block mask of the VPT/VPST?!");
827 End = Instr.getParent()->end();
829 while (Iter !=
End && Iter->isDebugInstr())
834 assert(Iter !=
End &&
"Expected some instructions in any VPT block");
837 "VPT/VPST should be followed by an instruction with a 'then' predicate!");
842 while (Iter !=
End) {
843 if (Iter->isDebugInstr()) {
855 MaskOp.
setImm((int64_t)(BlockMask));
const AArch64Subtarget & Subtarget
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const AArch64InstrInfo & TII
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Module.h This file contains the declarations for the Module class.
Register const TargetRegisterInfo * TRI
Promote Memory to Register
MachineRegisterInfo & MRI
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static unsigned negativeOffsetOpcode(unsigned opcode)
static unsigned positiveOffsetOpcode(unsigned opcode)
static unsigned immediateOffsetOpcode(unsigned opcode)
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
MachineInstr * optimizeSelect(MachineInstr &MI, SmallPtrSetImpl< MachineInstr * > &SeenMIs, bool) const override
const MachineInstrBuilder & AddDReg(MachineInstrBuilder &MIB, unsigned Reg, unsigned SubIdx, RegState State) const
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
void expandLoadStackGuardBase(MachineBasicBlock::iterator MI, unsigned LoadImmOpc, unsigned LoadOpc) const
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
ARMBaseInstrInfo(const ARMSubtarget &STI, const ARMBaseRegisterInfo &TRI)
const ARMSubtarget & getSubtarget() const
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const override
Commutes the operands in the given instruction.
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
Module * getParent()
Get the module that this global value is contained inside of...
MCInstBuilder & addReg(MCRegister Reg)
Add a new register operand.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
MachineInstrBundleIterator< MachineInstr > iterator
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
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.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
Representation of each machine instruction.
A description of a memory reference used in the backend.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
MachineOperand class - Representation of each machine instruction operand.
void setImm(int64_t immVal)
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
LLVM_ABI void ChangeToImmediate(int64_t ImmVal, unsigned TargetFlags=0)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A Module instance is used to store all the information related to an LLVM module.
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
virtual void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail, MachineBasicBlock *NewDest) const
Delete the instruction OldInst and everything after it, replacing it with an unconditional branch to ...
bool isPositionIndependent() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool isLegalToSplitMBBAt(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) const override
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
unsigned getUnindexedOpcode(unsigned Opc) const override
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const override
void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail, MachineBasicBlock *NewDest) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
MachineInstr * optimizeSelect(MachineInstr &MI, SmallPtrSetImpl< MachineInstr * > &SeenMIs, bool) const override
Thumb2InstrInfo(const ARMSubtarget &STI)
MCInst getNop() const override
Return the noop instruction to use for a noop.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned char getAM5FP16Offset(unsigned AM5Opc)
int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
AddrOpc getAM5Op(unsigned AM5Opc)
AddrOpc getAM5FP16Op(unsigned AM5Opc)
unsigned char getAM5Offset(unsigned AM5Opc)
PredBlockMask
Mask values for IT and VPT Blocks, to be used by MCOperands.
bool isVpred(OperandType op)
This is an optimization pass for GlobalISel generic memory operations.
int findVPTInactiveOperandIdx(const MachineInstr &MI)
constexpr T rotr(T V, int R)
int findFirstVPTPredOperandIdx(const MachineInstr &MI)
ARMVCC::VPTCodes getVPTInstrPredicate(const MachineInstr &MI, Register &PredReg)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
@ Kill
The last use of a register.
constexpr RegState getKillRegState(bool B)
static bool isVPTOpcode(int Opc)
bool rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, Register FrameReg, int &Offset, const ARMBaseInstrInfo &TII, const TargetRegisterInfo *TRI)
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
int countl_zero(T Val)
Count number of 0's from the most significant bit to the least stopping at the first 1.
ARMCC::CondCodes getITInstrPredicate(const MachineInstr &MI, Register &PredReg)
getITInstrPredicate - Valid only in Thumb2 mode.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
ARM::PredBlockMask expandPredBlockMask(ARM::PredBlockMask BlockMask, ARMVCC::VPTCodes Kind)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
ARMCC::CondCodes getInstrPredicate(const MachineInstr &MI, Register &PredReg)
getInstrPredicate - If instruction is predicated, returns its predicate condition,...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
static MachineOperand condCodeOp(unsigned CCReg=0)
Get the operand corresponding to the conditional code result.
@ End
Run the machine verifier once, at the end of the pipeline.
void recomputeVPTBlockMask(MachineInstr &Instr)
void emitT2RegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, Register DestReg, Register BaseReg, int NumBytes, ARMCC::CondCodes Pred, Register PredReg, const ARMBaseInstrInfo &TII, unsigned MIFlags=0)
MCRegisterClass TargetRegisterClass
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.