39 #include "llvm/Config/llvm-config.h" 60 #define DEBUG_TYPE "arm-cp-islands" 62 #define ARM_CP_ISLANDS_OPT_NAME \ 63 "ARM constant island placement and branch shortening pass" 64 STATISTIC(NumCPEs,
"Number of constpool entries");
65 STATISTIC(NumSplit,
"Number of uncond branches inserted");
66 STATISTIC(NumCBrFixed,
"Number of cond branches fixed");
67 STATISTIC(NumUBrFixed,
"Number of uncond branches fixed");
68 STATISTIC(NumTBs,
"Number of table branches generated");
69 STATISTIC(NumT2CPShrunk,
"Number of Thumb2 constantpool instructions shrunk");
70 STATISTIC(NumT2BrShrunk,
"Number of Thumb2 immediate branches shrunk");
71 STATISTIC(NumCBZ,
"Number of CBZ / CBNZ formed");
72 STATISTIC(NumJTMoved,
"Number of jump table destination blocks moved");
73 STATISTIC(NumJTInserted,
"Number of jump table intermediate blocks inserted");
74 STATISTIC(NumLEInserted,
"Number of LE backwards branches inserted");
78 cl::desc(
"Adjust basic block layout to better use TB[BH]"));
82 cl::desc(
"The max number of iteration for converge"));
86 cl::desc(
"Use compressed jump tables in Thumb-1 by synthesizing an " 87 "equivalent to the TBB/TBH instructions"));
103 std::unique_ptr<ARMBasicBlockUtils> BBUtils =
nullptr;
108 std::vector<MachineBasicBlock*> WaterList;
114 using water_iterator = std::vector<MachineBasicBlock *>::iterator;
135 bool KnownAlignment =
false;
138 bool neg,
bool soimm)
139 : MI(mi), CPEMI(cpemi), MaxDisp(maxdisp), NegOk(neg), IsSoImm(soimm) {
146 unsigned getMaxDisp()
const {
147 return (KnownAlignment ? MaxDisp : MaxDisp - 2) - 2;
153 std::vector<CPUser> CPUsers;
164 : CPEMI(cpemi), CPI(cpi), RefCount(
rc) {}
176 std::vector<std::vector<CPEntry>> CPEntries;
192 unsigned MaxDisp : 31;
196 ImmBranch(
MachineInstr *mi,
unsigned maxdisp,
bool cond,
unsigned ubr)
197 : MI(mi), MaxDisp(maxdisp), isCond(cond), UncondBr(ubr) {}
201 std::vector<ImmBranch> ImmBranches;
222 bool isPositionIndependentOrROPI;
246 void doInitialConstPlacement(std::vector<MachineInstr *> &CPEMIs);
247 void doInitialJumpTablePlacement(std::vector<MachineInstr *> &CPEMIs);
249 CPEntry *findConstPoolEntry(
unsigned CPI,
const MachineInstr *CPEMI);
251 void scanFunctionJumpTables();
252 void initializeFunctionInfo(
const std::vector<MachineInstr*> &CPEMIs);
255 bool decrementCPEReferenceCount(
unsigned CPI,
MachineInstr* CPEMI);
257 int findInRangeCPEntry(CPUser& U,
unsigned UserOffset);
258 bool findAvailableWater(CPUser&U,
unsigned UserOffset,
259 water_iterator &WaterIter,
bool CloserWater);
260 void createNewWater(
unsigned CPUserIndex,
unsigned UserOffset,
262 bool handleConstantPoolUser(
unsigned CPUserIndex,
bool CloserWater);
264 bool removeUnusedCPEntries();
265 bool isCPEntryInRange(
MachineInstr *MI,
unsigned UserOffset,
267 bool DoDump =
false);
269 CPUser &U,
unsigned &Growth);
270 bool fixupImmediateBr(ImmBranch &Br);
271 bool fixupConditionalBr(ImmBranch &Br);
272 bool fixupUnconditionalBr(ImmBranch &Br);
273 bool undoLRSpillRestore();
274 bool optimizeThumb2Instructions();
275 bool optimizeThumb2Branches();
276 bool reorderThumb2JumpTables();
278 unsigned &DeadSize,
bool &CanDeleteLEA,
280 bool optimizeThumb2JumpTables();
284 unsigned getUserOffset(CPUser&)
const;
288 bool isOffsetInRange(
unsigned UserOffset,
unsigned TrialOffset,
289 unsigned Disp,
bool NegativeOK,
bool IsSoImm =
false);
290 bool isOffsetInRange(
unsigned UserOffset,
unsigned TrialOffset,
292 return isOffsetInRange(UserOffset, TrialOffset,
293 U.getMaxDisp(), U.NegOk, U.IsSoImm);
308 return BBInfo[LHS.
getNumber()].postOffset() <
309 BBInfo[RHS.getNumber()].postOffset();
311 LLVM_DEBUG(
dbgs() <<
"Verifying " << CPUsers.size() <<
" CP users.\n");
312 for (
unsigned i = 0,
e = CPUsers.size(); i !=
e; ++i) {
313 CPUser &U = CPUsers[i];
314 unsigned UserOffset = getUserOffset(U);
317 if (isCPEntryInRange(U.MI, UserOffset, U.CPEMI, U.getMaxDisp()+2, U.NegOk,
330 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 335 for (
unsigned J = 0,
E = BBInfo.
size(); J !=
E; ++J) {
352 << MCP->
getConstants().size() <<
" CP entries, aligned to " 356 TII = STI->getInstrInfo();
357 isPositionIndependentOrROPI =
358 STI->getTargetLowering()->isPositionIndependent() || STI->isROPI();
360 DT = &getAnalysis<MachineDominatorTree>();
375 bool MadeChange =
false;
377 scanFunctionJumpTables();
378 MadeChange |= reorderThumb2JumpTables();
380 T2JumpTables.
clear();
387 std::vector<MachineInstr*> CPEMIs;
389 doInitialConstPlacement(CPEMIs);
392 doInitialJumpTablePlacement(CPEMIs);
400 initializeFunctionInfo(CPEMIs);
406 if (!T2JumpTables.
empty())
410 MadeChange |= removeUnusedCPEntries();
414 unsigned NoCPIters = 0, NoBRIters = 0;
416 LLVM_DEBUG(
dbgs() <<
"Beginning CP iteration #" << NoCPIters <<
'\n');
417 bool CPChange =
false;
418 for (
unsigned i = 0,
e = CPUsers.size(); i !=
e; ++i)
422 CPChange |= handleConstantPoolUser(i, NoCPIters >=
CPMaxIteration / 2);
429 NewWaterList.
clear();
431 LLVM_DEBUG(
dbgs() <<
"Beginning BR iteration #" << NoBRIters <<
'\n');
432 bool BRChange =
false;
433 for (
unsigned i = 0,
e = ImmBranches.size(); i !=
e; ++i)
434 BRChange |= fixupImmediateBr(ImmBranches[i]);
435 if (BRChange && ++NoBRIters > 30)
439 if (!CPChange && !BRChange)
445 if (isThumb2 && !STI->prefers32BitThumb())
446 MadeChange |= optimizeThumb2Instructions();
449 if (isThumb && STI->hasV8MBaselineOps())
450 MadeChange |= optimizeThumb2Branches();
453 if (GenerateTBB && !STI->genExecuteOnly())
454 MadeChange |= optimizeThumb2JumpTables();
462 MadeChange |= undoLRSpillRestore();
465 for (
unsigned i = 0,
e = CPEntries.size(); i !=
e; ++i) {
466 for (
unsigned j = 0, je = CPEntries[i].
size(); j != je; ++j) {
467 const CPEntry & CPE = CPEntries[i][j];
468 if (CPE.CPEMI && CPE.CPEMI->getOperand(1).isCPI())
479 JumpTableEntryIndices.
clear();
480 JumpTableUserIndices.
clear();
483 T2JumpTables.
clear();
491 ARMConstantIslands::doInitialConstPlacement(std::vector<MachineInstr*> &CPEMIs) {
498 const unsigned MaxLogAlign =
Log2(MaxAlign);
516 const std::vector<MachineConstantPoolEntry> &CPs = MCP->
getConstants();
519 for (
unsigned i = 0,
e = CPs.
size(); i !=
e; ++i) {
521 unsigned Align = CPs[i].getAlignment();
525 assert((Size % Align) == 0 &&
"CP Entry not multiple of 4 bytes!");
528 unsigned LogAlign =
Log2_32(Align);
533 CPEMIs.push_back(CPEMI);
537 for (
unsigned a = LogAlign + 1; a <= MaxLogAlign; ++a)
538 if (InsPoint[a] == InsAt)
542 CPEntries.emplace_back(1, CPEntry(CPEMI, i));
544 LLVM_DEBUG(
dbgs() <<
"Moved CPI#" << i <<
" to end of function, size = " 545 << Size <<
", align = " << Align <<
'\n');
555 void ARMConstantIslands::doInitialJumpTablePlacement(
556 std::vector<MachineInstr *> &CPEMIs) {
557 unsigned i = CPEntries.size();
559 const std::vector<MachineJumpTableEntry> &
JT = MJTI->getJumpTables();
563 auto MI = MBB.getLastNonDebugInstr();
574 case ARM::BR_JTm_i12:
576 JTOpcode = ARM::JUMPTABLE_ADDRS;
579 JTOpcode = ARM::JUMPTABLE_INSTS;
583 JTOpcode = ARM::JUMPTABLE_TBB;
587 JTOpcode = ARM::JUMPTABLE_TBH;
595 unsigned Size = JT[JTI].MBBs.size() *
sizeof(
uint32_t);
603 CPEMIs.push_back(CPEMI);
604 CPEntries.emplace_back(1, CPEntry(CPEMI, JTI));
605 JumpTableEntryIndices.
insert(std::make_pair(JTI, CPEntries.size() - 1));
606 if (!LastCorrectlyNumberedBB)
607 LastCorrectlyNumberedBB = &MBB;
611 if (LastCorrectlyNumberedBB)
612 MF->RenumberBlocks(LastCorrectlyNumberedBB);
632 bool TooDifficult = TII->
analyzeBranch(*MBB, TBB, FBB, Cond);
633 return TooDifficult || FBB ==
nullptr;
638 ARMConstantIslands::CPEntry *
639 ARMConstantIslands::findConstPoolEntry(
unsigned CPI,
641 std::vector<CPEntry> &CPEs = CPEntries[CPI];
644 for (
unsigned i = 0,
e = CPEs.size(); i !=
e; ++i) {
645 if (CPEs[i].CPEMI == CPEMI)
653 Align ARMConstantIslands::getCPEAlign(
const MachineInstr *CPEMI) {
655 case ARM::CONSTPOOL_ENTRY:
657 case ARM::JUMPTABLE_TBB:
658 return isThumb1 ?
Align(4) : Align(1);
659 case ARM::JUMPTABLE_TBH:
660 return isThumb1 ?
Align(4) : Align(2);
661 case ARM::JUMPTABLE_INSTS:
663 case ARM::JUMPTABLE_ADDRS:
669 unsigned CPI = getCombinedIndex(CPEMI);
670 assert(CPI < MCP->getConstants().
size() &&
"Invalid constant pool index.");
677 void ARMConstantIslands::scanFunctionJumpTables() {
681 (
I.getOpcode() == ARM::t2BR_JT ||
I.getOpcode() == ARM::tBR_JTr))
689 void ARMConstantIslands::
690 initializeFunctionInfo(
const std::vector<MachineInstr*> &CPEMIs) {
692 BBUtils->computeAllBlockSizes();
696 BBInfo.
front().KnownBits =
Log2(MF->getAlignment());
699 BBUtils->adjustBBOffsetsAfter(&MF->front());
706 WaterList.push_back(&MBB);
709 if (
I.isDebugInstr())
712 unsigned Opc =
I.getOpcode();
756 unsigned MaxOffs = ((1 << (Bits-1))-1) * Scale;
757 ImmBranches.push_back(ImmBranch(&
I, MaxOffs, isCond, UOpc));
760 if (Opc == ARM::tPUSH || Opc == ARM::tPOP_RET)
763 if (Opc == ARM::CONSTPOOL_ENTRY || Opc == ARM::JUMPTABLE_ADDRS ||
764 Opc == ARM::JUMPTABLE_INSTS || Opc == ARM::JUMPTABLE_TBB ||
765 Opc == ARM::JUMPTABLE_TBH)
769 for (
unsigned op = 0,
e =
I.getNumOperands();
op !=
e; ++
op)
770 if (
I.getOperand(
op).isCPI() ||
I.getOperand(
op).isJTI()) {
778 bool IsSoImm =
false;
786 case ARM::LEApcrelJT:
796 case ARM::t2LEApcrel:
797 case ARM::t2LEApcrelJT:
802 case ARM::tLEApcrelJT:
836 unsigned CPI =
I.getOperand(
op).getIndex();
837 if (
I.getOperand(
op).isJTI()) {
838 JumpTableUserIndices.
insert(std::make_pair(CPI, CPUsers.size()));
839 CPI = JumpTableEntryIndices[CPI];
843 unsigned MaxOffs = ((1 <<
Bits)-1) * Scale;
844 CPUsers.push_back(CPUser(&
I, CPEMI, MaxOffs, NegOk, IsSoImm));
847 CPEntry *CPE = findConstPoolEntry(CPI, CPEMI);
848 assert(CPE &&
"Cannot find a corresponding CPEntry!");
880 WaterList.insert(IP, NewBB);
890 LivePhysRegs LRs(*MF->getSubtarget().getRegisterInfo());
894 LRs.stepBackward(LiveMI);
900 MF->insert(MBBI, NewBB);
909 unsigned Opc = isThumb ? (isThumb2 ? ARM::t2B : ARM::tB) :
ARM::B;
933 MF->RenumberBlocks(NewBB);
945 if (WaterBB == OrigBB)
946 WaterList.
insert(std::next(IP), NewBB);
948 WaterList.insert(IP, OrigBB);
949 NewWaterList.
insert(OrigBB);
956 BBUtils->computeBlockSize(OrigBB);
960 BBUtils->computeBlockSize(NewBB);
963 BBUtils->adjustBBOffsetsAfter(OrigBB);
971 unsigned ARMConstantIslands::getUserOffset(CPUser &U)
const {
972 unsigned UserOffset = BBUtils->getOffsetOf(U.MI);
975 const BasicBlockInfo &BBI = BBInfo[U.MI->getParent()->getNumber()];
979 UserOffset += (isThumb ? 4 : 8);
983 U.KnownAlignment = (KnownBits >= 2);
988 if (isThumb && U.KnownAlignment)
1000 bool ARMConstantIslands::isOffsetInRange(
unsigned UserOffset,
1001 unsigned TrialOffset,
unsigned MaxDisp,
1002 bool NegativeOK,
bool IsSoImm) {
1003 if (UserOffset <= TrialOffset) {
1005 if (TrialOffset - UserOffset <= MaxDisp)
1008 }
else if (NegativeOK) {
1009 if (UserOffset - TrialOffset <= MaxDisp)
1020 bool ARMConstantIslands::isWaterInRange(
unsigned UserOffset,
1024 const Align CPEAlign = getCPEAlign(U.CPEMI);
1025 const unsigned CPEOffset = BBInfo[Water->
getNumber()].postOffset(CPEAlign);
1026 unsigned NextBlockOffset;
1027 Align NextBlockAlignment;
1029 if (++NextBlock == MF->end()) {
1030 NextBlockOffset = BBInfo[Water->
getNumber()].postOffset();
1032 NextBlockOffset = BBInfo[NextBlock->getNumber()].Offset;
1033 NextBlockAlignment = NextBlock->getAlignment();
1035 unsigned Size = U.CPEMI->getOperand(2).getImm();
1036 unsigned CPEEnd = CPEOffset +
Size;
1041 if (CPEEnd > NextBlockOffset) {
1042 Growth = CPEEnd - NextBlockOffset;
1050 if (CPEOffset < UserOffset)
1056 return isOffsetInRange(UserOffset, CPEOffset, U);
1061 bool ARMConstantIslands::isCPEntryInRange(
MachineInstr *MI,
unsigned UserOffset,
1063 bool NegOk,
bool DoDump) {
1064 unsigned CPEOffset = BBUtils->getOffsetOf(CPEMI);
1072 <<
" max delta=" << MaxDisp
1073 <<
format(
" insn address=%#x", UserOffset) <<
" in " 1076 <<
format(
"CPE address=%#x offset=%+d: ", CPEOffset,
1077 int(CPEOffset - UserOffset));
1081 return isOffsetInRange(UserOffset, CPEOffset, MaxDisp, NegOk);
1105 bool ARMConstantIslands::decrementCPEReferenceCount(
unsigned CPI,
1108 CPEntry *CPE = findConstPoolEntry(CPI, CPEMI);
1109 assert(CPE &&
"Unexpected!");
1110 if (--CPE->RefCount == 0) {
1111 removeDeadCPEMI(CPEMI);
1112 CPE->CPEMI =
nullptr;
1119 unsigned ARMConstantIslands::getCombinedIndex(
const MachineInstr *CPEMI) {
1132 int ARMConstantIslands::findInRangeCPEntry(CPUser& U,
unsigned UserOffset) {
1137 if (isCPEntryInRange(UserMI, UserOffset, CPEMI, U.getMaxDisp(), U.NegOk,
1144 unsigned CPI = getCombinedIndex(CPEMI);
1145 std::vector<CPEntry> &CPEs = CPEntries[CPI];
1146 for (
unsigned i = 0,
e = CPEs.size(); i !=
e; ++i) {
1148 if (CPEs[i].CPEMI == CPEMI)
1151 if (CPEs[i].CPEMI ==
nullptr)
1153 if (isCPEntryInRange(UserMI, UserOffset, CPEs[i].CPEMI, U.getMaxDisp(),
1156 << CPEs[i].CPI <<
"\n");
1158 U.CPEMI = CPEs[i].CPEMI;
1169 return decrementCPEReferenceCount(CPI, CPEMI) ? 2 : 1;
1180 return ((1<<10)-1)*2;
1182 return ((1<<23)-1)*2;
1187 return ((1<<23)-1)*4;
1198 bool ARMConstantIslands::findAvailableWater(CPUser &U,
unsigned UserOffset,
1199 water_iterator &WaterIter,
1201 if (WaterList.empty())
1204 unsigned BestGrowth = ~0u;
1217 const Align CPEAlign = getCPEAlign(U.CPEMI);
1218 unsigned MinNoSplitDisp = BBInfo[UserBB->
getNumber()].postOffset(CPEAlign);
1219 if (CloserWater && MinNoSplitDisp > U.getMaxDisp() / 2)
1221 for (water_iterator IP = std::prev(WaterList.end()),
B = WaterList.begin();;
1235 if (isWaterInRange(UserOffset, WaterBB, U, Growth) &&
1236 (WaterBB->
getNumber() < U.HighWaterMark->getNumber() ||
1237 NewWaterList.
count(WaterBB) || WaterBB == U.MI->getParent()) &&
1238 Growth < BestGrowth) {
1240 BestGrowth = Growth;
1243 <<
" Growth=" << Growth <<
'\n');
1245 if (CloserWater && WaterBB == U.MI->getParent())
1249 if (!CloserWater && BestGrowth == 0)
1255 return BestGrowth != ~0u;
1265 void ARMConstantIslands::createNewWater(
unsigned CPUserIndex,
1266 unsigned UserOffset,
1268 CPUser &U = CPUsers[CPUserIndex];
1271 const Align CPEAlign = getCPEAlign(CPEMI);
1282 unsigned Delta = isThumb1 ? 2 : 4;
1284 unsigned CPEOffset = UserBBI.
postOffset(CPEAlign) + Delta;
1286 if (isOffsetInRange(UserOffset, CPEOffset, U)) {
1288 <<
format(
", expected CPE offset %#x\n", CPEOffset));
1295 int UncondBr = isThumb ? ((isThumb2) ? ARM::t2B : ARM::tB) :
ARM::B;
1303 ImmBranches.push_back(ImmBranch(&UserMBB->
back(),
1304 MaxDisp,
false, UncondBr));
1305 BBUtils->computeBlockSize(UserMBB);
1306 BBUtils->adjustBBOffsetsAfter(UserMBB);
1326 const Align Align = MF->getAlignment();
1327 assert(Align >= CPEAlign &&
"Over-aligned constant pool entry");
1330 unsigned BaseInsertOffset = UserOffset + U.getMaxDisp() - UPad;
1337 BaseInsertOffset -= 4;
1340 <<
" la=" <<
Log2(Align) <<
" kb=" << KnownBits
1341 <<
" up=" << UPad <<
'\n');
1347 if (BaseInsertOffset + 8 >= UserBBI.
postOffset()) {
1369 I->getOpcode() != ARM::t2IT &&
1374 assert(I != UserMBB->
end() &&
"Fell off end of block");
1378 unsigned EndInsertOffset = BaseInsertOffset + 4 + UPad +
1382 unsigned CPUIndex = CPUserIndex+1;
1383 unsigned NumCPUsers = CPUsers.size();
1386 Offset < BaseInsertOffset;
1388 assert(MI != UserMBB->
end() &&
"Fell off end of block");
1389 if (CPUIndex < NumCPUsers && CPUsers[CPUIndex].MI == &*MI) {
1390 CPUser &U = CPUsers[CPUIndex];
1391 if (!isOffsetInRange(
Offset, EndInsertOffset, U)) {
1393 BaseInsertOffset -= Align.
value();
1394 EndInsertOffset -= Align.
value();
1400 EndInsertOffset += U.CPEMI->getOperand(2).getImm();
1405 if (MI->getOpcode() == ARM::t2IT)
1413 unsigned PredReg = 0;
1426 if (STI->isTargetWindows() && isThumb && MI->getOpcode() == ARM::t2MOVTi16 &&
1430 assert(MI->getOpcode() == ARM::t2MOVi16 &&
1440 NewMBB = splitBlockBeforeInstr(&*MI);
1447 bool ARMConstantIslands::handleConstantPoolUser(
unsigned CPUserIndex,
1449 CPUser &U = CPUsers[CPUserIndex];
1452 unsigned CPI = getCombinedIndex(CPEMI);
1455 unsigned UserOffset = getUserOffset(U);
1459 int result = findInRangeCPEntry(U, UserOffset);
1460 if (result==1)
return false;
1461 else if (result==2)
return true;
1471 if (findAvailableWater(U, UserOffset, IP, CloserWater)) {
1478 if (NewWaterList.
erase(WaterBB))
1479 NewWaterList.
insert(NewIsland);
1486 createNewWater(CPUserIndex, UserOffset, NewMBB);
1494 IP =
find(WaterList, WaterBB);
1495 if (IP != WaterList.end())
1496 NewWaterList.
erase(WaterBB);
1499 NewWaterList.
insert(NewIsland);
1504 const Align Alignment = isThumb ?
Align(2) :
Align(4);
1512 if (IP != WaterList.end())
1513 WaterList.erase(IP);
1519 updateForInsertedWaterBlock(NewIsland);
1523 U.HighWaterMark = NewIsland;
1528 CPEntries[CPI].push_back(CPEntry(U.CPEMI, ID, 1));
1532 decrementCPEReferenceCount(CPI, CPEMI);
1538 BBUtils->adjustBBSize(NewIsland, Size);
1539 BBUtils->adjustBBOffsetsAfter(&*--NewIsland->
getIterator());
1549 dbgs() <<
" Moved CPE to #" << ID <<
" CPI=" << CPI
1550 <<
format(
" offset=%#x\n",
1551 BBUtils->getBBInfo()[NewIsland->
getNumber()].Offset));
1558 void ARMConstantIslands::removeDeadCPEMI(
MachineInstr *CPEMI) {
1563 BBUtils->adjustBBSize(CPEBB, -Size);
1565 if (CPEBB->
empty()) {
1575 BBUtils->adjustBBOffsetsAfter(CPEBB);
1585 bool ARMConstantIslands::removeUnusedCPEntries() {
1586 unsigned MadeChange =
false;
1587 for (
unsigned i = 0,
e = CPEntries.size(); i !=
e; ++i) {
1588 std::vector<CPEntry> &CPEs = CPEntries[i];
1589 for (
unsigned j = 0, ee = CPEs.size(); j != ee; ++j) {
1590 if (CPEs[j].RefCount == 0 && CPEs[j].CPEMI) {
1591 removeDeadCPEMI(CPEs[j].CPEMI);
1592 CPEs[j].CPEMI =
nullptr;
1603 bool ARMConstantIslands::fixupImmediateBr(ImmBranch &Br) {
1608 if (BBUtils->isBBInRange(MI, DestBB, Br.MaxDisp))
1612 return fixupUnconditionalBr(Br);
1613 return fixupConditionalBr(Br);
1621 ARMConstantIslands::fixupUnconditionalBr(ImmBranch &Br) {
1631 Br.MaxDisp = (1 << 21) * 2;
1632 MI->
setDesc(TII->get(ARM::tBfar));
1635 BBUtils->adjustBBOffsetsAfter(MBB);
1648 ARMConstantIslands::fixupConditionalBr(ImmBranch &Br) {
1682 if (BBUtils->isBBInRange(MI, NewDest, Br.MaxDisp)) {
1684 dbgs() <<
" Invert Bcc condition and swap its destination with " 1695 splitBlockBeforeInstr(MI);
1699 BBUtils->adjustBBSize(MBB, -delta);
1705 std::next(MBB->
getIterator())->removeSuccessor(DestBB);
1712 <<
" also invert condition and change dest. to " 1719 Br.MI = &MBB->
back();
1729 ImmBranches.push_back(ImmBranch(&MBB->
back(), MaxDisp,
false, Br.UncondBr));
1734 BBUtils->adjustBBOffsetsAfter(MBB);
1741 bool ARMConstantIslands::undoLRSpillRestore() {
1742 bool MadeChange =
false;
1743 for (
unsigned i = 0,
e = PushPopMIs.
size(); i !=
e; ++i) {
1755 }
else if (MI->
getOpcode() == ARM::tPUSH &&
1766 bool ARMConstantIslands::optimizeThumb2Instructions() {
1767 bool MadeChange =
false;
1770 for (
unsigned i = 0,
e = CPUsers.size(); i !=
e; ++i) {
1771 CPUser &U = CPUsers[i];
1772 unsigned Opcode = U.MI->getOpcode();
1773 unsigned NewOpc = 0;
1778 case ARM::t2LEApcrel:
1780 NewOpc = ARM::tLEApcrel;
1787 NewOpc = ARM::tLDRpci;
1797 unsigned UserOffset = getUserOffset(U);
1798 unsigned MaxOffs = ((1 <<
Bits) - 1) * Scale;
1801 if (!U.KnownAlignment)
1805 if (isCPEntryInRange(U.MI, UserOffset, U.CPEMI, MaxOffs,
false,
true)) {
1807 U.MI->setDesc(TII->get(NewOpc));
1809 BBUtils->adjustBBSize(MBB, -2);
1810 BBUtils->adjustBBOffsetsAfter(MBB);
1820 bool ARMConstantIslands::optimizeThumb2Branches() {
1822 auto TryShrinkBranch = [
this](ImmBranch &Br) {
1823 unsigned Opcode = Br.MI->getOpcode();
1824 unsigned NewOpc = 0;
1841 unsigned MaxOffs = ((1 << (Bits-1))-1) * Scale;
1843 if (BBUtils->isBBInRange(Br.MI, DestBB, MaxOffs)) {
1845 Br.MI->setDesc(TII->get(NewOpc));
1847 BBUtils->adjustBBSize(MBB, -2);
1848 BBUtils->adjustBBOffsetsAfter(MBB);
1858 unsigned NewOpc = 0;
1861 auto FindCmpForCBZ = [
this](ImmBranch &Br, ImmCompare &ImmCmp,
1863 ImmCmp.MI =
nullptr;
1868 if (!Br.MI->killsRegister(ARM::CPSR))
1871 unsigned PredReg = 0;
1872 unsigned NewOpc = 0;
1877 NewOpc = ARM::tCBNZ;
1883 unsigned BrOffset = BBUtils->getOffsetOf(Br.MI) + 4 - 2;
1885 unsigned DestOffset = BBInfo[DestBB->getNumber()].Offset;
1886 if (BrOffset >= DestOffset || (DestOffset - BrOffset) > 126)
1890 auto *
TRI = STI->getRegisterInfo();
1892 if (!CmpMI || CmpMI->
getOpcode() != ARM::tCMPi8)
1896 ImmCmp.NewOpc = NewOpc;
1900 auto TryConvertToLE = [
this](ImmBranch &Br, ImmCompare &Cmp) {
1901 if (Br.MI->getOpcode() != ARM::t2Bcc || !STI->hasLOB() ||
1907 if (BBUtils->getOffsetOf(MBB) < BBUtils->getOffsetOf(DestBB) ||
1908 !BBUtils->isBBInRange(Br.MI, DestBB, 4094))
1911 if (!DT->dominates(DestBB, MBB))
1916 Cmp.NewOpc = Cmp.NewOpc == ARM::tCBZ ? ARM::tCBNZ : ARM::tCBZ;
1919 TII->get(ARM::t2LE));
1921 MIB.
add(Br.MI->getOperand(0));
1922 Br.MI->eraseFromParent();
1928 bool MadeChange =
false;
1935 for (ImmBranch &Br :
reverse(ImmBranches)) {
1943 if (FindCmpForCBZ(Br, Cmp, ExitBB) && TryConvertToLE(Br, Cmp)) {
1947 FindCmpForCBZ(Br, Cmp, DestBB);
1948 MadeChange |= TryShrinkBranch(Br);
1951 unsigned Opcode = Br.MI->getOpcode();
1952 if ((Opcode != ARM::tBcc && Opcode != ARM::t2LE) || !Cmp.NewOpc)
1959 auto *
TRI = STI->getRegisterInfo();
1961 bool RegKilled =
false;
1964 if (KillMI->killsRegister(Reg,
TRI)) {
1965 KillMI->clearRegisterKills(Reg,
TRI);
1969 }
while (KillMI != Cmp.MI);
1974 BuildMI(*MBB, Br.MI, Br.MI->getDebugLoc(), TII->get(Cmp.NewOpc))
1976 .addMBB(DestBB, Br.MI->getOperand(0).getTargetFlags());
1978 Cmp.MI->eraseFromParent();
1980 if (Br.MI->getOpcode() == ARM::tBcc) {
1981 Br.MI->eraseFromParent();
1983 BBUtils->adjustBBSize(MBB, -2);
1994 BBUtils->adjustBBOffsetsAfter(MBB);
2023 bool ARMConstantIslands::preserveBaseRegister(
MachineInstr *JumpMI,
2027 bool &BaseRegKill) {
2050 CanDeleteLEA =
true;
2051 BaseRegKill =
false;
2054 for (++I; &*I != JumpMI; ++
I) {
2060 for (
unsigned K = 0,
E = I->getNumOperands(); K !=
E; ++K) {
2067 BaseRegKill = BaseRegKill || MO.
isKill();
2068 CanDeleteLEA =
false;
2078 for (++I; &*I != JumpMI; ++
I) {
2079 for (
unsigned K = 0,
E = I->getNumOperands(); K !=
E; ++K) {
2086 RemovableAdd =
nullptr;
2092 DeadSize += isThumb2 ? 4 : 2;
2093 }
else if (BaseReg == EntryReg) {
2114 return MBB != MF->
end() && MBB->begin() != MBB->end() &&
2115 &*MBB->begin() == CPEMI;
2120 unsigned &DeadSize) {
2129 for (++I; &*I != JumpMI; ++
I) {
2130 if (I->getOpcode() == ARM::t2ADDrs && I->getOperand(0).getReg() == EntryReg)
2139 for (++J; &*J != JumpMI; ++J) {
2140 for (
unsigned K = 0,
E = J->getNumOperands(); K !=
E; ++K) {
2158 bool ARMConstantIslands::optimizeThumb2JumpTables() {
2159 bool MadeChange =
false;
2164 if (!MJTI)
return false;
2166 const std::vector<MachineJumpTableEntry> &JT = MJTI->
getJumpTables();
2167 for (
unsigned i = 0,
e = T2JumpTables.
size(); i !=
e; ++i) {
2171 unsigned JTOpIdx = NumOps - (MI->
isPredicable() ? 2 : 1);
2173 unsigned JTI = JTOP.getIndex();
2177 bool HalfWordOk =
true;
2178 unsigned JTOffset = BBUtils->getOffsetOf(MI) + 4;
2179 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
2181 for (
unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) {
2183 unsigned DstOffset = BBInfo[MBB->
getNumber()].Offset;
2186 if (ByteOk && (DstOffset - JTOffset) > ((1<<8)-1)*2)
2188 unsigned TBHLimit = ((1<<16)-1)*2;
2189 if (HalfWordOk && (DstOffset - JTOffset) > TBHLimit)
2191 if (!ByteOk && !HalfWordOk)
2195 if (!ByteOk && !HalfWordOk)
2198 CPUser &
User = CPUsers[JumpTableUserIndices[JTI]];
2203 unsigned DeadSize = 0;
2204 bool CanDeleteLEA =
false;
2205 bool BaseRegKill =
false;
2207 unsigned IdxReg = ~0U;
2208 bool IdxRegKill =
true;
2213 bool PreservedBaseReg =
2214 preserveBaseRegister(MI, User.MI, DeadSize, CanDeleteLEA, BaseRegKill);
2222 Register BaseReg = User.MI->getOperand(0).getReg();
2224 if (User.MI->getIterator() == User.MI->getParent()->begin())
2227 if (Shift->
getOpcode() != ARM::tLSLri ||
2249 auto *
TRI = STI->getRegisterInfo();
2259 if (isPositionIndependentOrROPI) {
2282 CanDeleteLEA =
true;
2290 unsigned Opc = ByteOk ? ARM::t2TBB_JT : ARM::t2TBH_JT;
2292 Opc = ByteOk ? ARM::tTBB_JT : ARM::tTBH_JT;
2297 .addReg(User.MI->getOperand(0).getReg(),
2300 .addJumpTableIndex(JTI, JTOP.getTargetFlags())
2304 unsigned JTOpc = ByteOk ? ARM::JUMPTABLE_TBB : ARM::JUMPTABLE_TBH;
2305 CPEMI->
setDesc(TII->get(JTOpc));
2315 User.MI->eraseFromParent();
2316 DeadSize += isThumb2 ? 4 : 2;
2323 User.IsSoImm =
false;
2324 User.KnownAlignment =
false;
2328 int CPEntryIdx = JumpTableEntryIndices[JTI];
2329 auto &CPEs = CPEntries[CPEntryIdx];
2331 find_if(CPEs, [&](CPEntry &
E) {
return E.CPEMI == User.CPEMI; });
2333 CPUsers.emplace_back(CPUser(NewJTMI, User.CPEMI, 4,
false,
false));
2341 int Delta = OrigSize - NewSize + DeadSize;
2343 BBUtils->adjustBBOffsetsAfter(MBB);
2354 bool ARMConstantIslands::reorderThumb2JumpTables() {
2355 bool MadeChange =
false;
2358 if (!MJTI)
return false;
2360 const std::vector<MachineJumpTableEntry> &JT = MJTI->
getJumpTables();
2361 for (
unsigned i = 0,
e = T2JumpTables.
size(); i !=
e; ++i) {
2365 unsigned JTOpIdx = NumOps - (MI->
isPredicable() ? 2 : 1);
2367 unsigned JTI = JTOP.getIndex();
2374 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
2375 for (
unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) {
2379 if (DTNumber < JTNumber) {
2383 adjustJTTargetBlockForward(MBB, MI->
getParent());
2412 if (!B && Cond.
empty() && BB != &MF->
front() &&
2415 OldPrior->updateTerminator();
2418 MF->RenumberBlocks();
2427 MF->insert(MBBI, NewBB);
2446 MF->RenumberBlocks(NewBB);
2459 return new ARMConstantIslands();
auto lower_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
unsigned Log2(Align A)
Returns the log2 of the alignment.
const MachineInstrBuilder & add(const MachineOperand &MO) const
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
const std::vector< MachineJumpTableEntry > & getJumpTables() const
bool isReserved(Register PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
unsigned postOffset(Align Alignment=Align::None()) const
Compute the offset immediately following this block.
MachineBasicBlock * getMBB() const
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
bool isEmpty() const
isEmpty - Return true if this constant pool contains no constants.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them...
void push_back(const T &Elt)
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.
void transferSuccessors(MachineBasicBlock *FromMBB)
Transfers all the successors from MBB to this machine basic block (i.e., copies all the successors Fr...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
const MachineInstrBuilder & addJumpTableIndex(unsigned Idx, unsigned TargetFlags=0) const
bool isPredicable(QueryType Type=AllInBundle) const
Return true if this instruction has a predicate operand that controls execution.
unsigned Offset
Offset - Distance from the beginning of the function to the beginning of this basic block...
STATISTIC(NumFunctions, "Total number of functions")
void moveAfter(MachineBasicBlock *NewBefore)
unsigned const TargetRegisterInfo * TRI
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
void dump() const
dump - Print the current MachineFunction to cerr, useful for debugger use.
uint64_t offsetToAlignment(uint64_t Value, Align Alignment)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
unsigned createPICLabelUId()
static bool isThumb(const MCSubtargetInfo &STI)
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
bool ReplaceMBBInJumpTable(unsigned Idx, MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTable - If Old is a target of the jump tables, update the jump table to branch to New...
BasicBlockInfo - Information about the offset and size of a single basic block.
bool registerDefinedBetween(unsigned Reg, MachineBasicBlock::iterator From, MachineBasicBlock::iterator To, const TargetRegisterInfo *TRI)
Return true if Reg is defd between From and To.
static bool CompareMBBNumbers(const MachineBasicBlock *LHS, const MachineBasicBlock *RHS)
CompareMBBNumbers - Little predicate function to sort the WaterList by MBB ID.
static bool isSimpleIndexCalc(MachineInstr &I, unsigned EntryReg, unsigned BaseReg)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
AnalysisUsage & addRequired()
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
const HexagonInstrInfo * TII
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
unsigned getNumOperands() const
Retuns the total number of operands.
unsigned UnknownPadding(Align Alignment, unsigned KnownBits)
UnknownPadding - Return the worst case padding that could result from unknown offset bits...
MachineBasicBlock * getFallThrough()
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
#define ARM_CP_ISLANDS_OPT_NAME
Align getAlignment() const
Return alignment of the basic block.
const MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned TargetFlags=0) const
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
FunctionPass * createARMConstantIslandPass()
createARMConstantIslandPass - returns an instance of the constpool island pass.
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.
static cl::opt< bool > SynthesizeThumb1TBB("arm-synthesize-thumb-1-tbb", cl::Hidden, cl::init(true), cl::desc("Use compressed jump tables in Thumb-1 by synthesizing an " "equivalent to the TBB/TBH instructions"))
bool isLRSpilledForFarJump() const
reverse_iterator getReverse() const
Get a reverse iterator to the same node.
bool isThumb2Function() const
void setReg(Register Reg)
Change the register this operand corresponds to.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
uint64_t value() const
This is a hole in the type system and should not be abused.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
reverse_iterator rbegin()
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
unsigned getKillRegState(bool B)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
initializer< Ty > init(const Ty &Val)
MachineInstrBundleIterator< MachineInstr > iterator
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned getConstantPoolAlignment() const
getConstantPoolAlignment - Return the alignment required by the whole constant pool, of which the first element must be aligned.
unsigned const MachineRegisterInfo * MRI
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
void ensureAlignment(Align A)
ensureAlignment - Make sure the function is at least A bytes aligned.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void addLiveOuts(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Returns the size of the specified MachineInstr.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
void setMBB(MachineBasicBlock *MBB)
Represent the analysis usage information of a pass.
static bool BBIsJumpedOver(MachineBasicBlock *MBB)
BBIsJumpedOver - Return true of the specified basic block's only predecessor unconditionally branches...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
void initPICLabelUId(unsigned UId)
FunctionPass class - This class is used to implement most global optimizations.
self_iterator getIterator()
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
unsigned internalKnownBits() const
Compute the number of known offset bits internally to this block.
bool isThumb1OnlyFunction() const
MachineInstr * findCMPToFoldIntoCBZ(MachineInstr *Br, const TargetRegisterInfo *TRI)
Search backwards from a tBcc to find a tCMPi8 against 0, meaning we can convert them to a tCBZ or tCB...
succ_iterator succ_begin()
Align PostAlign
PostAlign - When > 1, the block terminator contains a .align directive, so the end of the block is al...
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
ARMCC::CondCodes getInstrPredicate(const MachineInstr &MI, unsigned &PredReg)
getInstrPredicate - If instruction is predicated, returns its predicate condition, otherwise returns AL.
pred_iterator pred_begin()
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
static wasm::ValType getType(const TargetRegisterClass *RC)
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
MO_LO16 - On a symbol operand, this represents a relocation containing lower 16 bit of the address...
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
This struct is a compact representation of a valid (non-zero power of two) alignment.
void setIsKill(bool Val=true)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
const std::vector< MachineConstantPoolEntry > & getConstants() const
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Iterator for intrusive lists based on ilist_node.
void setAlignment(Align A)
Set alignment of the basic block.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
Align max(MaybeAlign Lhs, Align Rhs)
ARMCC::CondCodes getITInstrPredicate(const MachineInstr &MI, unsigned &PredReg)
getITInstrPredicate - Valid only in Thumb2 mode.
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
MachineOperand class - Representation of each machine instruction operand.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
void updateTerminator()
Update the terminator instructions in block to account for changes to the layout. ...
APFloat neg(APFloat X)
Returns the negated value of the argument.
static cl::opt< bool > AdjustJumpTableBlocks("arm-adjust-jump-tables", cl::Hidden, cl::init(true), cl::desc("Adjust basic block layout to better use TB[BH]"))
unsigned pred_size() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New)
Replace successor OLD with NEW and update probability info.
unsigned succ_size() const
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
MachineFunctionProperties & set(Property P)
void recordCPEClone(unsigned CPIdx, unsigned CPCloneIdx)
static bool isARMLowRegister(unsigned Reg)
isARMLowRegister - Returns true if the register is a low register (r0-r7).
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static CondCodes getOppositeCondition(CondCodes CC)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
uint8_t Unalign
Unalign - When non-zero, the block contains instructions (inline asm) of unknown size.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
A set of physical registers with utility functions to track liveness when walking backward/forward th...
LLVM_NODISCARD bool empty() const
static bool BBHasFallthrough(MachineBasicBlock *MBB)
BBHasFallthrough - Return true if the specified basic block can fallthrough into the block immediatel...
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
Pair of physical register and lane mask.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
MO_OPTION_MASK - Most flags are mutually exclusive; this mask selects just that part of the flag set...
uint8_t KnownBits
KnownBits - The number of low bits in Offset that are known to be exact.
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
static unsigned getUnconditionalBrDisp(int Opc)
getUnconditionalBrDisp - Returns the maximum displacement that can fit in the specific unconditional ...
iterator_range< livein_iterator > liveins() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
static cl::opt< unsigned > CPMaxIteration("arm-constant-island-max-iteration", cl::Hidden, cl::init(30), cl::desc("The max number of iteration for converge"))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool jumpTableFollowsTB(MachineInstr *JTMI, MachineInstr *CPEMI)
Returns whether CPEMI is the first instruction in the block immediately following JTMI (assumed to be...
void push_back(MachineBasicBlock *MBB)
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
StringRef - Represent a constant reference to a string, i.e.
Register getReg() const
getReg - Returns the register number.
static void RemoveDeadAddBetweenLEAAndJT(MachineInstr *LEAMI, MachineInstr *JumpMI, unsigned &DeadSize)
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const MachineOperand & getOperand(unsigned i) const
bool isThumbFunction() const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
MO_HI16 - On a symbol operand, this represents a relocation containing higher 16 bit of the address...
Properties which a MachineFunction may have at a given point in time.
Wrapper class representing virtual and physical registers.
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.