Lines Matching refs:MBB

182   int getSCCNum(MachineBasicBlock *MBB) const;
184 bool hasBackEdge(MachineBasicBlock *MBB) const;
185 bool isRetiredBlock(MachineBasicBlock *MBB) const;
186 bool isActiveLoophead(MachineBasicBlock *MBB) const;
191 bool needMigrateBlock(MachineBasicBlock *MBB) const;
195 MachineBasicBlock &MBB);
200 void insertInstrEnd(MachineBasicBlock *MBB, int NewOpcode,
202 MachineInstr *insertInstrBefore(MachineBasicBlock *MBB, int NewOpcode,
207 void insertCondBranchBefore(MachineBasicBlock *MBB,
216 static void setTrueBranch(MachineInstr *MI, MachineBasicBlock *MBB);
217 static MachineBasicBlock *getFalseBranch(MachineBasicBlock *MBB,
221 static DebugLoc getLastDebugLocInBB(MachineBasicBlock *MBB);
222 static MachineInstr *getNormalBlockBranchInstr(MachineBasicBlock *MBB);
228 MachineInstr *getLoopendBlockBranchInstr(MachineBasicBlock *MBB);
230 static MachineInstr *getReturnInstr(MachineBasicBlock *MBB);
231 static bool isReturnBlock(MachineBasicBlock *MBB);
234 static MachineBasicBlock *clone(MachineBasicBlock *MBB);
242 static void wrapup(MachineBasicBlock *MBB);
244 int patternMatch(MachineBasicBlock *MBB);
245 int patternMatchGroup(MachineBasicBlock *MBB);
246 int serialPatternMatch(MachineBasicBlock *MBB);
247 int ifPatternMatch(MachineBasicBlock *MBB);
272 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB,
290 void removeUnconditionalBranch(MachineBasicBlock *MBB);
300 void removeRedundantConditionalBranch(MachineBasicBlock *MBB);
303 void removeSuccessor(MachineBasicBlock *MBB);
304 MachineBasicBlock *cloneBlockForPredecessor(MachineBasicBlock *MBB,
308 void recordSccnum(MachineBasicBlock *MBB, int SCCNum);
309 void retireBlock(MachineBasicBlock *MBB);
323 int R600MachineCFGStructurizer::getSCCNum(MachineBasicBlock *MBB) const { in getSCCNum()
324 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB); in getSCCNum()
338 bool R600MachineCFGStructurizer::hasBackEdge(MachineBasicBlock *MBB) const { in hasBackEdge()
339 MachineLoop *LoopRep = MLI->getLoopFor(MBB); in hasBackEdge()
343 return MBB->isSuccessor(LoopHeader); in hasBackEdge()
346 bool R600MachineCFGStructurizer::isRetiredBlock(MachineBasicBlock *MBB) const { in isRetiredBlock()
347 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB); in isRetiredBlock()
353 bool R600MachineCFGStructurizer::isActiveLoophead(MachineBasicBlock *MBB) const { in isActiveLoophead()
354 MachineLoop *LoopRep = MLI->getLoopFor(MBB); in isActiveLoophead()
355 while (LoopRep && LoopRep->getHeader() == MBB) { in isActiveLoophead()
395 bool R600MachineCFGStructurizer::needMigrateBlock(MachineBasicBlock *MBB) const { in needMigrateBlock()
398 bool MultiplePreds = MBB && (MBB->pred_size() > 1); in needMigrateBlock()
402 unsigned BlkSize = MBB->size(); in needMigrateBlock()
404 (BlkSize * (MBB->pred_size() - 1) > CloneInstrThreshold)); in needMigrateBlock()
408 MachineBasicBlock::iterator I, MachineBasicBlock &MBB) { in reversePredicateSetter() argument
411 if (I == MBB.end()) in reversePredicateSetter()
434 void R600MachineCFGStructurizer::insertInstrEnd(MachineBasicBlock *MBB, in insertInstrEnd() argument
437 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DL); in insertInstrEnd()
438 MBB->push_back(MI); in insertInstrEnd()
443 MachineInstr *R600MachineCFGStructurizer::insertInstrBefore(MachineBasicBlock *MBB, in insertInstrBefore() argument
447 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DL); in insertInstrBefore()
448 if (!MBB->empty()) in insertInstrBefore()
449 MBB->insert(MBB->begin(), MI); in insertInstrBefore()
451 MBB->push_back(MI); in insertInstrBefore()
459 MachineBasicBlock *MBB = OldMI->getParent(); in insertInstrBefore() local
461 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DebugLoc()); in insertInstrBefore()
462 MBB->insert(I, NewMBB); in insertInstrBefore()
471 MachineBasicBlock *MBB = OldMI->getParent(); in insertCondBranchBefore() local
472 MachineFunction *MF = MBB->getParent(); in insertCondBranchBefore()
474 MBB->insert(I, NewMI); in insertCondBranchBefore()
537 MachineBasicBlock *MBB) { in setTrueBranch() argument
538 MI->getOperand(0).setMBB(MBB); in setTrueBranch()
542 R600MachineCFGStructurizer::getFalseBranch(MachineBasicBlock *MBB, in getFalseBranch() argument
544 assert(MBB->succ_size() == 2); in getFalseBranch()
546 MachineBasicBlock::succ_iterator It = MBB->succ_begin(); in getFalseBranch()
574 DebugLoc R600MachineCFGStructurizer::getLastDebugLocInBB(MachineBasicBlock *MBB) { in getLastDebugLocInBB() argument
577 for (MachineInstr &MI : *MBB) 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 *R600MachineCFGStructurizer::getReturnInstr(MachineBasicBlock *MBB) { in getReturnInstr() argument
609 MachineBasicBlock::reverse_iterator It = MBB->rbegin(); in getReturnInstr()
610 if (It != MBB->rend()) { in getReturnInstr()
618 bool R600MachineCFGStructurizer::isReturnBlock(MachineBasicBlock *MBB) { in isReturnBlock() argument
619 MachineInstr *MI = getReturnInstr(MBB); in isReturnBlock()
620 bool IsReturn = MBB->succ_empty(); in isReturnBlock()
624 LLVM_DEBUG(dbgs() << "BB" << MBB->getNumber() in isReturnBlock()
635 MachineBasicBlock *R600MachineCFGStructurizer::clone(MachineBasicBlock *MBB) { in clone() argument
636 MachineFunction *Func = MBB->getParent(); in clone()
639 for (const MachineInstr &It : *MBB) in clone()
653 void R600MachineCFGStructurizer::wrapup(MachineBasicBlock *MBB) { in wrapup() argument
654 assert((!MBB->getParent()->getJumpTableInfo() in wrapup()
655 || MBB->getParent()->getJumpTableInfo()->isEmpty()) in wrapup()
660 MachineBasicBlock::iterator Pre = MBB->begin(); in wrapup()
661 MachineBasicBlock::iterator E = MBB->end(); in wrapup()
706 for (MachineBasicBlock *MBB : OrderedBlks) { in prepare()
707 removeUnconditionalBranch(MBB); in prepare()
708 removeRedundantConditionalBranch(MBB); in prepare()
709 if (isReturnBlock(MBB)) { in prepare()
710 RetBlks.push_back(MBB); in prepare()
712 assert(MBB->succ_size() <= 2); in prepare()
735 MachineBasicBlock *MBB; in run() local
759 MBB = *It; in run()
763 SccBeginMBB = MBB; in run()
770 if (!isRetiredBlock(MBB)) in run()
771 patternMatch(MBB); in run()
782 LLVM_DEBUG(dbgs() << "Can't reduce SCC " << getSCCNum(MBB) in run()
791 LLVM_DEBUG(dbgs() << "repeat processing SCC" << getSCCNum(MBB) in run()
853 for (MachineBasicBlock *MBB : SccNext) { in orderBlocks()
854 OrderedBlks.push_back(MBB); in orderBlocks()
855 recordSccnum(MBB, SccNum); in orderBlocks()
860 for (auto *MBB : nodes(MF)) { in orderBlocks() local
861 SccNum = getSCCNum(MBB); in orderBlocks()
863 dbgs() << "unreachable block BB" << MBB->getNumber() << "\n"; in orderBlocks()
867 int R600MachineCFGStructurizer::patternMatch(MachineBasicBlock *MBB) { in patternMatch() argument
871 LLVM_DEBUG(dbgs() << "Begin patternMatch BB" << MBB->getNumber() << "\n";); in patternMatch()
873 while ((CurMatch = patternMatchGroup(MBB)) > 0) in patternMatch()
876 LLVM_DEBUG(dbgs() << "End patternMatch BB" << MBB->getNumber() in patternMatch()
882 int R600MachineCFGStructurizer::patternMatchGroup(MachineBasicBlock *MBB) { in patternMatchGroup() argument
885 NumMatch += serialPatternMatch(MBB); in patternMatchGroup()
886 NumMatch += ifPatternMatch(MBB); in patternMatchGroup()
890 int R600MachineCFGStructurizer::serialPatternMatch(MachineBasicBlock *MBB) { in serialPatternMatch() argument
891 if (MBB->succ_size() != 1) in serialPatternMatch()
894 MachineBasicBlock *childBlk = *MBB->succ_begin(); in serialPatternMatch()
898 mergeSerialBlock(MBB, childBlk); in serialPatternMatch()
903 int R600MachineCFGStructurizer::ifPatternMatch(MachineBasicBlock *MBB) { in ifPatternMatch() argument
905 if (MBB->succ_size() != 2) in ifPatternMatch()
907 if (hasBackEdge(MBB)) in ifPatternMatch()
909 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB); in ifPatternMatch()
919 MachineBasicBlock *FalseMBB = getFalseBranch(MBB, BranchMI); in ifPatternMatch()
940 reversePredicateSetter(MBB->end(), *MBB); in ifPatternMatch()
950 return NumMatch + handleJumpintoIf(MBB, TrueMBB, FalseMBB); in ifPatternMatch()
959 Cloned += improveSimpleJumpintoIf(MBB, TrueMBB, FalseMBB, &LandBlk); in ifPatternMatch()
963 TrueMBB = cloneBlockForPredecessor(TrueMBB, MBB); in ifPatternMatch()
968 FalseMBB = cloneBlockForPredecessor(FalseMBB, MBB); in ifPatternMatch()
972 mergeIfthenelseBlock(BranchMI, MBB, TrueMBB, FalseMBB, LandBlk); in ifPatternMatch()
1017 for (MachineBasicBlock *MBB : ExitBlks) in mergeLoop()
1018 ExitBlkSet.insert(MBB); in mergeLoop()
1027 for (MachineBasicBlock *MBB : ExitingMBBs) in mergeLoop()
1028 mergeLoopbreakBlock(MBB, ExitBlk); in mergeLoop()
1029 for (MachineBasicBlock *MBB : LatchBlks) in mergeLoop()
1030 settleLoopcontBlock(MBB, LoopHeader); in mergeLoop()
1314 for (MachineBasicBlock *MBB : LandBlk->predecessors()) in improveSimpleJumpintoIf()
1315 if (MBB != TrueMBB && MBB != FalseMBB) in improveSimpleJumpintoIf()
1343 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB, in mergeIfthenelseBlock() argument
1346 LLVM_DEBUG(dbgs() << "ifPattern BB" << MBB->getNumber(); dbgs() << "{ "; in mergeIfthenelseBlock()
1372 MBB->splice(I, TrueMBB, TrueMBB->begin(), TrueMBB->end()); in mergeIfthenelseBlock()
1373 MBB->removeSuccessor(TrueMBB, true); in mergeIfthenelseBlock()
1382 MBB->splice(I, FalseMBB, FalseMBB->begin(), in mergeIfthenelseBlock()
1384 MBB->removeSuccessor(FalseMBB, true); in mergeIfthenelseBlock()
1395 MBB->addSuccessor(LandMBB); in mergeIfthenelseBlock()
1491 R600MachineCFGStructurizer::cloneBlockForPredecessor(MachineBasicBlock *MBB, in cloneBlockForPredecessor() argument
1493 assert(PredMBB->isSuccessor(MBB) && "succBlk is not a predecessor of curBlk"); in cloneBlockForPredecessor()
1495 MachineBasicBlock *CloneMBB = clone(MBB); //clone instructions in cloneBlockForPredecessor()
1496 replaceInstrUseOfBlockWith(PredMBB, MBB, CloneMBB); in cloneBlockForPredecessor()
1499 PredMBB->replaceSuccessor(MBB, CloneMBB); in cloneBlockForPredecessor()
1502 cloneSuccessorList(CloneMBB, MBB); in cloneBlockForPredecessor()
1504 numClonedInstr += MBB->size(); in cloneBlockForPredecessor()
1507 << "BB" << MBB->getNumber() << "size " << MBB->size() in cloneBlockForPredecessor()
1560 void R600MachineCFGStructurizer::removeUnconditionalBranch(MachineBasicBlock *MBB) { in removeUnconditionalBranch() argument
1565 while ((BranchMI = getLoopendBlockBranchInstr(MBB)) in removeUnconditionalBranch()
1573 MachineBasicBlock *MBB) { in removeRedundantConditionalBranch() argument
1574 if (MBB->succ_size() != 2) in removeRedundantConditionalBranch()
1576 MachineBasicBlock *MBB1 = *MBB->succ_begin(); in removeRedundantConditionalBranch()
1577 MachineBasicBlock *MBB2 = *std::next(MBB->succ_begin()); in removeRedundantConditionalBranch()
1581 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB); in removeRedundantConditionalBranch()
1586 MBB->removeSuccessor(MBB1, true); in removeRedundantConditionalBranch()
1595 for (MachineBasicBlock *MBB : RetMBB) { in addDummyExitBlock()
1596 if (MachineInstr *MI = getReturnInstr(MBB)) in addDummyExitBlock()
1598 MBB->addSuccessor(DummyExitBlk); in addDummyExitBlock()
1599 LLVM_DEBUG(dbgs() << "Add dummyExitBlock to BB" << MBB->getNumber() in addDummyExitBlock()
1605 void R600MachineCFGStructurizer::removeSuccessor(MachineBasicBlock *MBB) { in removeSuccessor() argument
1606 while (MBB->succ_size()) in removeSuccessor()
1607 MBB->removeSuccessor(*MBB->succ_begin()); in removeSuccessor()
1610 void R600MachineCFGStructurizer::recordSccnum(MachineBasicBlock *MBB, in recordSccnum() argument
1612 BlockInformation *&srcBlkInfo = BlockInfoMap[MBB]; in recordSccnum()
1618 void R600MachineCFGStructurizer::retireBlock(MachineBasicBlock *MBB) { in retireBlock() argument
1619 LLVM_DEBUG(dbgs() << "Retiring BB" << MBB->getNumber() << "\n";); in retireBlock()
1621 BlockInformation *&SrcBlkInfo = BlockInfoMap[MBB]; in retireBlock()
1627 assert(MBB->succ_empty() && MBB->pred_empty() && "can't retire block yet"); in retireBlock()