39 cl::desc(
"Use old-style Thumb2 if-conversion heuristics"),
84 while (Count && MBBI != E) {
85 if (MBBI->isDebugValue()) {
89 if (MBBI->getOpcode() == ARM::t2IT) {
90 unsigned Mask = MBBI->getOperand(1).getImm();
92 MBBI->eraseFromParent();
94 unsigned MaskOn = 1 << Count;
95 unsigned MaskOff = ~(MaskOn - 1);
96 MBBI->getOperand(1).setImm((Mask & MaskOff) | MaskOn);
112 while (MBBI->isDebugValue()) {
114 if (MBBI == MBB.
end())
118 unsigned PredReg = 0;
125 unsigned SrcReg,
bool KillSrc)
const {
127 if (!ARM::GPRRegClass.
contains(DestReg, SrcReg))
130 BuildMI(MBB, I, DL,
get(ARM::tMOVr), DestReg)
137 unsigned SrcReg,
bool isKill,
int FI,
141 if (I != MBB.
end()) DL = I->getDebugLoc();
149 if (RC == &ARM::GPRRegClass || RC == &ARM::tGPRRegClass ||
150 RC == &ARM::tcGPRRegClass || RC == &ARM::rGPRRegClass ||
151 RC == &ARM::GPRnopcRegClass) {
152 BuildMI(MBB, I, DL,
get(ARM::t2STRi12))
161 if (ARM::GPRPairRegClass.hasSubClassEq(RC)) {
172 AddDReg(MIB, SrcReg, ARM::gsub_1, 0, TRI);
182 unsigned DestReg,
int FI,
191 if (I != MBB.
end()) DL = I->getDebugLoc();
193 if (RC == &ARM::GPRRegClass || RC == &ARM::tGPRRegClass ||
194 RC == &ARM::tcGPRRegClass || RC == &ARM::rGPRRegClass ||
195 RC == &ARM::GPRnopcRegClass) {
196 BuildMI(MBB, I, DL,
get(ARM::t2LDRi12), DestReg)
204 if (ARM::GPRPairRegClass.hasSubClassEq(RC)) {
211 &ARM::GPRPair_with_gsub_1_in_rGPRRegClass);
227 void Thumb2InstrInfo::expandLoadStackGuard(
238 const DebugLoc &dl,
unsigned DestReg,
239 unsigned BaseReg,
int NumBytes,
243 if (NumBytes == 0 && DestReg != BaseReg) {
244 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), DestReg)
250 bool isSub = NumBytes < 0;
251 if (isSub) NumBytes = -NumBytes;
255 if (DestReg != ARM::SP && DestReg != BaseReg &&
259 if (NumBytes < 65536) {
261 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2MOVi16), DestReg)
265 }
else if ((NumBytes & 0xffff) == 0) {
267 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2MOVTi16), DestReg)
276 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2SUBrr), DestReg)
288 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2ADDrr), DestReg)
300 unsigned ThisVal = NumBytes;
302 if (DestReg == ARM::SP && BaseReg != ARM::SP) {
304 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), DestReg)
312 bool HasCCOut =
true;
313 if (BaseReg == ARM::SP) {
315 if (DestReg == ARM::SP && (ThisVal < ((1 << 7)-1) * 4)) {
316 assert((ThisVal & 3) == 0 &&
"Stack update is not multiple of 4?");
317 Opc = isSub ? ARM::tSUBspi : ARM::tADDspi;
318 BuildMI(MBB, MBBI, dl, TII.get(Opc), DestReg)
328 Opc = isSub ? ARM::t2SUBri : ARM::t2ADDri;
335 NumBytes &= ~ThisVal;
337 "Bit extraction didn't work?");
340 assert(DestReg != ARM::SP && BaseReg != ARM::SP);
341 Opc = isSub ? ARM::t2SUBri : ARM::t2ADDri;
344 }
else if (ThisVal < 4096) {
345 Opc = isSub ? ARM::t2SUBri12 : ARM::t2ADDri12;
352 NumBytes &= ~ThisVal;
354 "Bit extraction didn't work?");
375 case ARM::t2LDRi12:
return ARM::t2LDRi8;
376 case ARM::t2LDRHi12:
return ARM::t2LDRHi8;
377 case ARM::t2LDRBi12:
return ARM::t2LDRBi8;
378 case ARM::t2LDRSHi12:
return ARM::t2LDRSHi8;
379 case ARM::t2LDRSBi12:
return ARM::t2LDRSBi8;
380 case ARM::t2STRi12:
return ARM::t2STRi8;
381 case ARM::t2STRBi12:
return ARM::t2STRBi8;
382 case ARM::t2STRHi12:
return ARM::t2STRHi8;
383 case ARM::t2PLDi12:
return ARM::t2PLDi8;
407 case ARM::t2LDRi8:
return ARM::t2LDRi12;
408 case ARM::t2LDRHi8:
return ARM::t2LDRHi12;
409 case ARM::t2LDRBi8:
return ARM::t2LDRBi12;
410 case ARM::t2LDRSHi8:
return ARM::t2LDRSHi12;
411 case ARM::t2LDRSBi8:
return ARM::t2LDRSBi12;
412 case ARM::t2STRi8:
return ARM::t2STRi12;
413 case ARM::t2STRBi8:
return ARM::t2STRBi12;
414 case ARM::t2STRHi8:
return ARM::t2STRHi12;
415 case ARM::t2PLDi8:
return ARM::t2PLDi12;
420 case ARM::t2LDRSHi12:
421 case ARM::t2LDRSBi12:
439 case ARM::t2LDRs:
return ARM::t2LDRi12;
440 case ARM::t2LDRHs:
return ARM::t2LDRHi12;
441 case ARM::t2LDRBs:
return ARM::t2LDRBi12;
442 case ARM::t2LDRSHs:
return ARM::t2LDRSHi12;
443 case ARM::t2LDRSBs:
return ARM::t2LDRSBi12;
444 case ARM::t2STRs:
return ARM::t2STRi12;
445 case ARM::t2STRBs:
return ARM::t2STRBi12;
446 case ARM::t2STRHs:
return ARM::t2STRHi12;
447 case ARM::t2PLDs:
return ARM::t2PLDi12;
452 case ARM::t2LDRSHi12:
453 case ARM::t2LDRSBi12:
477 unsigned FrameReg,
int &
Offset,
488 if (Opcode == ARM::t2ADDri || Opcode == ARM::t2ADDri12) {
494 MI.
setDesc(TII.get(ARM::tMOVr));
504 bool HasCCOut = Opcode != ARM::t2ADDri12;
509 MI.
setDesc(TII.get(ARM::t2SUBri));
511 MI.
setDesc(TII.get(ARM::t2ADDri));
527 unsigned NewOpc = isSub ? ARM::t2SUBri12 : ARM::t2ADDri12;
540 unsigned RotAmt = countLeadingZeros<unsigned>(
Offset);
541 unsigned ThisImmVal = Offset &
ARM_AM::rotr32(0xff000000U, RotAmt);
544 Offset &= ~ThisImmVal;
547 "Bit extraction didn't work?");
559 unsigned NewOpc = Opcode;
562 if (OffsetReg != 0) {
573 unsigned NumBits = 0;
597 Offset += InstrOffs * 4;
598 assert((Offset & (Scale-1)) == 0 &&
"Can't encode this offset!");
608 assert((Offset & 3) == 0 &&
"Can't encode this offset!");
613 if (NewOpc != Opcode)
620 int ImmedOffset = Offset / Scale;
621 unsigned Mask = (1 << NumBits) - 1;
622 if ((
unsigned)Offset <= Mask * Scale) {
628 ImmedOffset |= 1 << NumBits;
630 ImmedOffset = -ImmedOffset;
638 ImmedOffset = ImmedOffset &
Mask;
642 ImmedOffset |= 1 << NumBits;
644 ImmedOffset = -ImmedOffset;
645 if (ImmedOffset == 0)
651 Offset &= ~(Mask*Scale);
654 Offset = (isSub) ? -Offset : Offset;
661 if (Opc == ARM::tBcc || Opc == ARM::t2Bcc)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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
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...
Describe properties that are true of each instruction in the target description file.
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
const MachineInstrBuilder & add(const MachineOperand &MO) const
static unsigned negativeOffsetOpcode(unsigned opcode)
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
void expandLoadStackGuardBase(MachineBasicBlock::iterator MI, unsigned LoadImmOpc, unsigned LoadOpc) const
std::size_t 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...
return AArch64::GPR64RegClass contains(Reg)
static unsigned rotr32(unsigned Val, unsigned Amt)
rotr32 - Rotate a 32-bit unsigned value right by a specified # bits.
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)
const HexagonInstrInfo * TII
static MachineOperand CreateReg(unsigned 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)
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)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
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.
bool rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, int &Offset, const ARMBaseInstrInfo &TII)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
INLINEASM - Represents an inline asm block.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
void RemoveOperand(unsigned i)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
static int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
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 copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
const MachineBasicBlock * getParent() const
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 getUnindexedOpcode(unsigned Opc) const override
initializer< Ty > init(const Ty &Val)
unsigned const MachineRegisterInfo * MRI
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static unsigned char getAM5Offset(unsigned AM5Opc)
const MachineOperand & getOperand(unsigned i) const
void getNoop(MCInst &NopInst) const override
Return the noop instruction to use for a noop.
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
bool isPositionIndependent() const
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Thumb2InstrInfo(const ARMSubtarget &STI)
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...
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...
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.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail, MachineBasicBlock *NewDest) const override
const MachineInstrBuilder & addFrameIndex(int Idx) const
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
AddrMode
ARM Addressing Modes.
llvm_unreachable("Unknown RegBank!")
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.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
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)
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
static AddrOpc getAM5Op(unsigned AM5Opc)
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
void addOperand(const MCOperand &Op)
virtual void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail, MachineBasicBlock *NewDest) const
Delete the instruction OldInst and everything after it, replacing it with an unconditional branch to ...
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
static MCOperand createImm(int64_t Val)
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
const MachineInstrBuilder & AddDReg(MachineInstrBuilder &MIB, unsigned Reg, unsigned SubIdx, unsigned State, const TargetRegisterInfo *TRI) const