Lines Matching refs:MBB

204   int getSCCNum(MachineBasicBlock *MBB) const;
206 bool hasBackEdge(MachineBasicBlock *MBB) const;
207 bool isRetiredBlock(MachineBasicBlock *MBB) const;
208 bool isActiveLoophead(MachineBasicBlock *MBB) const;
213 bool needMigrateBlock(MachineBasicBlock *MBB) const;
217 MachineBasicBlock &MBB);
222 void insertInstrEnd(MachineBasicBlock *MBB, int NewOpcode,
224 MachineInstr *insertInstrBefore(MachineBasicBlock *MBB, int NewOpcode,
229 void insertCondBranchBefore(MachineBasicBlock *MBB,
238 static void setTrueBranch(MachineInstr *MI, MachineBasicBlock *MBB);
239 static MachineBasicBlock *getFalseBranch(MachineBasicBlock *MBB,
243 static DebugLoc getLastDebugLocInBB(MachineBasicBlock *MBB);
244 static MachineInstr *getNormalBlockBranchInstr(MachineBasicBlock *MBB);
250 MachineInstr *getLoopendBlockBranchInstr(MachineBasicBlock *MBB);
252 static MachineInstr *getReturnInstr(MachineBasicBlock *MBB);
253 static bool isReturnBlock(MachineBasicBlock *MBB);
256 static MachineBasicBlock *clone(MachineBasicBlock *MBB);
264 static void wrapup(MachineBasicBlock *MBB);
266 int patternMatch(MachineBasicBlock *MBB);
267 int patternMatchGroup(MachineBasicBlock *MBB);
268 int serialPatternMatch(MachineBasicBlock *MBB);
269 int ifPatternMatch(MachineBasicBlock *MBB);
294 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB,
312 void removeUnconditionalBranch(MachineBasicBlock *MBB);
322 void removeRedundantConditionalBranch(MachineBasicBlock *MBB);
325 void removeSuccessor(MachineBasicBlock *MBB);
326 MachineBasicBlock *cloneBlockForPredecessor(MachineBasicBlock *MBB,
330 void recordSccnum(MachineBasicBlock *MBB, int SCCNum);
331 void retireBlock(MachineBasicBlock *MBB);
345 int AMDGPUCFGStructurizer::getSCCNum(MachineBasicBlock *MBB) const { in getSCCNum()
346 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB); in getSCCNum()
360 bool AMDGPUCFGStructurizer::hasBackEdge(MachineBasicBlock *MBB) const { in hasBackEdge()
361 MachineLoop *LoopRep = MLI->getLoopFor(MBB); in hasBackEdge()
365 return MBB->isSuccessor(LoopHeader); in hasBackEdge()
368 bool AMDGPUCFGStructurizer::isRetiredBlock(MachineBasicBlock *MBB) const { in isRetiredBlock()
369 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB); in isRetiredBlock()
375 bool AMDGPUCFGStructurizer::isActiveLoophead(MachineBasicBlock *MBB) const { in isActiveLoophead()
376 MachineLoop *LoopRep = MLI->getLoopFor(MBB); in isActiveLoophead()
377 while (LoopRep && LoopRep->getHeader() == MBB) { in isActiveLoophead()
417 bool AMDGPUCFGStructurizer::needMigrateBlock(MachineBasicBlock *MBB) const { in needMigrateBlock()
420 bool MultiplePreds = MBB && (MBB->pred_size() > 1); in needMigrateBlock()
424 unsigned BlkSize = MBB->size(); in needMigrateBlock()
426 (BlkSize * (MBB->pred_size() - 1) > CloneInstrThreshold)); in needMigrateBlock()
430 MachineBasicBlock::iterator I, MachineBasicBlock &MBB) { in reversePredicateSetter() argument
433 if (I == MBB.end()) in reversePredicateSetter()
456 void AMDGPUCFGStructurizer::insertInstrEnd(MachineBasicBlock *MBB, in insertInstrEnd() argument
459 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DL); in insertInstrEnd()
460 MBB->push_back(MI); in insertInstrEnd()
465 MachineInstr *AMDGPUCFGStructurizer::insertInstrBefore(MachineBasicBlock *MBB, in insertInstrBefore() argument
469 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DL); in insertInstrBefore()
470 if (MBB->begin() != MBB->end()) in insertInstrBefore()
471 MBB->insert(MBB->begin(), MI); in insertInstrBefore()
473 MBB->push_back(MI); in insertInstrBefore()
481 MachineBasicBlock *MBB = OldMI->getParent(); in insertInstrBefore() local
483 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DebugLoc()); in insertInstrBefore()
484 MBB->insert(I, NewMBB); in insertInstrBefore()
493 MachineBasicBlock *MBB = OldMI->getParent(); in insertCondBranchBefore() local
494 MachineFunction *MF = MBB->getParent(); in insertCondBranchBefore()
496 MBB->insert(I, NewMI); in insertCondBranchBefore()
559 MachineBasicBlock *MBB) { in setTrueBranch() argument
560 MI->getOperand(0).setMBB(MBB); in setTrueBranch()
564 AMDGPUCFGStructurizer::getFalseBranch(MachineBasicBlock *MBB, in getFalseBranch() argument
566 assert(MBB->succ_size() == 2); in getFalseBranch()
568 MachineBasicBlock::succ_iterator It = MBB->succ_begin(); in getFalseBranch()
596 DebugLoc AMDGPUCFGStructurizer::getLastDebugLocInBB(MachineBasicBlock *MBB) { in getLastDebugLocInBB() argument
599 for (MachineBasicBlock::iterator It = MBB->begin(); It != MBB->end(); in getLastDebugLocInBB()
609 MachineBasicBlock *MBB) { in getNormalBlockBranchInstr() argument
610 MachineBasicBlock::reverse_iterator It = MBB->rbegin(); in getNormalBlockBranchInstr()
618 MachineBasicBlock *MBB) { in getLoopendBlockBranchInstr() argument
619 for (MachineBasicBlock::reverse_iterator It = MBB->rbegin(), E = MBB->rend(); in getLoopendBlockBranchInstr()
633 MachineInstr *AMDGPUCFGStructurizer::getReturnInstr(MachineBasicBlock *MBB) { in getReturnInstr() argument
634 MachineBasicBlock::reverse_iterator It = MBB->rbegin(); in getReturnInstr()
635 if (It != MBB->rend()) { in getReturnInstr()
643 bool AMDGPUCFGStructurizer::isReturnBlock(MachineBasicBlock *MBB) { in isReturnBlock() argument
644 MachineInstr *MI = getReturnInstr(MBB); in isReturnBlock()
645 bool IsReturn = (MBB->succ_size() == 0); in isReturnBlock()
649 LLVM_DEBUG(dbgs() << "BB" << MBB->getNumber() in isReturnBlock()
661 MachineBasicBlock *AMDGPUCFGStructurizer::clone(MachineBasicBlock *MBB) { in clone() argument
662 MachineFunction *Func = MBB->getParent(); in clone()
665 for (const MachineInstr &It : *MBB) in clone()
679 void AMDGPUCFGStructurizer::wrapup(MachineBasicBlock *MBB) { in wrapup() argument
680 assert((!MBB->getParent()->getJumpTableInfo() in wrapup()
681 || MBB->getParent()->getJumpTableInfo()->isEmpty()) in wrapup()
686 MachineBasicBlock::iterator Pre = MBB->begin(); in wrapup()
687 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()
765 MachineBasicBlock *MBB; in run() local
788 MBB = *It; in run()
792 SccBeginMBB = MBB; in run()
799 if (!isRetiredBlock(MBB)) in run()
800 patternMatch(MBB); in run()
811 LLVM_DEBUG(dbgs() << "Can't reduce SCC " << getSCCNum(MBB) in run()
819 LLVM_DEBUG(dbgs() << "repeat processing SCC" << getSCCNum(MBB) in run()
879 MachineBasicBlock *MBB; in orderBlocks() local
886 MBB = *blockIter; in orderBlocks()
887 OrderedBlks.push_back(MBB); in orderBlocks()
888 recordSccnum(MBB, SccNum); in orderBlocks()
893 for (auto *MBB : nodes(MF)) { in orderBlocks() local
894 SccNum = getSCCNum(MBB); in orderBlocks()
896 dbgs() << "unreachable block BB" << MBB->getNumber() << "\n"; in orderBlocks()
900 int AMDGPUCFGStructurizer::patternMatch(MachineBasicBlock *MBB) { in patternMatch() argument
904 LLVM_DEBUG(dbgs() << "Begin patternMatch BB" << MBB->getNumber() << "\n";); in patternMatch()
906 while ((CurMatch = patternMatchGroup(MBB)) > 0) in patternMatch()
909 LLVM_DEBUG(dbgs() << "End patternMatch BB" << MBB->getNumber() in patternMatch()
915 int AMDGPUCFGStructurizer::patternMatchGroup(MachineBasicBlock *MBB) { in patternMatchGroup() argument
918 NumMatch += serialPatternMatch(MBB); in patternMatchGroup()
919 NumMatch += ifPatternMatch(MBB); in patternMatchGroup()
923 int AMDGPUCFGStructurizer::serialPatternMatch(MachineBasicBlock *MBB) { in serialPatternMatch() argument
924 if (MBB->succ_size() != 1) in serialPatternMatch()
927 MachineBasicBlock *childBlk = *MBB->succ_begin(); in serialPatternMatch()
931 mergeSerialBlock(MBB, childBlk); in serialPatternMatch()
936 int AMDGPUCFGStructurizer::ifPatternMatch(MachineBasicBlock *MBB) { in ifPatternMatch() argument
938 if (MBB->succ_size() != 2) in ifPatternMatch()
940 if (hasBackEdge(MBB)) in ifPatternMatch()
942 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB); in ifPatternMatch()
952 MachineBasicBlock *FalseMBB = getFalseBranch(MBB, BranchMI); in ifPatternMatch()
973 reversePredicateSetter(MBB->end(), *MBB); in ifPatternMatch()
983 return NumMatch + handleJumpintoIf(MBB, TrueMBB, FalseMBB); in ifPatternMatch()
992 Cloned += improveSimpleJumpintoIf(MBB, TrueMBB, FalseMBB, &LandBlk); in ifPatternMatch()
996 TrueMBB = cloneBlockForPredecessor(TrueMBB, MBB); in ifPatternMatch()
1001 FalseMBB = cloneBlockForPredecessor(FalseMBB, MBB); in ifPatternMatch()
1005 mergeIfthenelseBlock(BranchMI, MBB, TrueMBB, FalseMBB, LandBlk); in ifPatternMatch()
1349 MachineBasicBlock *MBB = *PI; in improveSimpleJumpintoIf() local
1350 if (MBB != TrueMBB && MBB != FalseMBB) in improveSimpleJumpintoIf()
1379 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB, in mergeIfthenelseBlock() argument
1382 LLVM_DEBUG(dbgs() << "ifPattern BB" << MBB->getNumber(); dbgs() << "{ "; in mergeIfthenelseBlock()
1408 MBB->splice(I, TrueMBB, TrueMBB->begin(), TrueMBB->end()); in mergeIfthenelseBlock()
1409 MBB->removeSuccessor(TrueMBB, true); in mergeIfthenelseBlock()
1418 MBB->splice(I, FalseMBB, FalseMBB->begin(), in mergeIfthenelseBlock()
1420 MBB->removeSuccessor(FalseMBB, true); in mergeIfthenelseBlock()
1431 MBB->addSuccessor(LandMBB); in mergeIfthenelseBlock()
1527 AMDGPUCFGStructurizer::cloneBlockForPredecessor(MachineBasicBlock *MBB, in cloneBlockForPredecessor() argument
1529 assert(PredMBB->isSuccessor(MBB) && in cloneBlockForPredecessor()
1532 MachineBasicBlock *CloneMBB = clone(MBB); //clone instructions in cloneBlockForPredecessor()
1533 replaceInstrUseOfBlockWith(PredMBB, MBB, CloneMBB); in cloneBlockForPredecessor()
1536 PredMBB->replaceSuccessor(MBB, CloneMBB); in cloneBlockForPredecessor()
1539 cloneSuccessorList(CloneMBB, MBB); in cloneBlockForPredecessor()
1541 numClonedInstr += MBB->size(); in cloneBlockForPredecessor()
1544 << "BB" << MBB->getNumber() << "size " << MBB->size() in cloneBlockForPredecessor()
1597 void AMDGPUCFGStructurizer::removeUnconditionalBranch(MachineBasicBlock *MBB) { in removeUnconditionalBranch() argument
1602 while ((BranchMI = getLoopendBlockBranchInstr(MBB)) in removeUnconditionalBranch()
1610 MachineBasicBlock *MBB) { in removeRedundantConditionalBranch() argument
1611 if (MBB->succ_size() != 2) in removeRedundantConditionalBranch()
1613 MachineBasicBlock *MBB1 = *MBB->succ_begin(); in removeRedundantConditionalBranch()
1614 MachineBasicBlock *MBB2 = *std::next(MBB->succ_begin()); in removeRedundantConditionalBranch()
1618 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB); in removeRedundantConditionalBranch()
1623 MBB->removeSuccessor(MBB1, true); in removeRedundantConditionalBranch()
1634 MachineBasicBlock *MBB = *It; in addDummyExitBlock() local
1635 MachineInstr *MI = getReturnInstr(MBB); in addDummyExitBlock()
1638 MBB->addSuccessor(DummyExitBlk); in addDummyExitBlock()
1639 LLVM_DEBUG(dbgs() << "Add dummyExitBlock to BB" << MBB->getNumber() in addDummyExitBlock()
1645 void AMDGPUCFGStructurizer::removeSuccessor(MachineBasicBlock *MBB) { in removeSuccessor() argument
1646 while (MBB->succ_size()) in removeSuccessor()
1647 MBB->removeSuccessor(*MBB->succ_begin()); in removeSuccessor()
1650 void AMDGPUCFGStructurizer::recordSccnum(MachineBasicBlock *MBB, in recordSccnum() argument
1652 BlockInformation *&srcBlkInfo = BlockInfoMap[MBB]; in recordSccnum()
1658 void AMDGPUCFGStructurizer::retireBlock(MachineBasicBlock *MBB) { in retireBlock() argument
1659 LLVM_DEBUG(dbgs() << "Retiring BB" << MBB->getNumber() << "\n";); in retireBlock()
1661 BlockInformation *&SrcBlkInfo = BlockInfoMap[MBB]; in retireBlock()
1667 assert(MBB->succ_size() == 0 && MBB->pred_size() == 0 in retireBlock()