Lines Matching refs:MBB

213   int getSCCNum(MachineBasicBlock *MBB) const;
215 bool hasBackEdge(MachineBasicBlock *MBB) const;
217 bool isRetiredBlock(MachineBasicBlock *MBB) const;
218 bool isActiveLoophead(MachineBasicBlock *MBB) const;
223 bool needMigrateBlock(MachineBasicBlock *MBB) const;
231 void insertInstrEnd(MachineBasicBlock *MBB, int NewOpcode,
233 MachineInstr *insertInstrBefore(MachineBasicBlock *MBB, int NewOpcode,
238 void insertCondBranchBefore(MachineBasicBlock *MBB,
241 void insertCondBranchEnd(MachineBasicBlock *MBB, int NewOpcode, int RegNum);
247 static void setTrueBranch(MachineInstr *MI, MachineBasicBlock *MBB);
248 static MachineBasicBlock *getFalseBranch(MachineBasicBlock *MBB,
252 static DebugLoc getLastDebugLocInBB(MachineBasicBlock *MBB);
253 static MachineInstr *getNormalBlockBranchInstr(MachineBasicBlock *MBB);
258 MachineInstr *getLoopendBlockBranchInstr(MachineBasicBlock *MBB);
259 static MachineInstr *getReturnInstr(MachineBasicBlock *MBB);
260 static MachineInstr *getContinueInstr(MachineBasicBlock *MBB);
261 static bool isReturnBlock(MachineBasicBlock *MBB);
264 static MachineBasicBlock *clone(MachineBasicBlock *MBB);
270 static void wrapup(MachineBasicBlock *MBB);
273 int patternMatch(MachineBasicBlock *MBB);
274 int patternMatchGroup(MachineBasicBlock *MBB);
275 int serialPatternMatch(MachineBasicBlock *MBB);
276 int ifPatternMatch(MachineBasicBlock *MBB);
305 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB,
322 void removeUnconditionalBranch(MachineBasicBlock *MBB);
331 void removeRedundantConditionalBranch(MachineBasicBlock *MBB);
333 void removeSuccessor(MachineBasicBlock *MBB);
334 MachineBasicBlock *cloneBlockForPredecessor(MachineBasicBlock *MBB,
338 void recordSccnum(MachineBasicBlock *MBB, int SCCNum);
339 void retireBlock(MachineBasicBlock *MBB);
340 void setLoopLandBlock(MachineLoop *LoopRep, MachineBasicBlock *MBB = nullptr);
356 int AMDGPUCFGStructurizer::getSCCNum(MachineBasicBlock *MBB) const {
357 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB);
371 bool AMDGPUCFGStructurizer::hasBackEdge(MachineBasicBlock *MBB) const {
372 MachineLoop *LoopRep = MLI->getLoopFor(MBB);
376 return MBB->isSuccessor(LoopHeader);
383 bool AMDGPUCFGStructurizer::isRetiredBlock(MachineBasicBlock *MBB) const {
384 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB);
390 bool AMDGPUCFGStructurizer::isActiveLoophead(MachineBasicBlock *MBB) const {
391 MachineLoop *LoopRep = MLI->getLoopFor(MBB);
392 while (LoopRep && LoopRep->getHeader() == MBB) {
431 bool AMDGPUCFGStructurizer::needMigrateBlock(MachineBasicBlock *MBB) const {
434 bool MultiplePreds = MBB && (MBB->pred_size() > 1);
438 unsigned BlkSize = MBB->size();
440 (BlkSize * (MBB->pred_size() - 1) > CloneInstrThreshold));
471 void AMDGPUCFGStructurizer::insertInstrEnd(MachineBasicBlock *MBB,
473 MachineInstr *MI = MBB->getParent()
475 MBB->push_back(MI);
480 MachineInstr *AMDGPUCFGStructurizer::insertInstrBefore(MachineBasicBlock *MBB,
483 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DL);
484 if (MBB->begin() != MBB->end())
485 MBB->insert(MBB->begin(), MI);
487 MBB->push_back(MI);
495 MachineBasicBlock *MBB = OldMI->getParent();
497 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DebugLoc());
498 MBB->insert(I, NewMBB);
507 MachineBasicBlock *MBB = OldMI->getParent();
508 MachineFunction *MF = MBB->getParent();
510 MBB->insert(I, NewMI);
528 void AMDGPUCFGStructurizer::insertCondBranchEnd(MachineBasicBlock *MBB,
530 MachineFunction *MF = MBB->getParent();
533 MBB->push_back(NewInstr);
583 MachineBasicBlock *MBB) {
584 MI->getOperand(0).setMBB(MBB);
588 AMDGPUCFGStructurizer::getFalseBranch(MachineBasicBlock *MBB,
590 assert(MBB->succ_size() == 2);
592 MachineBasicBlock::succ_iterator It = MBB->succ_begin();
620 DebugLoc AMDGPUCFGStructurizer::getLastDebugLocInBB(MachineBasicBlock *MBB) {
623 for (MachineBasicBlock::iterator It = MBB->begin(); It != MBB->end();
633 MachineBasicBlock *MBB) {
634 MachineBasicBlock::reverse_iterator It = MBB->rbegin();
642 MachineBasicBlock *MBB) {
643 for (MachineBasicBlock::reverse_iterator It = MBB->rbegin(), E = MBB->rend();
657 MachineInstr *AMDGPUCFGStructurizer::getReturnInstr(MachineBasicBlock *MBB) {
658 MachineBasicBlock::reverse_iterator It = MBB->rbegin();
659 if (It != MBB->rend()) {
667 MachineInstr *AMDGPUCFGStructurizer::getContinueInstr(MachineBasicBlock *MBB) {
668 MachineBasicBlock::reverse_iterator It = MBB->rbegin();
669 if (It != MBB->rend()) {
677 bool AMDGPUCFGStructurizer::isReturnBlock(MachineBasicBlock *MBB) {
678 MachineInstr *MI = getReturnInstr(MBB);
679 bool IsReturn = (MBB->succ_size() == 0);
684 dbgs() << "BB" << MBB->getNumber()
696 MachineBasicBlock *AMDGPUCFGStructurizer::clone(MachineBasicBlock *MBB) {
697 MachineFunction *Func = MBB->getParent();
700 for (MachineBasicBlock::iterator It = MBB->begin(), E = MBB->end();
717 void AMDGPUCFGStructurizer::wrapup(MachineBasicBlock *MBB) {
718 assert((!MBB->getParent()->getJumpTableInfo()
719 || MBB->getParent()->getJumpTableInfo()->isEmpty())
724 MachineBasicBlock::iterator Pre = MBB->begin();
725 MachineBasicBlock::iterator E = MBB->end();
776 MachineBasicBlock *MBB = *It;
777 removeUnconditionalBranch(MBB);
778 removeRedundantConditionalBranch(MBB);
779 if (isReturnBlock(MBB)) {
780 RetBlks.push_back(MBB);
782 assert(MBB->succ_size() <= 2);
806 MachineBasicBlock *MBB;
831 MBB = *It;
835 SccBeginMBB = MBB;
844 if (!isRetiredBlock(MBB))
845 patternMatch(MBB);
857 dbgs() << "Can't reduce SCC " << getSCCNum(MBB)
867 dbgs() << "repeat processing SCC" << getSCCNum(MBB)
936 MachineBasicBlock *MBB;
943 MBB = *blockIter;
944 OrderedBlks.push_back(MBB);
945 recordSccnum(MBB, SccNum);
953 MachineBasicBlock *MBB = &(*It);
954 SccNum = getSCCNum(MBB);
956 dbgs() << "unreachable block BB" << MBB->getNumber() << "\n";
960 int AMDGPUCFGStructurizer::patternMatch(MachineBasicBlock *MBB) {
965 dbgs() << "Begin patternMatch BB" << MBB->getNumber() << "\n";
968 while ((CurMatch = patternMatchGroup(MBB)) > 0)
972 dbgs() << "End patternMatch BB" << MBB->getNumber()
979 int AMDGPUCFGStructurizer::patternMatchGroup(MachineBasicBlock *MBB) {
982 NumMatch += serialPatternMatch(MBB);
983 NumMatch += ifPatternMatch(MBB);
988 int AMDGPUCFGStructurizer::serialPatternMatch(MachineBasicBlock *MBB) {
989 if (MBB->succ_size() != 1)
992 MachineBasicBlock *childBlk = *MBB->succ_begin();
996 mergeSerialBlock(MBB, childBlk);
1001 int AMDGPUCFGStructurizer::ifPatternMatch(MachineBasicBlock *MBB) {
1003 if (MBB->succ_size() != 2)
1005 if (hasBackEdge(MBB))
1007 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB);
1017 MachineBasicBlock *FalseMBB = getFalseBranch(MBB, BranchMI);
1038 reversePredicateSetter(MBB->end());
1048 return NumMatch + handleJumpintoIf(MBB, TrueMBB, FalseMBB);
1057 Cloned += improveSimpleJumpintoIf(MBB, TrueMBB, FalseMBB, &LandBlk);
1061 TrueMBB = cloneBlockForPredecessor(TrueMBB, MBB);
1066 FalseMBB = cloneBlockForPredecessor(FalseMBB, MBB);
1070 mergeIfthenelseBlock(BranchMI, MBB, TrueMBB, FalseMBB, LandBlk);
1156 MachineBasicBlock *MBB = *It;
1157 if (LoopRep->contains(MBB)) {
1158 handleLoopcontBlock(MBB, MLI->getLoopFor(MBB),
1160 ContMBB.push_back(MBB);
1455 MachineBasicBlock *MBB = *PI;
1456 if (MBB != TrueMBB && MBB != FalseMBB)
1499 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB,
1503 dbgs() << "ifPattern BB" << MBB->getNumber();
1539 MBB->splice(I, TrueMBB, TrueMBB->begin(), TrueMBB->end());
1540 MBB->removeSuccessor(TrueMBB, true);
1549 MBB->splice(I, FalseMBB, FalseMBB->begin(),
1551 MBB->removeSuccessor(FalseMBB, true);
1562 MBB->addSuccessor(LandMBB);
1659 AMDGPUCFGStructurizer::cloneBlockForPredecessor(MachineBasicBlock *MBB,
1661 assert(PredMBB->isSuccessor(MBB) &&
1664 MachineBasicBlock *CloneMBB = clone(MBB); //clone instructions
1665 replaceInstrUseOfBlockWith(PredMBB, MBB, CloneMBB);
1668 PredMBB->replaceSuccessor(MBB, CloneMBB);
1671 cloneSuccessorList(CloneMBB, MBB);
1673 numClonedInstr += MBB->size();
1677 << MBB->getNumber() << "size " << MBB->size() << "\n";
1734 void AMDGPUCFGStructurizer::removeUnconditionalBranch(MachineBasicBlock *MBB) {
1739 while ((BranchMI = getLoopendBlockBranchInstr(MBB))
1747 MachineBasicBlock *MBB) {
1748 if (MBB->succ_size() != 2)
1750 MachineBasicBlock *MBB1 = *MBB->succ_begin();
1751 MachineBasicBlock *MBB2 = *std::next(MBB->succ_begin());
1755 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB);
1760 MBB->removeSuccessor(MBB1, true);
1771 MachineBasicBlock *MBB = *It;
1772 MachineInstr *MI = getReturnInstr(MBB);
1775 MBB->addSuccessor(DummyExitBlk);
1777 dbgs() << "Add dummyExitBlock to BB" << MBB->getNumber()
1784 void AMDGPUCFGStructurizer::removeSuccessor(MachineBasicBlock *MBB) {
1785 while (MBB->succ_size())
1786 MBB->removeSuccessor(*MBB->succ_begin());
1789 void AMDGPUCFGStructurizer::recordSccnum(MachineBasicBlock *MBB,
1791 BlockInformation *&srcBlkInfo = BlockInfoMap[MBB];
1797 void AMDGPUCFGStructurizer::retireBlock(MachineBasicBlock *MBB) {
1799 dbgs() << "Retiring BB" << MBB->getNumber() << "\n";
1802 BlockInformation *&SrcBlkInfo = BlockInfoMap[MBB];
1808 assert(MBB->succ_size() == 0 && MBB->pred_size() == 0
1813 MachineBasicBlock *MBB) {
1815 if (!MBB) {
1816 MBB = FuncRep->CreateMachineBasicBlock();
1817 FuncRep->push_back(MBB); //insert to function
1818 SHOWNEWBLK(MBB, "DummyLandingBlock for loop without break: ");
1820 TheEntry = MBB;
1824 << " landing-block = BB" << MBB->getNumber() << "\n";
1866 MachineBasicBlock *MBB = *It;
1867 if (MBB != CommonDom)
1868 CommonDom = findNearestCommonPostDom(MBB, CommonDom);