Home | History | Annotate | Download | only in R600

Lines Matching full:mbb

206   int getSCCNum(MachineBasicBlock *MBB) const;
208 bool hasBackEdge(MachineBasicBlock *MBB) const;
210 bool isRetiredBlock(MachineBasicBlock *MBB) const;
211 bool isActiveLoophead(MachineBasicBlock *MBB) const;
216 bool needMigrateBlock(MachineBasicBlock *MBB) const;
224 void insertInstrEnd(MachineBasicBlock *MBB, int NewOpcode,
226 MachineInstr *insertInstrBefore(MachineBasicBlock *MBB, int NewOpcode,
231 void insertCondBranchBefore(MachineBasicBlock *MBB,
234 void insertCondBranchEnd(MachineBasicBlock *MBB, int NewOpcode, int RegNum);
240 static void setTrueBranch(MachineInstr *MI, MachineBasicBlock *MBB);
241 static MachineBasicBlock *getFalseBranch(MachineBasicBlock *MBB,
245 static DebugLoc getLastDebugLocInBB(MachineBasicBlock *MBB);
246 static MachineInstr *getNormalBlockBranchInstr(MachineBasicBlock *MBB);
251 MachineInstr *getLoopendBlockBranchInstr(MachineBasicBlock *MBB);
252 static MachineInstr *getReturnInstr(MachineBasicBlock *MBB);
253 static MachineInstr *getContinueInstr(MachineBasicBlock *MBB);
254 static bool isReturnBlock(MachineBasicBlock *MBB);
257 static MachineBasicBlock *clone(MachineBasicBlock *MBB);
263 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);
298 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB,
315 void removeUnconditionalBranch(MachineBasicBlock *MBB);
324 void removeRedundantConditionalBranch(MachineBasicBlock *MBB);
326 void removeSuccessor(MachineBasicBlock *MBB);
327 MachineBasicBlock *cloneBlockForPredecessor(MachineBasicBlock *MBB,
331 void recordSccnum(MachineBasicBlock *MBB, int SCCNum);
332 void retireBlock(MachineBasicBlock *MBB);
333 void setLoopLandBlock(MachineLoop *LoopRep, MachineBasicBlock *MBB = NULL);
349 int AMDGPUCFGStructurizer::getSCCNum(MachineBasicBlock *MBB) const {
350 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB);
364 bool AMDGPUCFGStructurizer::hasBackEdge(MachineBasicBlock *MBB) const {
365 MachineLoop *LoopRep = MLI->getLoopFor(MBB);
369 return MBB->isSuccessor(LoopHeader);
376 bool AMDGPUCFGStructurizer::isRetiredBlock(MachineBasicBlock *MBB) const {
377 MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB);
383 bool AMDGPUCFGStructurizer::isActiveLoophead(MachineBasicBlock *MBB) const {
384 MachineLoop *LoopRep = MLI->getLoopFor(MBB);
385 while (LoopRep && LoopRep->getHeader() == MBB) {
424 bool AMDGPUCFGStructurizer::needMigrateBlock(MachineBasicBlock *MBB) const {
427 bool MultiplePreds = MBB && (MBB->pred_size() > 1);
431 unsigned BlkSize = MBB->size();
433 (BlkSize * (MBB->pred_size() - 1) > CloneInstrThreshold));
464 void AMDGPUCFGStructurizer::insertInstrEnd(MachineBasicBlock *MBB,
466 MBB->getParent()
468 MBB->push_back(MI);
473 MachineInstr *AMDGPUCFGStructurizer::insertInstrBefore(MachineBasicBlock *MBB,
476 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DL);
477 if (MBB->begin() != MBB->end())
478 MBB->insert(MBB->begin(), MI);
480 MBB->push_back(MI);
488 MachineBasicBlock *MBB = OldMI->getParent();
490 MBB->getParent()->CreateMachineInstr(TII->get(NewOpcode), DebugLoc());
491 MBB->insert(I, NewMBB);
500 MachineBasicBlock *MBB = OldMI->getParent();
501 MachineFunction *MF = MBB->getParent();
503 MBB->insert(I, NewMI);
521 void AMDGPUCFGStructurizer::insertCondBranchEnd(MachineBasicBlock *MBB,
523 MachineFunction *MF = MBB->getParent();
526 MBB->push_back(NewInstr);
576 MachineBasicBlock *MBB) {
577 MI->getOperand(0).setMBB(MBB);
581 AMDGPUCFGStructurizer::getFalseBranch(MachineBasicBlock *MBB,
583 assert(MBB->succ_size() == 2);
585 MachineBasicBlock::succ_iterator It = MBB->succ_begin();
613 DebugLoc AMDGPUCFGStructurizer::getLastDebugLocInBB(MachineBasicBlock *MBB) {
616 for (MachineBasicBlock::iterator It = MBB->begin(); It != MBB->end();
626 MachineBasicBlock *MBB) {
627 MachineBasicBlock::reverse_iterator It = MBB->rbegin();
635 MachineBasicBlock *MBB) {
636 for (MachineBasicBlock::reverse_iterator It = MBB->rbegin(), E = MBB->rend();
650 MachineInstr *AMDGPUCFGStructurizer::getReturnInstr(MachineBasicBlock *MBB) {
651 MachineBasicBlock::reverse_iterator It = MBB->rbegin();
652 if (It != MBB->rend()) {
660 MachineInstr *AMDGPUCFGStructurizer::getContinueInstr(MachineBasicBlock *MBB) {
661 MachineBasicBlock::reverse_iterator It = MBB->rbegin();
662 if (It != MBB->rend()) {
670 bool AMDGPUCFGStructurizer::isReturnBlock(MachineBasicBlock *MBB) {
671 MachineInstr *MI = getReturnInstr(MBB);
672 bool IsReturn = (MBB->succ_size() == 0);
677 dbgs() << "BB" << MBB->getNumber()
689 MachineBasicBlock *AMDGPUCFGStructurizer::clone(MachineBasicBlock *MBB) {
690 MachineFunction *Func = MBB->getParent();
693 for (MachineBasicBlock::iterator It = MBB->begin(), E = MBB->end();
710 void AMDGPUCFGStructurizer::wrapup(MachineBasicBlock *MBB) {
711 assert((!MBB->getParent()->getJumpTableInfo()
712 || MBB->getParent()->getJumpTableInfo()->isEmpty())
717 MachineBasicBlock::iterator Pre = MBB->begin();
718 MachineBasicBlock::iterator E = MBB->end();
769 MachineBasicBlock *MBB = *It;
770 removeUnconditionalBranch(MBB);
771 removeRedundantConditionalBranch(MBB);
772 if (isReturnBlock(MBB)) {
773 RetBlks.push_back(MBB);
775 assert(MBB->succ_size() <= 2);
799 MachineBasicBlock *MBB;
824 MBB = *It;
828 SccBeginMBB = MBB;
837 if (!isRetiredBlock(MBB))
838 patternMatch(MBB);
850 dbgs() << "Can't reduce SCC " << getSCCNum(MBB)
860 dbgs() << "repeat processing SCC" << getSCCNum(MBB)
932 MachineBasicBlock *MBB;
939 MBB = *blockIter;
940 OrderedBlks.push_back(MBB);
941 recordSccnum(MBB, SccNum);
949 MachineBasicBlock *MBB = &(*It);
950 SccNum = getSCCNum(MBB);
952 dbgs() << "unreachable block BB" << MBB->getNumber() << "\n";
956 int AMDGPUCFGStructurizer::patternMatch(MachineBasicBlock *MBB) {
961 dbgs() << "Begin patternMatch BB" << MBB->getNumber() << "\n";
964 while ((CurMatch = patternMatchGroup(MBB)) > 0)
968 dbgs() << "End patternMatch BB" << MBB->getNumber()
975 int AMDGPUCFGStructurizer::patternMatchGroup(MachineBasicBlock *MBB) {
978 NumMatch += serialPatternMatch(MBB);
979 NumMatch += ifPatternMatch(MBB);
984 int AMDGPUCFGStructurizer::serialPatternMatch(MachineBasicBlock *MBB) {
985 if (MBB->succ_size() != 1)
988 MachineBasicBlock *childBlk = *MBB->succ_begin();
992 mergeSerialBlock(MBB, childBlk);
997 int AMDGPUCFGStructurizer::ifPatternMatch(MachineBasicBlock *MBB) {
999 if (MBB->succ_size() != 2)
1001 if (hasBackEdge(MBB))
1003 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB);
1012 MachineBasicBlock *FalseMBB = getFalseBranch(MBB, BranchMI);
1033 reversePredicateSetter(MBB->end());
1043 return handleJumpintoIf(MBB, TrueMBB, FalseMBB);
1052 Cloned += improveSimpleJumpintoIf(MBB, TrueMBB, FalseMBB, &LandBlk);
1056 TrueMBB = cloneBlockForPredecessor(TrueMBB, MBB);
1061 FalseMBB = cloneBlockForPredecessor(FalseMBB, MBB);
1065 mergeIfthenelseBlock(BranchMI, MBB, TrueMBB, FalseMBB, LandBlk);
1155 MachineBasicBlock *MBB = *It;
1156 if (LoopRep->contains(MBB)) {
1157 handleLoopcontBlock(MBB, MLI->getLoopFor(MBB),
1159 ContMBB.push_back(MBB);
1405 MachineBasicBlock *MBB = *PI;
1406 if (MBB != TrueMBB && MBB != FalseMBB)
1449 MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB,
1453 dbgs() << "ifPattern BB" << MBB->getNumber();
1489 MBB->splice(I, TrueMBB, TrueMBB->begin(), TrueMBB->end());
1490 MBB->removeSuccessor(TrueMBB);
1499 MBB->splice(I, FalseMBB, FalseMBB->begin(),
1501 MBB->removeSuccessor(FalseMBB);
1512 MBB->addSuccessor(LandMBB);
1610 AMDGPUCFGStructurizer::cloneBlockForPredecessor(MachineBasicBlock *MBB,
1612 assert(PredMBB->isSuccessor(MBB) &&
1615 MachineBasicBlock *CloneMBB = clone(MBB); //clone instructions
1616 replaceInstrUseOfBlockWith(PredMBB, MBB, CloneMBB);
1619 PredMBB->removeSuccessor(MBB);
1623 cloneSuccessorList(CloneMBB, MBB);
1625 numClonedInstr += MBB->size();
1629 << MBB->getNumber() << "size " << MBB->size() << "\n";
1699 void AMDGPUCFGStructurizer::removeUnconditionalBranch(MachineBasicBlock *MBB) {
1704 while ((BranchMI = getLoopendBlockBranchInstr(MBB))
1712 MachineBasicBlock *MBB) {
1713 if (MBB->succ_size() != 2)
1715 MachineBasicBlock *MBB1 = *MBB->succ_begin();
1716 MachineBasicBlock *MBB2 = *(++MBB->succ_begin());
1720 MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB);
1725 MBB->removeSuccessor(MBB1);
1736 MachineBasicBlock *MBB = *It;
1737 MachineInstr *MI = getReturnInstr(MBB);
1740 MBB->addSuccessor(DummyExitBlk);
1742 dbgs() << "Add dummyExitBlock to BB" << MBB->getNumber()
1749 void AMDGPUCFGStructurizer::removeSuccessor(MachineBasicBlock *MBB) {
1750 while (MBB->succ_size())
1751 MBB->removeSuccessor(*MBB->succ_begin());
1754 void AMDGPUCFGStructurizer::recordSccnum(MachineBasicBlock *MBB,
1756 BlockInformation *&srcBlkInfo = BlockInfoMap[MBB];
1762 void AMDGPUCFGStructurizer::retireBlock(MachineBasicBlock *MBB) {
1764 dbgs() << "Retiring BB" << MBB->getNumber() << "\n";
1767 BlockInformation *&SrcBlkInfo = BlockInfoMap[MBB];
1773 assert(MBB->succ_size() == 0 && MBB->pred_size() == 0
1778 MachineBasicBlock *MBB) {
1780 if (!MBB) {
1781 MBB = FuncRep->CreateMachineBasicBlock();
1782 FuncRep->push_back(MBB); //insert to function
1783 SHOWNEWBLK(MBB, "DummyLandingBlock for loop without break: ");
1785 TheEntry = MBB;
1789 << " landing-block = BB" << MBB->getNumber() << "\n";
1831 MachineBasicBlock *MBB = *It;
1832 if (MBB != CommonDom)
1833 CommonDom = findNearestCommonPostDom(MBB, CommonDom);