Lines Matching refs:MBB
179 int getSCCNum(MachineBasicBlock *MBB) const;
181 bool hasBackEdge(MachineBasicBlock *MBB) const;
182 bool isRetiredBlock(MachineBasicBlock *MBB) const;
183 bool isActiveLoophead(MachineBasicBlock *MBB) const;
188 bool needMigrateBlock(MachineBasicBlock *MBB) const;
192 MachineBasicBlock &MBB);
197 void insertInstrEnd(MachineBasicBlock *MBB, int NewOpcode,
199 MachineInstr *insertInstrBefore(MachineBasicBlock *MBB, int NewOpcode,
204 void insertCondBranchBefore(MachineBasicBlock *MBB,
213 static void setTrueBranch(MachineInstr *MI, MachineBasicBlock *MBB);
214 static MachineBasicBlock *getFalseBranch(MachineBasicBlock *MBB,
218 static DebugLoc getLastDebugLocInBB(MachineBasicBlock *MBB);
219 static MachineInstr *getNormalBlockBranchInstr(MachineBasicBlock *MBB);
225 MachineInstr *getLoopendBlockBranchInstr(MachineBasicBlock *MBB);
227 static MachineInstr *getReturnInstr(MachineBasicBlock *MBB);
228 static bool isReturnBlock(MachineBasicBlock *MBB);
231 static MachineBasicBlock *clone(MachineBasicBlock *MBB);
239 static void wrapup(MachineBasicBlock *MBB);
241 int patternMatch(MachineBasicBlock *MBB);
242 int patternMatchGroup(MachineBasicBlock *MBB);
243 int serialPatternMatch(MachineBasicBlock *MBB);
244 int ifPatternMatch(MachineBasicBlock *MBB);
269 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB,
287 void removeUnconditionalBranch(MachineBasicBlock *MBB);
297 void removeRedundantConditionalBranch(MachineBasicBlock *MBB);
300 void removeSuccessor(MachineBasicBlock *MBB);
301 MachineBasicBlock *cloneBlockForPredecessor(MachineBasicBlock *MBB,
305 void recordSccnum(MachineBasicBlock *MBB, int SCCNum);
306 void retireBlock(MachineBasicBlock *MBB);
320 int AMDGPUCFGStructurizer::getSCCNum(MachineBasicBlock *MBB) const { in getSCCNum()
321 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB); in getSCCNum()
335 bool AMDGPUCFGStructurizer::hasBackEdge(MachineBasicBlock *MBB) const { in hasBackEdge()
336 MachineLoop *LoopRep = MLI->getLoopFor(MBB); in hasBackEdge()
340 return MBB->isSuccessor(LoopHeader); in hasBackEdge()
343 bool AMDGPUCFGStructurizer::isRetiredBlock(MachineBasicBlock *MBB) const { in isRetiredBlock()
344 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB); in isRetiredBlock()
350 bool AMDGPUCFGStructurizer::isActiveLoophead(MachineBasicBlock *MBB) const { in isActiveLoophead()
351 MachineLoop *LoopRep = MLI->getLoopFor(MBB); in isActiveLoophead()
352 while (LoopRep && LoopRep->getHeader() == MBB) { in isActiveLoophead()
392 bool AMDGPUCFGStructurizer::needMigrateBlock(MachineBasicBlock *MBB) const { in needMigrateBlock()
395 bool MultiplePreds = MBB && (MBB->pred_size() > 1); in needMigrateBlock()
399 unsigned BlkSize = MBB->size(); in needMigrateBlock()
401 (BlkSize * (MBB->pred_size() - 1) > CloneInstrThreshold)); in needMigrateBlock()
405 MachineBasicBlock::iterator I, MachineBasicBlock &MBB) { in reversePredicateSetter() argument
408 if (I == MBB.end()) in reversePredicateSetter()
431 void AMDGPUCFGStructurizer::insertInstrEnd(MachineBasicBlock *MBB, in insertInstrEnd() argument
434 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DL); in insertInstrEnd()
435 MBB->push_back(MI); in insertInstrEnd()
440 MachineInstr *AMDGPUCFGStructurizer::insertInstrBefore(MachineBasicBlock *MBB, in insertInstrBefore() argument
444 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DL); in insertInstrBefore()
445 if (!MBB->empty()) in insertInstrBefore()
446 MBB->insert(MBB->begin(), MI); in insertInstrBefore()
448 MBB->push_back(MI); in insertInstrBefore()
456 MachineBasicBlock *MBB = OldMI->getParent(); in insertInstrBefore() local
458 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DebugLoc()); in insertInstrBefore()
459 MBB->insert(I, NewMBB); in insertInstrBefore()
468 MachineBasicBlock *MBB = OldMI->getParent(); in insertCondBranchBefore() local
469 MachineFunction *MF = MBB->getParent(); in insertCondBranchBefore()
471 MBB->insert(I, NewMI); in insertCondBranchBefore()
534 MachineBasicBlock *MBB) { in setTrueBranch() argument
535 MI->getOperand(0).setMBB(MBB); in setTrueBranch()
539 AMDGPUCFGStructurizer::getFalseBranch(MachineBasicBlock *MBB, in getFalseBranch() argument
541 assert(MBB->succ_size() == 2); in getFalseBranch()
543 MachineBasicBlock::succ_iterator It = MBB->succ_begin(); in getFalseBranch()
571 DebugLoc AMDGPUCFGStructurizer::getLastDebugLocInBB(MachineBasicBlock *MBB) { in getLastDebugLocInBB() argument
574 for (MachineBasicBlock::iterator It = MBB->begin(); It != MBB->end(); in getLastDebugLocInBB()
584 MachineBasicBlock *MBB) { in getNormalBlockBranchInstr() argument
585 MachineBasicBlock::reverse_iterator It = MBB->rbegin(); in getNormalBlockBranchInstr()
593 MachineBasicBlock *MBB) { in getLoopendBlockBranchInstr() argument
594 for (MachineBasicBlock::reverse_iterator It = MBB->rbegin(), E = MBB->rend(); in getLoopendBlockBranchInstr()
608 MachineInstr *AMDGPUCFGStructurizer::getReturnInstr(MachineBasicBlock *MBB) { in getReturnInstr() argument
609 MachineBasicBlock::reverse_iterator It = MBB->rbegin(); in getReturnInstr()
610 if (It != MBB->rend()) { in getReturnInstr()
618 bool AMDGPUCFGStructurizer::isReturnBlock(MachineBasicBlock *MBB) { in isReturnBlock() argument
619 MachineInstr *MI = getReturnInstr(MBB); in isReturnBlock()
620 bool IsReturn = (MBB->succ_size() == 0); in isReturnBlock()
624 LLVM_DEBUG(dbgs() << "BB" << MBB->getNumber() in isReturnBlock()
636 MachineBasicBlock *AMDGPUCFGStructurizer::clone(MachineBasicBlock *MBB) { in clone() argument
637 MachineFunction *Func = MBB->getParent(); in clone()
640 for (const MachineInstr &It : *MBB) in clone()
654 void AMDGPUCFGStructurizer::wrapup(MachineBasicBlock *MBB) { in wrapup() argument
655 assert((!MBB->getParent()->getJumpTableInfo() in wrapup()
656 || MBB->getParent()->getJumpTableInfo()->isEmpty()) in wrapup()
661 MachineBasicBlock::iterator Pre = MBB->begin(); in wrapup()
662 MachineBasicBlock::iterator E = MBB->end(); in wrapup()
711 MachineBasicBlock *MBB = *It; in prepare() local
712 removeUnconditionalBranch(MBB); in prepare()
713 removeRedundantConditionalBranch(MBB); in prepare()
714 if (isReturnBlock(MBB)) { in prepare()
715 RetBlks.push_back(MBB); in prepare()
717 assert(MBB->succ_size() <= 2); in prepare()
740 MachineBasicBlock *MBB; in run() local
763 MBB = *It; in run()
767 SccBeginMBB = MBB; in run()
774 if (!isRetiredBlock(MBB)) in run()
775 patternMatch(MBB); in run()
786 LLVM_DEBUG(dbgs() << "Can't reduce SCC " << getSCCNum(MBB) in run()
794 LLVM_DEBUG(dbgs() << "repeat processing SCC" << getSCCNum(MBB) in run()
854 MachineBasicBlock *MBB; in orderBlocks() local
861 MBB = *blockIter; in orderBlocks()
862 OrderedBlks.push_back(MBB); in orderBlocks()
863 recordSccnum(MBB, SccNum); in orderBlocks()
868 for (auto *MBB : nodes(MF)) { in orderBlocks() local
869 SccNum = getSCCNum(MBB); in orderBlocks()
871 dbgs() << "unreachable block BB" << MBB->getNumber() << "\n"; in orderBlocks()
875 int AMDGPUCFGStructurizer::patternMatch(MachineBasicBlock *MBB) { in patternMatch() argument
879 LLVM_DEBUG(dbgs() << "Begin patternMatch BB" << MBB->getNumber() << "\n";); in patternMatch()
881 while ((CurMatch = patternMatchGroup(MBB)) > 0) in patternMatch()
884 LLVM_DEBUG(dbgs() << "End patternMatch BB" << MBB->getNumber() in patternMatch()
890 int AMDGPUCFGStructurizer::patternMatchGroup(MachineBasicBlock *MBB) { in patternMatchGroup() argument
893 NumMatch += serialPatternMatch(MBB); in patternMatchGroup()
894 NumMatch += ifPatternMatch(MBB); in patternMatchGroup()
898 int AMDGPUCFGStructurizer::serialPatternMatch(MachineBasicBlock *MBB) { in serialPatternMatch() argument
899 if (MBB->succ_size() != 1) in serialPatternMatch()
902 MachineBasicBlock *childBlk = *MBB->succ_begin(); in serialPatternMatch()
906 mergeSerialBlock(MBB, childBlk); in serialPatternMatch()
911 int AMDGPUCFGStructurizer::ifPatternMatch(MachineBasicBlock *MBB) { in ifPatternMatch() argument
913 if (MBB->succ_size() != 2) in ifPatternMatch()
915 if (hasBackEdge(MBB)) in ifPatternMatch()
917 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB); in ifPatternMatch()
927 MachineBasicBlock *FalseMBB = getFalseBranch(MBB, BranchMI); in ifPatternMatch()
948 reversePredicateSetter(MBB->end(), *MBB); in ifPatternMatch()
958 return NumMatch + handleJumpintoIf(MBB, TrueMBB, FalseMBB); in ifPatternMatch()
967 Cloned += improveSimpleJumpintoIf(MBB, TrueMBB, FalseMBB, &LandBlk); in ifPatternMatch()
971 TrueMBB = cloneBlockForPredecessor(TrueMBB, MBB); in ifPatternMatch()
976 FalseMBB = cloneBlockForPredecessor(FalseMBB, MBB); in ifPatternMatch()
980 mergeIfthenelseBlock(BranchMI, MBB, TrueMBB, FalseMBB, LandBlk); in ifPatternMatch()
1324 MachineBasicBlock *MBB = *PI; in improveSimpleJumpintoIf() local
1325 if (MBB != TrueMBB && MBB != FalseMBB) in improveSimpleJumpintoIf()
1354 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB, in mergeIfthenelseBlock() argument
1357 LLVM_DEBUG(dbgs() << "ifPattern BB" << MBB->getNumber(); dbgs() << "{ "; in mergeIfthenelseBlock()
1383 MBB->splice(I, TrueMBB, TrueMBB->begin(), TrueMBB->end()); in mergeIfthenelseBlock()
1384 MBB->removeSuccessor(TrueMBB, true); in mergeIfthenelseBlock()
1393 MBB->splice(I, FalseMBB, FalseMBB->begin(), in mergeIfthenelseBlock()
1395 MBB->removeSuccessor(FalseMBB, true); in mergeIfthenelseBlock()
1406 MBB->addSuccessor(LandMBB); in mergeIfthenelseBlock()
1502 AMDGPUCFGStructurizer::cloneBlockForPredecessor(MachineBasicBlock *MBB, in cloneBlockForPredecessor() argument
1504 assert(PredMBB->isSuccessor(MBB) && in cloneBlockForPredecessor()
1507 MachineBasicBlock *CloneMBB = clone(MBB); //clone instructions in cloneBlockForPredecessor()
1508 replaceInstrUseOfBlockWith(PredMBB, MBB, CloneMBB); in cloneBlockForPredecessor()
1511 PredMBB->replaceSuccessor(MBB, CloneMBB); in cloneBlockForPredecessor()
1514 cloneSuccessorList(CloneMBB, MBB); in cloneBlockForPredecessor()
1516 numClonedInstr += MBB->size(); in cloneBlockForPredecessor()
1519 << "BB" << MBB->getNumber() << "size " << MBB->size() in cloneBlockForPredecessor()
1572 void AMDGPUCFGStructurizer::removeUnconditionalBranch(MachineBasicBlock *MBB) { in removeUnconditionalBranch() argument
1577 while ((BranchMI = getLoopendBlockBranchInstr(MBB)) in removeUnconditionalBranch()
1585 MachineBasicBlock *MBB) { in removeRedundantConditionalBranch() argument
1586 if (MBB->succ_size() != 2) in removeRedundantConditionalBranch()
1588 MachineBasicBlock *MBB1 = *MBB->succ_begin(); in removeRedundantConditionalBranch()
1589 MachineBasicBlock *MBB2 = *std::next(MBB->succ_begin()); in removeRedundantConditionalBranch()
1593 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB); in removeRedundantConditionalBranch()
1598 MBB->removeSuccessor(MBB1, true); in removeRedundantConditionalBranch()
1609 MachineBasicBlock *MBB = *It; in addDummyExitBlock() local
1610 MachineInstr *MI = getReturnInstr(MBB); in addDummyExitBlock()
1613 MBB->addSuccessor(DummyExitBlk); in addDummyExitBlock()
1614 LLVM_DEBUG(dbgs() << "Add dummyExitBlock to BB" << MBB->getNumber() in addDummyExitBlock()
1620 void AMDGPUCFGStructurizer::removeSuccessor(MachineBasicBlock *MBB) { in removeSuccessor() argument
1621 while (MBB->succ_size()) in removeSuccessor()
1622 MBB->removeSuccessor(*MBB->succ_begin()); in removeSuccessor()
1625 void AMDGPUCFGStructurizer::recordSccnum(MachineBasicBlock *MBB, in recordSccnum() argument
1627 BlockInformation *&srcBlkInfo = BlockInfoMap[MBB]; in recordSccnum()
1633 void AMDGPUCFGStructurizer::retireBlock(MachineBasicBlock *MBB) { in retireBlock() argument
1634 LLVM_DEBUG(dbgs() << "Retiring BB" << MBB->getNumber() << "\n";); in retireBlock()
1636 BlockInformation *&SrcBlkInfo = BlockInfoMap[MBB]; in retireBlock()
1642 assert(MBB->succ_size() == 0 && MBB->pred_size() == 0 in retireBlock()