Lines Matching refs:MBB
211 int getSCCNum(MachineBasicBlock *MBB) const;
213 bool hasBackEdge(MachineBasicBlock *MBB) const;
214 bool isRetiredBlock(MachineBasicBlock *MBB) const;
215 bool isActiveLoophead(MachineBasicBlock *MBB) const;
220 bool needMigrateBlock(MachineBasicBlock *MBB) const;
228 void insertInstrEnd(MachineBasicBlock *MBB, int NewOpcode,
230 MachineInstr *insertInstrBefore(MachineBasicBlock *MBB, int NewOpcode,
235 void insertCondBranchBefore(MachineBasicBlock *MBB,
243 static void setTrueBranch(MachineInstr *MI, MachineBasicBlock *MBB);
244 static MachineBasicBlock *getFalseBranch(MachineBasicBlock *MBB,
248 static DebugLoc getLastDebugLocInBB(MachineBasicBlock *MBB);
249 static MachineInstr *getNormalBlockBranchInstr(MachineBasicBlock *MBB);
254 MachineInstr *getLoopendBlockBranchInstr(MachineBasicBlock *MBB);
255 static MachineInstr *getReturnInstr(MachineBasicBlock *MBB);
256 static bool isReturnBlock(MachineBasicBlock *MBB);
259 static MachineBasicBlock *clone(MachineBasicBlock *MBB);
265 static void wrapup(MachineBasicBlock *MBB);
268 int patternMatch(MachineBasicBlock *MBB);
269 int patternMatchGroup(MachineBasicBlock *MBB);
270 int serialPatternMatch(MachineBasicBlock *MBB);
271 int ifPatternMatch(MachineBasicBlock *MBB);
296 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB,
313 void removeUnconditionalBranch(MachineBasicBlock *MBB);
322 void removeRedundantConditionalBranch(MachineBasicBlock *MBB);
324 void removeSuccessor(MachineBasicBlock *MBB);
325 MachineBasicBlock *cloneBlockForPredecessor(MachineBasicBlock *MBB,
329 void recordSccnum(MachineBasicBlock *MBB, int SCCNum);
330 void retireBlock(MachineBasicBlock *MBB);
341 int AMDGPUCFGStructurizer::getSCCNum(MachineBasicBlock *MBB) const { in getSCCNum()
342 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB); in getSCCNum()
356 bool AMDGPUCFGStructurizer::hasBackEdge(MachineBasicBlock *MBB) const { in hasBackEdge()
357 MachineLoop *LoopRep = MLI->getLoopFor(MBB); in hasBackEdge()
361 return MBB->isSuccessor(LoopHeader); in hasBackEdge()
364 bool AMDGPUCFGStructurizer::isRetiredBlock(MachineBasicBlock *MBB) const { in isRetiredBlock()
365 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB); in isRetiredBlock()
371 bool AMDGPUCFGStructurizer::isActiveLoophead(MachineBasicBlock *MBB) const { in isActiveLoophead()
372 MachineLoop *LoopRep = MLI->getLoopFor(MBB); in isActiveLoophead()
373 while (LoopRep && LoopRep->getHeader() == MBB) { in isActiveLoophead()
412 bool AMDGPUCFGStructurizer::needMigrateBlock(MachineBasicBlock *MBB) const { in needMigrateBlock()
415 bool MultiplePreds = MBB && (MBB->pred_size() > 1); in needMigrateBlock()
419 unsigned BlkSize = MBB->size(); in needMigrateBlock()
421 (BlkSize * (MBB->pred_size() - 1) > CloneInstrThreshold)); in needMigrateBlock()
453 void AMDGPUCFGStructurizer::insertInstrEnd(MachineBasicBlock *MBB, in insertInstrEnd() argument
456 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DL); in insertInstrEnd()
457 MBB->push_back(MI); in insertInstrEnd()
462 MachineInstr *AMDGPUCFGStructurizer::insertInstrBefore(MachineBasicBlock *MBB, in insertInstrBefore() argument
466 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DL); in insertInstrBefore()
467 if (MBB->begin() != MBB->end()) in insertInstrBefore()
468 MBB->insert(MBB->begin(), MI); in insertInstrBefore()
470 MBB->push_back(MI); in insertInstrBefore()
478 MachineBasicBlock *MBB = OldMI->getParent(); in insertInstrBefore() local
480 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DebugLoc()); in insertInstrBefore()
481 MBB->insert(I, NewMBB); in insertInstrBefore()
490 MachineBasicBlock *MBB = OldMI->getParent(); in insertCondBranchBefore() local
491 MachineFunction *MF = MBB->getParent(); in insertCondBranchBefore()
493 MBB->insert(I, NewMI); in insertCondBranchBefore()
556 MachineBasicBlock *MBB) { in setTrueBranch() argument
557 MI->getOperand(0).setMBB(MBB); in setTrueBranch()
561 AMDGPUCFGStructurizer::getFalseBranch(MachineBasicBlock *MBB, in getFalseBranch() argument
563 assert(MBB->succ_size() == 2); in getFalseBranch()
565 MachineBasicBlock::succ_iterator It = MBB->succ_begin(); in getFalseBranch()
593 DebugLoc AMDGPUCFGStructurizer::getLastDebugLocInBB(MachineBasicBlock *MBB) { in getLastDebugLocInBB() argument
596 for (MachineBasicBlock::iterator It = MBB->begin(); It != MBB->end(); in getLastDebugLocInBB()
606 MachineBasicBlock *MBB) { in getNormalBlockBranchInstr() argument
607 MachineBasicBlock::reverse_iterator It = MBB->rbegin(); in getNormalBlockBranchInstr()
615 MachineBasicBlock *MBB) { in getLoopendBlockBranchInstr() argument
616 for (MachineBasicBlock::reverse_iterator It = MBB->rbegin(), E = MBB->rend(); in getLoopendBlockBranchInstr()
630 MachineInstr *AMDGPUCFGStructurizer::getReturnInstr(MachineBasicBlock *MBB) { in getReturnInstr() argument
631 MachineBasicBlock::reverse_iterator It = MBB->rbegin(); in getReturnInstr()
632 if (It != MBB->rend()) { in getReturnInstr()
640 bool AMDGPUCFGStructurizer::isReturnBlock(MachineBasicBlock *MBB) { in isReturnBlock() argument
641 MachineInstr *MI = getReturnInstr(MBB); in isReturnBlock()
642 bool IsReturn = (MBB->succ_size() == 0); in isReturnBlock()
647 dbgs() << "BB" << MBB->getNumber() in isReturnBlock()
659 MachineBasicBlock *AMDGPUCFGStructurizer::clone(MachineBasicBlock *MBB) { in clone() argument
660 MachineFunction *Func = MBB->getParent(); in clone()
663 for (const MachineInstr &It : *MBB) in clone()
677 void AMDGPUCFGStructurizer::wrapup(MachineBasicBlock *MBB) { in wrapup() argument
678 assert((!MBB->getParent()->getJumpTableInfo() in wrapup()
679 || MBB->getParent()->getJumpTableInfo()->isEmpty()) in wrapup()
684 MachineBasicBlock::iterator Pre = MBB->begin(); in wrapup()
685 MachineBasicBlock::iterator E = MBB->end(); in wrapup()
736 MachineBasicBlock *MBB = *It; in prepare() local
737 removeUnconditionalBranch(MBB); in prepare()
738 removeRedundantConditionalBranch(MBB); in prepare()
739 if (isReturnBlock(MBB)) { in prepare()
740 RetBlks.push_back(MBB); in prepare()
742 assert(MBB->succ_size() <= 2); in prepare()
766 MachineBasicBlock *MBB; in run() local
791 MBB = *It; in run()
795 SccBeginMBB = MBB; in run()
804 if (!isRetiredBlock(MBB)) in run()
805 patternMatch(MBB); in run()
817 dbgs() << "Can't reduce SCC " << getSCCNum(MBB) in run()
827 dbgs() << "repeat processing SCC" << getSCCNum(MBB) in run()
896 MachineBasicBlock *MBB; in orderBlocks() local
903 MBB = *blockIter; in orderBlocks()
904 OrderedBlks.push_back(MBB); in orderBlocks()
905 recordSccnum(MBB, SccNum); in orderBlocks()
913 MachineBasicBlock *MBB = &(*It); in orderBlocks() local
914 SccNum = getSCCNum(MBB); in orderBlocks()
916 dbgs() << "unreachable block BB" << MBB->getNumber() << "\n"; in orderBlocks()
920 int AMDGPUCFGStructurizer::patternMatch(MachineBasicBlock *MBB) { in patternMatch() argument
925 dbgs() << "Begin patternMatch BB" << MBB->getNumber() << "\n"; in patternMatch()
928 while ((CurMatch = patternMatchGroup(MBB)) > 0) in patternMatch()
932 dbgs() << "End patternMatch BB" << MBB->getNumber() in patternMatch()
939 int AMDGPUCFGStructurizer::patternMatchGroup(MachineBasicBlock *MBB) { in patternMatchGroup() argument
942 NumMatch += serialPatternMatch(MBB); in patternMatchGroup()
943 NumMatch += ifPatternMatch(MBB); in patternMatchGroup()
948 int AMDGPUCFGStructurizer::serialPatternMatch(MachineBasicBlock *MBB) { in serialPatternMatch() argument
949 if (MBB->succ_size() != 1) in serialPatternMatch()
952 MachineBasicBlock *childBlk = *MBB->succ_begin(); in serialPatternMatch()
956 mergeSerialBlock(MBB, childBlk); in serialPatternMatch()
961 int AMDGPUCFGStructurizer::ifPatternMatch(MachineBasicBlock *MBB) { in ifPatternMatch() argument
963 if (MBB->succ_size() != 2) in ifPatternMatch()
965 if (hasBackEdge(MBB)) in ifPatternMatch()
967 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB); in ifPatternMatch()
977 MachineBasicBlock *FalseMBB = getFalseBranch(MBB, BranchMI); in ifPatternMatch()
998 reversePredicateSetter(MBB->end()); in ifPatternMatch()
1008 return NumMatch + handleJumpintoIf(MBB, TrueMBB, FalseMBB); in ifPatternMatch()
1017 Cloned += improveSimpleJumpintoIf(MBB, TrueMBB, FalseMBB, &LandBlk); in ifPatternMatch()
1021 TrueMBB = cloneBlockForPredecessor(TrueMBB, MBB); in ifPatternMatch()
1026 FalseMBB = cloneBlockForPredecessor(FalseMBB, MBB); in ifPatternMatch()
1030 mergeIfthenelseBlock(BranchMI, MBB, TrueMBB, FalseMBB, LandBlk); in ifPatternMatch()
1387 MachineBasicBlock *MBB = *PI; in improveSimpleJumpintoIf() local
1388 if (MBB != TrueMBB && MBB != FalseMBB) in improveSimpleJumpintoIf()
1420 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB, in mergeIfthenelseBlock() argument
1424 dbgs() << "ifPattern BB" << MBB->getNumber(); in mergeIfthenelseBlock()
1460 MBB->splice(I, TrueMBB, TrueMBB->begin(), TrueMBB->end()); in mergeIfthenelseBlock()
1461 MBB->removeSuccessor(TrueMBB, true); in mergeIfthenelseBlock()
1470 MBB->splice(I, FalseMBB, FalseMBB->begin(), in mergeIfthenelseBlock()
1472 MBB->removeSuccessor(FalseMBB, true); in mergeIfthenelseBlock()
1483 MBB->addSuccessor(LandMBB); in mergeIfthenelseBlock()
1580 AMDGPUCFGStructurizer::cloneBlockForPredecessor(MachineBasicBlock *MBB, in cloneBlockForPredecessor() argument
1582 assert(PredMBB->isSuccessor(MBB) && in cloneBlockForPredecessor()
1585 MachineBasicBlock *CloneMBB = clone(MBB); //clone instructions in cloneBlockForPredecessor()
1586 replaceInstrUseOfBlockWith(PredMBB, MBB, CloneMBB); in cloneBlockForPredecessor()
1589 PredMBB->replaceSuccessor(MBB, CloneMBB); in cloneBlockForPredecessor()
1592 cloneSuccessorList(CloneMBB, MBB); in cloneBlockForPredecessor()
1594 numClonedInstr += MBB->size(); in cloneBlockForPredecessor()
1598 << MBB->getNumber() << "size " << MBB->size() << "\n"; in cloneBlockForPredecessor()
1655 void AMDGPUCFGStructurizer::removeUnconditionalBranch(MachineBasicBlock *MBB) { in removeUnconditionalBranch() argument
1660 while ((BranchMI = getLoopendBlockBranchInstr(MBB)) in removeUnconditionalBranch()
1668 MachineBasicBlock *MBB) { in removeRedundantConditionalBranch() argument
1669 if (MBB->succ_size() != 2) in removeRedundantConditionalBranch()
1671 MachineBasicBlock *MBB1 = *MBB->succ_begin(); in removeRedundantConditionalBranch()
1672 MachineBasicBlock *MBB2 = *std::next(MBB->succ_begin()); in removeRedundantConditionalBranch()
1676 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB); in removeRedundantConditionalBranch()
1681 MBB->removeSuccessor(MBB1, true); in removeRedundantConditionalBranch()
1692 MachineBasicBlock *MBB = *It; in addDummyExitBlock() local
1693 MachineInstr *MI = getReturnInstr(MBB); in addDummyExitBlock()
1696 MBB->addSuccessor(DummyExitBlk); in addDummyExitBlock()
1698 dbgs() << "Add dummyExitBlock to BB" << MBB->getNumber() in addDummyExitBlock()
1705 void AMDGPUCFGStructurizer::removeSuccessor(MachineBasicBlock *MBB) { in removeSuccessor() argument
1706 while (MBB->succ_size()) in removeSuccessor()
1707 MBB->removeSuccessor(*MBB->succ_begin()); in removeSuccessor()
1710 void AMDGPUCFGStructurizer::recordSccnum(MachineBasicBlock *MBB, in recordSccnum() argument
1712 BlockInformation *&srcBlkInfo = BlockInfoMap[MBB]; in recordSccnum()
1718 void AMDGPUCFGStructurizer::retireBlock(MachineBasicBlock *MBB) { in retireBlock() argument
1720 dbgs() << "Retiring BB" << MBB->getNumber() << "\n"; in retireBlock()
1723 BlockInformation *&SrcBlkInfo = BlockInfoMap[MBB]; in retireBlock()
1729 assert(MBB->succ_size() == 0 && MBB->pred_size() == 0 in retireBlock()