38 cl::desc(
"Use old-style Thumb2 if-conversion heuristics"),
83 while (Count && MBBI != E) {
84 if (MBBI->isDebugInstr()) {
88 if (MBBI->getOpcode() == ARM::t2IT) {
89 unsigned Mask = MBBI->getOperand(1).getImm();
91 MBBI->eraseFromParent();
93 unsigned MaskOn = 1 << Count;
94 unsigned MaskOff = ~(MaskOn - 1);
95 MBBI->getOperand(1).setImm((Mask & MaskOff) | MaskOn);
111 while (MBBI->isDebugInstr()) {
113 if (MBBI == MBB.
end())
117 unsigned PredReg = 0;
126 if (!ARM::GPRRegClass.
contains(DestReg, SrcReg))
129 BuildMI(MBB, I, DL,
get(ARM::tMOVr), DestReg)
136 unsigned SrcReg,
bool isKill,
int FI,
140 if (I != MBB.
end()) DL = I->getDebugLoc();
148 if (ARM::GPRRegClass.hasSubClassEq(RC)) {
149 BuildMI(MBB, I, DL,
get(ARM::t2STRi12))
158 if (ARM::GPRPairRegClass.hasSubClassEq(RC)) {
169 AddDReg(MIB, SrcReg, ARM::gsub_1, 0, TRI);
179 unsigned DestReg,
int FI,
188 if (I != MBB.
end()) DL = I->getDebugLoc();
190 if (ARM::GPRRegClass.hasSubClassEq(RC)) {
191 BuildMI(MBB, I, DL,
get(ARM::t2LDRi12), DestReg)
199 if (ARM::GPRPairRegClass.hasSubClassEq(RC)) {
221 void Thumb2InstrInfo::expandLoadStackGuard(
232 const DebugLoc &dl,
unsigned DestReg,
233 unsigned BaseReg,
int NumBytes,
237 if (NumBytes == 0 && DestReg != BaseReg) {
238 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), DestReg)
244 bool isSub = NumBytes < 0;
245 if (isSub) NumBytes = -NumBytes;
249 if (DestReg != ARM::SP && DestReg != BaseReg &&
253 if (NumBytes < 65536) {
255 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2MOVi16), DestReg)
259 }
else if ((NumBytes & 0xffff) == 0) {
261 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2MOVTi16), DestReg)
270 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2SUBrr), DestReg)
282 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2ADDrr), DestReg)
294 unsigned ThisVal = NumBytes;
296 if (DestReg == ARM::SP && BaseReg != ARM::SP) {
298 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), DestReg)
306 assert((DestReg != ARM::SP || BaseReg == ARM::SP) &&
307 "Writing to SP, from other register.");
310 if ((DestReg == ARM::SP) && (ThisVal < ((1 << 7) - 1) * 4)) {
311 assert((ThisVal & 3) == 0 &&
"Stack update is not multiple of 4?");
312 Opc = isSub ? ARM::tSUBspi : ARM::tADDspi;
313 BuildMI(MBB, MBBI, dl, TII.get(Opc), DestReg)
320 bool HasCCOut =
true;
322 bool ToSP = DestReg == ARM::SP;
323 unsigned t2SUB = ToSP ? ARM::t2SUBspImm : ARM::t2SUBri;
324 unsigned t2ADD = ToSP ? ARM::t2ADDspImm : ARM::t2ADDri;
325 unsigned t2SUBi12 = ToSP ? ARM::t2SUBspImm12 : ARM::t2SUBri12;
326 unsigned t2ADDi12 = ToSP ? ARM::t2ADDspImm12 : ARM::t2ADDri12;
327 Opc = isSub ? t2SUB : t2ADD;
329 if (ImmIsT2SO != -1) {
331 }
else if (ThisVal < 4096) {
334 Opc = isSub ? t2SUBi12 : t2ADDi12;
342 NumBytes &= ~ThisVal;
344 "Bit extraction didn't work?");
364 case ARM::t2LDRi12:
return ARM::t2LDRi8;
365 case ARM::t2LDRHi12:
return ARM::t2LDRHi8;
366 case ARM::t2LDRBi12:
return ARM::t2LDRBi8;
367 case ARM::t2LDRSHi12:
return ARM::t2LDRSHi8;
368 case ARM::t2LDRSBi12:
return ARM::t2LDRSBi8;
369 case ARM::t2STRi12:
return ARM::t2STRi8;
370 case ARM::t2STRBi12:
return ARM::t2STRBi8;
371 case ARM::t2STRHi12:
return ARM::t2STRHi8;
372 case ARM::t2PLDi12:
return ARM::t2PLDi8;
373 case ARM::t2PLDWi12:
return ARM::t2PLDWi8;
374 case ARM::t2PLIi12:
return ARM::t2PLIi8;
398 case ARM::t2LDRi8:
return ARM::t2LDRi12;
399 case ARM::t2LDRHi8:
return ARM::t2LDRHi12;
400 case ARM::t2LDRBi8:
return ARM::t2LDRBi12;
401 case ARM::t2LDRSHi8:
return ARM::t2LDRSHi12;
402 case ARM::t2LDRSBi8:
return ARM::t2LDRSBi12;
403 case ARM::t2STRi8:
return ARM::t2STRi12;
404 case ARM::t2STRBi8:
return ARM::t2STRBi12;
405 case ARM::t2STRHi8:
return ARM::t2STRHi12;
406 case ARM::t2PLDi8:
return ARM::t2PLDi12;
407 case ARM::t2PLDWi8:
return ARM::t2PLDWi12;
408 case ARM::t2PLIi8:
return ARM::t2PLIi12;
413 case ARM::t2LDRSHi12:
414 case ARM::t2LDRSBi12:
432 case ARM::t2LDRs:
return ARM::t2LDRi12;
433 case ARM::t2LDRHs:
return ARM::t2LDRHi12;
434 case ARM::t2LDRBs:
return ARM::t2LDRBi12;
435 case ARM::t2LDRSHs:
return ARM::t2LDRSHi12;
436 case ARM::t2LDRSBs:
return ARM::t2LDRSBi12;
437 case ARM::t2STRs:
return ARM::t2STRi12;
438 case ARM::t2STRBs:
return ARM::t2STRBi12;
439 case ARM::t2STRHs:
return ARM::t2STRHi12;
440 case ARM::t2PLDs:
return ARM::t2PLDi12;
441 case ARM::t2PLDWs:
return ARM::t2PLDWi12;
442 case ARM::t2PLIs:
return ARM::t2PLIi12;
447 case ARM::t2LDRSHi12:
448 case ARM::t2LDRSBi12:
474 unsigned FrameReg,
int &
Offset,
484 TII.getRegClass(Desc, FrameRegIdx, TRI, MF);
490 const bool IsSP = Opcode == ARM::t2ADDspImm12 || Opcode == ARM::t2ADDspImm;
491 if (IsSP || Opcode == ARM::t2ADDri || Opcode == ARM::t2ADDri12) {
498 MI.
setDesc(TII.get(ARM::tMOVr));
508 bool HasCCOut = (Opcode != ARM::t2ADDspImm12 && Opcode != ARM::t2ADDri12);
513 MI.
setDesc(IsSP ? TII.get(ARM::t2SUBspImm) : TII.get(ARM::t2SUBri));
515 MI.
setDesc(IsSP ? TII.get(ARM::t2ADDspImm) : TII.get(ARM::t2ADDri));
531 unsigned NewOpc = isSub ? IsSP ? ARM::t2SUBspImm12 : ARM::t2SUBri12
532 : IsSP ? ARM::t2ADDspImm12 : ARM::t2ADDri12;
545 unsigned RotAmt = countLeadingZeros<unsigned>(
Offset);
546 unsigned ThisImmVal = Offset &
ARM_AM::rotr32(0xff000000U, RotAmt);
549 Offset &= ~ThisImmVal;
552 "Bit extraction didn't work?");
564 unsigned NewOpc = Opcode;
567 if (OffsetReg != 0) {
578 unsigned NumBits = 0;
602 Offset += InstrOffs * 4;
603 assert((Offset & (Scale-1)) == 0 &&
"Can't encode this offset!");
616 Offset += InstrOffs * 2;
617 assert((Offset & (Scale-1)) == 0 &&
"Can't encode this offset!");
630 default: NumBits = 7; OffsetMask = 0x0;
break;
634 assert((Offset & OffsetMask) == 0 &&
"Can't encode this offset!");
641 assert((Offset & 3) == 0 &&
"Can't encode this offset!");
646 assert((Offset & 3) == 0 &&
"Can't encode this offset!");
651 if (NewOpc != Opcode)
660 int ImmedOffset = Offset / Scale;
661 unsigned Mask = (1 << NumBits) - 1;
662 if ((
unsigned)Offset <= Mask * Scale &&
677 ImmedOffset |= 1 << NumBits;
679 ImmedOffset = -ImmedOffset;
687 ImmedOffset = ImmedOffset &
Mask;
691 ImmedOffset |= 1 << NumBits;
693 ImmedOffset = -ImmedOffset;
694 if (ImmedOffset == 0)
700 Offset &= ~(Mask*Scale);
703 Offset = (isSub) ? -Offset : Offset;
711 if (Opc == ARM::tBcc || Opc == ARM::t2Bcc)
const MachineInstrBuilder & add(const MachineOperand &MO) const
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
Wrapper class representing physical registers. Should be passed by value.
This class represents lattice values for constants.
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.
static unsigned negativeOffsetOpcode(unsigned opcode)
unsigned const TargetRegisterInfo * TRI
return AArch64::GPR64RegClass contains(Reg)
static cl::opt< bool > OldT2IfCvt("old-thumb2-ifcvt", cl::Hidden, cl::desc("Use old-style Thumb2 if-conversion heuristics"), cl::init(false))
bool isLegalToSplitMBBAt(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) const override
A description of a memory reference used in the backend.
static MCOperand createReg(unsigned Reg)
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
const HexagonInstrInfo * TII
unsigned getNumOperands() const
Retuns the total number of operands.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
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)
const MachineInstrBuilder & AddDReg(MachineInstrBuilder &MIB, unsigned Reg, unsigned SubIdx, unsigned State, const TargetRegisterInfo *TRI) const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
INLINEASM - Represents an inline asm block.
uint8_t OperandType
Information about the type of the operand.
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.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
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...
Instances of this class represent a single low-level machine instruction.
unsigned getKillRegState(bool B)
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
unsigned getUnindexedOpcode(unsigned Opc) const override
virtual void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail, MachineBasicBlock *NewDest) const
Delete the instruction OldInst and everything after it, replacing it with an unconditional branch to ...
initializer< Ty > init(const Ty &Val)
unsigned char getAM5Offset(unsigned AM5Opc)
unsigned const MachineRegisterInfo * MRI
int findFirstVPTPredOperandIdx(const MachineInstr &MI)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void expandLoadStackGuardBase(MachineBasicBlock::iterator MI, unsigned LoadImmOpc, unsigned LoadOpc) const
void getNoop(MCInst &NopInst) const override
Return the noop instruction to use for a noop.
bool definesRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr fully defines the specified register.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
Thumb2InstrInfo(const ARMSubtarget &STI)
const MachineInstrBuilder & addFrameIndex(int Idx) const
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)
unsigned rotr32(unsigned Val, unsigned Amt)
rotr32 - Rotate a 32-bit unsigned value right by a specified # bits.
static unsigned immediateOffsetOpcode(unsigned opcode)
ARMCC::CondCodes getInstrPredicate(const MachineInstr &MI, unsigned &PredReg)
getInstrPredicate - If instruction is predicated, returns its predicate condition, otherwise returns AL.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
unsigned countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the most significant bit to the least stopping at the first 1...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
The memory access writes data.
void setOpcode(unsigned Op)
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
bool rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, int &Offset, const ARMBaseInstrInfo &TII, const TargetRegisterInfo *TRI)
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
ARMCC::CondCodes getITInstrPredicate(const MachineInstr &MI, unsigned &PredReg)
getITInstrPredicate - Valid only in Thumb2 mode.
MachineOperand class - Representation of each machine instruction operand.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail, MachineBasicBlock *NewDest) const override
bool isVpred(OperandType op)
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
AddrOpc getAM5FP16Op(unsigned AM5Opc)
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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 unsigned positiveOffsetOpcode(unsigned opcode)
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
ARMVCC::VPTCodes getVPTInstrPredicate(const MachineInstr &MI, unsigned &PredReg)
bool isPositionIndependent() const
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
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...
Tail - This calling convention attemps to make calls as fast as possible while guaranteeing that tail...
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
INLINEASM_BR - Terminator version of inline asm. Used by asm-goto.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
const MCOperandInfo * OpInfo
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.
void addOperand(const MCOperand &Op)
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
unsigned char getAM5FP16Offset(unsigned AM5Opc)
AddrOpc getAM5Op(unsigned AM5Opc)
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
static MCOperand createImm(int64_t Val)
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Wrapper class representing virtual and physical registers.