llvm.org GIT mirror llvm / b1a710d
Make analyzeBranch family of instruction names consistent analyzeBranch was renamed to use lowercase first, rename the related set to match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281506 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 3 years ago
47 changed file(s) with 101 addition(s) and 101 deletion(s). Raw diff Collapse all Expand all
461461 /// condition. These operands can be passed to other TargetInstrInfo
462462 /// methods to create new branches.
463463 ///
464 /// Note that RemoveBranch and InsertBranch must be implemented to support
464 /// Note that RemoveBranch and insertBranch must be implemented to support
465465 /// cases where this method returns success.
466466 ///
467467 /// If AllowModify is true, then this routine is allowed to modify the basic
544544 ///
545545 /// The CFG information in MBB.Predecessors and MBB.Successors must be valid
546546 /// before calling this function.
547 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
547 virtual unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
548548 MachineBasicBlock *FBB,
549549 ArrayRef Cond,
550550 const DebugLoc &DL,
551551 int *BytesAdded = nullptr) const {
552 llvm_unreachable("Target didn't implement TargetInstrInfo::InsertBranch!");
552 llvm_unreachable("Target didn't implement TargetInstrInfo::insertBranch!");
553553 }
554554
555555 unsigned insertUnconditionalBranch(MachineBasicBlock &MBB,
556556 MachineBasicBlock *DestBB,
557557 const DebugLoc &DL,
558558 int *BytesAdded = nullptr) const {
559 return InsertBranch(MBB, DestBB, nullptr,
559 return insertBranch(MBB, DestBB, nullptr,
560560 ArrayRef(), DL, BytesAdded);
561561 }
562562
516516 if (TBB == NextBB && !Cond.empty() && !FBB) {
517517 if (!TII->ReverseBranchCondition(Cond)) {
518518 TII->RemoveBranch(*CurMBB);
519 TII->InsertBranch(*CurMBB, SuccBB, nullptr, Cond, dl);
519 TII->insertBranch(*CurMBB, SuccBB, nullptr, Cond, dl);
520520 return;
521521 }
522522 }
523523 }
524 TII->InsertBranch(*CurMBB, SuccBB, nullptr,
524 TII->insertBranch(*CurMBB, SuccBB, nullptr,
525525 SmallVector(), dl);
526526 }
527527
11091109 TII->RemoveBranch(*PBB);
11101110 if (!Cond.empty())
11111111 // reinsert conditional branch only, for now
1112 TII->InsertBranch(*PBB, (TBB == IBB) ? FBB : TBB, nullptr,
1112 TII->insertBranch(*PBB, (TBB == IBB) ? FBB : TBB, nullptr,
11131113 NewCond, dl);
11141114 }
11151115
13281328 TII->RemoveBranch(PrevBB);
13291329 PriorCond.clear();
13301330 if (PriorTBB != MBB)
1331 TII->InsertBranch(PrevBB, PriorTBB, nullptr, PriorCond, dl);
1331 TII->insertBranch(PrevBB, PriorTBB, nullptr, PriorCond, dl);
13321332 MadeChange = true;
13331333 ++NumBranchOpts;
13341334 goto ReoptimizeBlock;
13841384 if (PriorFBB == MBB) {
13851385 DebugLoc dl = getBranchDebugLoc(PrevBB);
13861386 TII->RemoveBranch(PrevBB);
1387 TII->InsertBranch(PrevBB, PriorTBB, nullptr, PriorCond, dl);
1387 TII->insertBranch(PrevBB, PriorTBB, nullptr, PriorCond, dl);
13881388 MadeChange = true;
13891389 ++NumBranchOpts;
13901390 goto ReoptimizeBlock;
13981398 if (!TII->ReverseBranchCondition(NewPriorCond)) {
13991399 DebugLoc dl = getBranchDebugLoc(PrevBB);
14001400 TII->RemoveBranch(PrevBB);
1401 TII->InsertBranch(PrevBB, PriorFBB, nullptr, NewPriorCond, dl);
1401 TII->insertBranch(PrevBB, PriorFBB, nullptr, NewPriorCond, dl);
14021402 MadeChange = true;
14031403 ++NumBranchOpts;
14041404 goto ReoptimizeBlock;
14361436
14371437 DebugLoc dl = getBranchDebugLoc(PrevBB);
14381438 TII->RemoveBranch(PrevBB);
1439 TII->InsertBranch(PrevBB, MBB, nullptr, NewPriorCond, dl);
1439 TII->insertBranch(PrevBB, MBB, nullptr, NewPriorCond, dl);
14401440
14411441 // Move this block to the end of the function.
14421442 MBB->moveAfter(&MF.back());
15031503 if (!TII->ReverseBranchCondition(NewCond)) {
15041504 DebugLoc dl = getBranchDebugLoc(*MBB);
15051505 TII->RemoveBranch(*MBB);
1506 TII->InsertBranch(*MBB, CurFBB, CurTBB, NewCond, dl);
1506 TII->insertBranch(*MBB, CurFBB, CurTBB, NewCond, dl);
15071507 MadeChange = true;
15081508 ++NumBranchOpts;
15091509 goto ReoptimizeBlock;
15511551 }
15521552 DebugLoc pdl = getBranchDebugLoc(PrevBB);
15531553 TII->RemoveBranch(PrevBB);
1554 TII->InsertBranch(PrevBB, PriorTBB, PriorFBB, PriorCond, pdl);
1554 TII->insertBranch(PrevBB, PriorTBB, PriorFBB, PriorCond, pdl);
15551555 }
15561556
15571557 // Iterate through all the predecessors, revectoring each in-turn.
15781578 DebugLoc pdl = getBranchDebugLoc(*PMBB);
15791579 TII->RemoveBranch(*PMBB);
15801580 NewCurCond.clear();
1581 TII->InsertBranch(*PMBB, NewCurTBB, nullptr, NewCurCond, pdl);
1581 TII->insertBranch(*PMBB, NewCurTBB, nullptr, NewCurCond, pdl);
15821582 MadeChange = true;
15831583 ++NumBranchOpts;
15841584 PMBB->CorrectExtraCFGEdges(NewCurTBB, nullptr, false);
15981598 }
15991599
16001600 // Add the branch back if the block is more than just an uncond branch.
1601 TII->InsertBranch(*MBB, CurTBB, nullptr, CurCond, dl);
1601 TII->insertBranch(*MBB, CurTBB, nullptr, CurCond, dl);
16021602 }
16031603 }
16041604
16351635 if (CurFallsThru) {
16361636 MachineBasicBlock *NextBB = &*std::next(MBB->getIterator());
16371637 CurCond.clear();
1638 TII->InsertBranch(*MBB, NextBB, nullptr, CurCond, DebugLoc());
1638 TII->insertBranch(*MBB, NextBB, nullptr, CurCond, DebugLoc());
16391639 }
16401640 MBB->moveAfter(PredBB);
16411641 MadeChange = true;
573573 // We need a branch to Tail, let code placement work it out later.
574574 DEBUG(dbgs() << "Converting to unconditional branch.\n");
575575 SmallVector EmptyCond;
576 TII->InsertBranch(*Head, Tail, nullptr, EmptyCond, HeadDL);
576 TII->insertBranch(*Head, Tail, nullptr, EmptyCond, HeadDL);
577577 Head->addSuccessor(Tail);
578578 }
579579 DEBUG(dbgs() << *Head);
504504 DebugLoc dl; // FIXME: this is nowhere
505505 if (!TII->ReverseBranchCondition(BBI.BrCond)) {
506506 TII->RemoveBranch(*BBI.BB);
507 TII->InsertBranch(*BBI.BB, BBI.FalseBB, BBI.TrueBB, BBI.BrCond, dl);
507 TII->insertBranch(*BBI.BB, BBI.FalseBB, BBI.TrueBB, BBI.BrCond, dl);
508508 std::swap(BBI.TrueBB, BBI.FalseBB);
509509 return true;
510510 }
13931393 const TargetInstrInfo *TII) {
13941394 DebugLoc dl; // FIXME: this is nowhere
13951395 SmallVector NoCond;
1396 TII->InsertBranch(MBB, &ToMBB, nullptr, NoCond, dl);
1396 TII->insertBranch(MBB, &ToMBB, nullptr, NoCond, dl);
13971397 }
13981398
13991399 /// Remove true / false edges if either / both are no longer successors.
16661666 BBI.BB->setSuccProbability(NewTrueBBIter, NewNext);
16671667
16681668 auto NewFalse = BBCvt * CvtFalse;
1669 TII->InsertBranch(*BBI.BB, CvtBBI->FalseBB, nullptr, RevCond, dl);
1669 TII->insertBranch(*BBI.BB, CvtBBI->FalseBB, nullptr, RevCond, dl);
16701670 BBI.BB->addSuccessor(CvtBBI->FalseBB, NewFalse);
16711671 }
16721672
19501950
19511951 // Add back the branch.
19521952 // Debug location saved above when removing the branch from BBI2
1953 TII->InsertBranch(*BBI.BB, TrueBBI.TrueBB, TrueBBI.FalseBB,
1953 TII->insertBranch(*BBI.BB, TrueBBI.TrueBB, TrueBBI.FalseBB,
19541954 TrueBBI.BrCond, dl);
19551955
19561956 RemoveExtraEdges(BBI);
559559 NC.getCheckOperation()->eraseFromParent();
560560
561561 // Insert an *unconditional* branch to not-null successor.
562 TII->InsertBranch(*NC.getCheckBlock(), NC.getNotNullSucc(), nullptr,
562 TII->insertBranch(*NC.getCheckBlock(), NC.getNotNullSucc(), nullptr,
563563 /*Cond=*/None, DL);
564564
565565 NumImplicitNullChecks++;
435435 // Finally update the unconditional successor to be reached via a branch
436436 // if it would not be reached by fallthrough.
437437 if (!isLayoutSuccessor(TBB))
438 TII->InsertBranch(*this, TBB, nullptr, Cond, DL);
438 TII->insertBranch(*this, TBB, nullptr, Cond, DL);
439439 }
440440 return;
441441 }
448448 if (TII->ReverseBranchCondition(Cond))
449449 return;
450450 TII->RemoveBranch(*this);
451 TII->InsertBranch(*this, FBB, nullptr, Cond, DL);
451 TII->insertBranch(*this, FBB, nullptr, Cond, DL);
452452 } else if (isLayoutSuccessor(FBB)) {
453453 TII->RemoveBranch(*this);
454 TII->InsertBranch(*this, TBB, nullptr, Cond, DL);
454 TII->insertBranch(*this, TBB, nullptr, Cond, DL);
455455 }
456456 return;
457457 }
478478 // Finally update the unconditional successor to be reached via a branch if
479479 // it would not be reached by fallthrough.
480480 if (!isLayoutSuccessor(TBB))
481 TII->InsertBranch(*this, TBB, nullptr, Cond, DL);
481 TII->insertBranch(*this, TBB, nullptr, Cond, DL);
482482 return;
483483 }
484484
487487 // change the conditional branch into unconditional branch.
488488 TII->RemoveBranch(*this);
489489 Cond.clear();
490 TII->InsertBranch(*this, TBB, nullptr, Cond, DL);
490 TII->insertBranch(*this, TBB, nullptr, Cond, DL);
491491 return;
492492 }
493493
496496 if (TII->ReverseBranchCondition(Cond)) {
497497 // We can't reverse the condition, add an unconditional branch.
498498 Cond.clear();
499 TII->InsertBranch(*this, FallthroughBB, nullptr, Cond, DL);
499 TII->insertBranch(*this, FallthroughBB, nullptr, Cond, DL);
500500 return;
501501 }
502502 TII->RemoveBranch(*this);
503 TII->InsertBranch(*this, FallthroughBB, nullptr, Cond, DL);
503 TII->insertBranch(*this, FallthroughBB, nullptr, Cond, DL);
504504 } else if (!isLayoutSuccessor(FallthroughBB)) {
505505 TII->RemoveBranch(*this);
506 TII->InsertBranch(*this, TBB, FallthroughBB, Cond, DL);
506 TII->insertBranch(*this, TBB, FallthroughBB, Cond, DL);
507507 }
508508 }
509509
809809 if (!NMBB->isLayoutSuccessor(Succ)) {
810810 SmallVector Cond;
811811 const TargetInstrInfo *TII = getParent()->getSubtarget().getInstrInfo();
812 TII->InsertBranch(*NMBB, Succ, nullptr, Cond, DL);
812 TII->insertBranch(*NMBB, Succ, nullptr, Cond, DL);
813813
814814 if (Indexes) {
815815 for (MachineInstr &MI : NMBB->instrs()) {
16421642 << MBPI->getEdgeProbability(ChainBB, TBB) << "\n");
16431643 DebugLoc dl; // FIXME: this is nowhere
16441644 TII->RemoveBranch(*ChainBB);
1645 TII->InsertBranch(*ChainBB, FBB, TBB, Cond, dl);
1645 TII->insertBranch(*ChainBB, FBB, TBB, Cond, dl);
16461646 ChainBB->updateTerminator();
16471647 }
16481648 }
23652365 unsigned numBranches = TII->RemoveBranch(*PreheaderBB);
23662366 if (numBranches) {
23672367 SmallVector Cond;
2368 TII->InsertBranch(*PreheaderBB, PrologBBs[0], nullptr, Cond, DebugLoc());
2368 TII->insertBranch(*PreheaderBB, PrologBBs[0], nullptr, Cond, DebugLoc());
23692369 }
23702370 }
23712371
24522452 // Create a branch to the new epilog from the kernel.
24532453 // Remove the original branch and add a new branch to the epilog.
24542454 TII->RemoveBranch(*KernelBB);
2455 TII->InsertBranch(*KernelBB, KernelBB, EpilogStart, Cond, DebugLoc());
2455 TII->insertBranch(*KernelBB, KernelBB, EpilogStart, Cond, DebugLoc());
24562456 // Add a branch to the loop exit.
24572457 if (EpilogBBs.size() > 0) {
24582458 MachineBasicBlock *LastEpilogBB = EpilogBBs.back();
24592459 SmallVector Cond1;
2460 TII->InsertBranch(*LastEpilogBB, LoopExitBB, nullptr, Cond1, DebugLoc());
2460 TII->insertBranch(*LastEpilogBB, LoopExitBB, nullptr, Cond1, DebugLoc());
24612461 }
24622462 }
24632463
30123012 unsigned numAdded = 0;
30133013 if (TargetRegisterInfo::isVirtualRegister(LC)) {
30143014 Prolog->addSuccessor(Epilog);
3015 numAdded = TII->InsertBranch(*Prolog, Epilog, LastPro, Cond, DebugLoc());
3015 numAdded = TII->insertBranch(*Prolog, Epilog, LastPro, Cond, DebugLoc());
30163016 } else if (j >= LCMin) {
30173017 Prolog->addSuccessor(Epilog);
30183018 Prolog->removeSuccessor(LastPro);
30193019 LastEpi->removeSuccessor(Epilog);
3020 numAdded = TII->InsertBranch(*Prolog, Epilog, nullptr, Cond, DebugLoc());
3020 numAdded = TII->insertBranch(*Prolog, Epilog, nullptr, Cond, DebugLoc());
30213021 removePhis(Epilog, LastEpi);
30223022 // Remove the blocks that are no longer referenced.
30233023 if (LastPro != LastEpi) {
30273027 LastPro->clear();
30283028 LastPro->eraseFromParent();
30293029 } else {
3030 numAdded = TII->InsertBranch(*Prolog, LastPro, nullptr, Cond, DebugLoc());
3030 numAdded = TII->insertBranch(*Prolog, LastPro, nullptr, Cond, DebugLoc());
30313031 removePhis(Epilog, Prolog);
30323032 }
30333033 LastPro = Prolog;
14451445 // fall-through case, which needs no instructions.
14461446 } else {
14471447 // The unconditional branch case.
1448 TII.InsertBranch(*FuncInfo.MBB, MSucc, nullptr,
1448 TII.insertBranch(*FuncInfo.MBB, MSucc, nullptr,
14491449 SmallVector(), DbgLoc);
14501450 }
14511451 if (FuncInfo.BPI) {
725725 }
726726
727727 if (PredTBB)
728 TII->InsertBranch(*PredBB, PredTBB, PredFBB, PredCond, DebugLoc());
728 TII->insertBranch(*PredBB, PredTBB, PredFBB, PredCond, DebugLoc());
729729
730730 TDBBs.push_back(PredBB);
731731 }
118118
119119 // If MBB isn't immediately before MBB, insert a branch to it.
120120 if (++MachineFunction::iterator(MBB) != MachineFunction::iterator(NewDest))
121 InsertBranch(*MBB, NewDest, nullptr, SmallVector(), DL);
121 insertBranch(*MBB, NewDest, nullptr, SmallVector(), DL);
122122 MBB->addSuccessor(NewDest);
123123 }
124124
302302 TII->ReverseBranchCondition(Cond);
303303 int OldSize = 0, NewSize = 0;
304304 TII->RemoveBranch(*MBB, &OldSize);
305 TII->InsertBranch(*MBB, FBB, TBB, Cond, DL, &NewSize);
305 TII->insertBranch(*MBB, FBB, TBB, Cond, DL, &NewSize);
306306
307307 BlockInfo[MBB->getNumber()].Size += (NewSize - OldSize);
308308 return true;
344344 MBBSize -= RemovedSize;
345345
346346 int AddedSize = 0;
347 TII->InsertBranch(*MBB, &NextBB, TBB, Cond, DL, &AddedSize);
347 TII->insertBranch(*MBB, &NextBB, TBB, Cond, DL, &AddedSize);
348348 MBBSize += AddedSize;
349349
350350 // Finally, keep the block offsets up to date.
349349 }
350350 }
351351
352 unsigned AArch64InstrInfo::InsertBranch(MachineBasicBlock &MBB,
352 unsigned AArch64InstrInfo::insertBranch(MachineBasicBlock &MBB,
353353 MachineBasicBlock *TBB,
354354 MachineBasicBlock *FBB,
355355 ArrayRef Cond,
356356 const DebugLoc &DL,
357357 int *BytesAdded) const {
358358 // Shouldn't be a fall through.
359 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
359 assert(TBB && "insertBranch must not be told to insert a fallthrough");
360360
361361 if (!FBB) {
362362 if (Cond.empty()) // Unconditional branch?
184184 bool AllowModify = false) const override;
185185 unsigned RemoveBranch(MachineBasicBlock &MBB,
186186 int *BytesRemoved = nullptr) const override;
187 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
187 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
188188 MachineBasicBlock *FBB, ArrayRef Cond,
189189 const DebugLoc &DL,
190190 int *BytesAdded = nullptr) const override;
730730 return MBB.end();
731731 }
732732
733 unsigned R600InstrInfo::InsertBranch(MachineBasicBlock &MBB,
733 unsigned R600InstrInfo::insertBranch(MachineBasicBlock &MBB,
734734 MachineBasicBlock *TBB,
735735 MachineBasicBlock *FBB,
736736 ArrayRef Cond,
737737 const DebugLoc &DL,
738738 int *BytesAdded) const {
739 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
739 assert(TBB && "insertBranch must not be told to insert a fallthrough");
740740 assert(!BytesAdded && "code size not handled");
741741
742742 if (!FBB) {
166166 SmallVectorImpl &Cond,
167167 bool AllowModify) const override;
168168
169 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
169 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
170170 MachineBasicBlock *FBB, ArrayRef Cond,
171171 const DebugLoc &DL,
172172 int *BytesAdded = nullptr) const override;
11241124 return Count;
11251125 }
11261126
1127 unsigned SIInstrInfo::InsertBranch(MachineBasicBlock &MBB,
1127 unsigned SIInstrInfo::insertBranch(MachineBasicBlock &MBB,
11281128 MachineBasicBlock *TBB,
11291129 MachineBasicBlock *FBB,
11301130 ArrayRef Cond,
165165 unsigned RemoveBranch(MachineBasicBlock &MBB,
166166 int *BytesRemoved = nullptr) const override;
167167
168 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
168 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
169169 MachineBasicBlock *FBB, ArrayRef Cond,
170170 const DebugLoc &DL,
171171 int *BytesAdded = nullptr) const override;
408408 return 2;
409409 }
410410
411 unsigned ARMBaseInstrInfo::InsertBranch(MachineBasicBlock &MBB,
411 unsigned ARMBaseInstrInfo::insertBranch(MachineBasicBlock &MBB,
412412 MachineBasicBlock *TBB,
413413 MachineBasicBlock *FBB,
414414 ArrayRef Cond,
423423 bool isThumb = AFI->isThumbFunction() || AFI->isThumb2Function();
424424
425425 // Shouldn't be a fall through.
426 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
426 assert(TBB && "insertBranch must not be told to insert a fallthrough");
427427 assert((Cond.size() == 2 || Cond.size() == 0) &&
428428 "ARM branch conditions have two components!");
429429
125125 bool AllowModify = false) const override;
126126 unsigned RemoveBranch(MachineBasicBlock &MBB,
127127 int *BytesRemoved = nullptr) const override;
128 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
128 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
129129 MachineBasicBlock *FBB, ArrayRef Cond,
130130 const DebugLoc &DL,
131131 int *BytesAdded = nullptr) const override;
372372 return false;
373373 }
374374
375 unsigned AVRInstrInfo::InsertBranch(MachineBasicBlock &MBB,
375 unsigned AVRInstrInfo::insertBranch(MachineBasicBlock &MBB,
376376 MachineBasicBlock *TBB,
377377 MachineBasicBlock *FBB,
378378 ArrayRef Cond,
381381 assert(!BytesAdded && "code size not handled");
382382
383383 // Shouldn't be a fall through.
384 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
384 assert(TBB && "insertBranch must not be told to insert a fallthrough");
385385 assert((Cond.size() == 1 || Cond.size() == 0) &&
386386 "AVR branch conditions have one component!");
387387
9393 MachineBasicBlock *&FBB,
9494 SmallVectorImpl &Cond,
9595 bool AllowModify = false) const override;
96 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
96 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
9797 MachineBasicBlock *FBB, ArrayRef Cond,
9898 const DebugLoc &DL,
9999 int *BytesAdded = nullptr) const override;
129129 return false;
130130 }
131131
132 unsigned BPFInstrInfo::InsertBranch(MachineBasicBlock &MBB,
132 unsigned BPFInstrInfo::insertBranch(MachineBasicBlock &MBB,
133133 MachineBasicBlock *TBB,
134134 MachineBasicBlock *FBB,
135135 ArrayRef Cond,
138138 assert(!BytesAdded && "code size not handled");
139139
140140 // Shouldn't be a fall through.
141 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
141 assert(TBB && "insertBranch must not be told to insert a fallthrough");
142142
143143 if (Cond.empty()) {
144144 // Unconditional branch
5050
5151 unsigned RemoveBranch(MachineBasicBlock &MBB,
5252 int *BytesRemoved = nullptr) const override;
53 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
53 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
5454 MachineBasicBlock *FBB, ArrayRef Cond,
5555 const DebugLoc &DL,
5656 int *BytesAdded = nullptr) const override;
12451245 if (LastI != LastMBB->end())
12461246 LastI = LastMBB->erase(LastI);
12471247 SmallVector Cond;
1248 TII->InsertBranch(*LastMBB, BranchTarget, nullptr, Cond, LastIDL);
1248 TII->insertBranch(*LastMBB, BranchTarget, nullptr, Cond, LastIDL);
12491249 }
12501250 } else {
12511251 // Conditional branch to loop start; just delete it.
19221922 (void)NotAnalyzed; // suppress compiler warning
19231923 assert (!NotAnalyzed && "Should be analyzable!");
19241924 if (TB != Header && (Tmp2.empty() || FB != Header))
1925 TII->InsertBranch(*PB, NewPH, nullptr, EmptyCond, DL);
1925 TII->insertBranch(*PB, NewPH, nullptr, EmptyCond, DL);
19261926 PB->ReplaceUsesOfBlockWith(Header, NewPH);
19271927 }
19281928 }
19341934 (void)LatchNotAnalyzed; // suppress compiler warning
19351935 assert (!LatchNotAnalyzed && "Should be analyzable!");
19361936 if (!TB && !FB)
1937 TII->InsertBranch(*Latch, Header, nullptr, EmptyCond, DL);
1937 TII->insertBranch(*Latch, Header, nullptr, EmptyCond, DL);
19381938
19391939 // Finally, the branch from the preheader to the header.
1940 TII->InsertBranch(*NewPH, Header, nullptr, EmptyCond, DL);
1940 TII->insertBranch(*NewPH, Header, nullptr, EmptyCond, DL);
19411941 NewPH->addSuccessor(Header);
19421942
19431943 MachineLoop *ParentLoop = L->getParentLoop();
559559 return Count;
560560 }
561561
562 unsigned HexagonInstrInfo::InsertBranch(MachineBasicBlock &MBB,
562 unsigned HexagonInstrInfo::insertBranch(MachineBasicBlock &MBB,
563563 MachineBasicBlock *TBB,
564564 MachineBasicBlock *FBB,
565565 ArrayRef Cond,
568568 unsigned BOpc = Hexagon::J2_jump;
569569 unsigned BccOpc = Hexagon::J2_jumpt;
570570 assert(validateBranchCond(Cond) && "Invalid branching condition");
571 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
571 assert(TBB && "insertBranch must not be told to insert a fallthrough");
572572 assert(!BytesAdded && "code size not handled");
573573
574574 // Check if ReverseBranchCondition has asked to reverse this branch
591591 MachineFunction::iterator(NewTBB) == ++MBB.getIterator()) {
592592 ReverseBranchCondition(Cond);
593593 RemoveBranch(MBB);
594 return InsertBranch(MBB, TBB, nullptr, Cond, DL);
594 return insertBranch(MBB, TBB, nullptr, Cond, DL);
595595 }
596596 BuildMI(&MBB, DL, get(BOpc)).addMBB(TBB);
597597 } else if (isEndLoopN(Cond[0].getImm())) {
7272 /// condition. These operands can be passed to other TargetInstrInfo
7373 /// methods to create new branches.
7474 ///
75 /// Note that RemoveBranch and InsertBranch must be implemented to support
75 /// Note that RemoveBranch and insertBranch must be implemented to support
7676 /// cases where this method returns success.
7777 ///
7878 /// If AllowModify is true, then this routine is allowed to modify the basic
9999 /// cases where AnalyzeBranch doesn't apply because there was no original
100100 /// branch to analyze. At least this much must be implemented, else tail
101101 /// merging needs to be disabled.
102 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
102 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
103103 MachineBasicBlock *FBB, ArrayRef Cond,
104104 const DebugLoc &DL,
105105 int *BytesAdded = nullptr) const override;
557557 // - FalseBlock is set to the destination if condition evaluates to false (it
558558 // is the nullptr if the branch is unconditional);
559559 // - condition is populated with machine operands needed to generate the branch
560 // to insert in InsertBranch;
560 // to insert in insertBranch;
561561 // Returns: false if branch could successfully be analyzed.
562562 bool LanaiInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
563563 MachineBasicBlock *&TrueBlock,
657657 // Insert the branch with condition specified in condition and given targets
658658 // (TrueBlock and FalseBlock). This function returns the number of machine
659659 // instructions inserted.
660 unsigned LanaiInstrInfo::InsertBranch(MachineBasicBlock &MBB,
660 unsigned LanaiInstrInfo::insertBranch(MachineBasicBlock &MBB,
661661 MachineBasicBlock *TrueBlock,
662662 MachineBasicBlock *FalseBlock,
663663 ArrayRef Condition,
664664 const DebugLoc &DL,
665665 int *BytesAdded) const {
666666 // Shouldn't be a fall through.
667 assert(TrueBlock && "InsertBranch must not be told to insert a fallthrough");
667 assert(TrueBlock && "insertBranch must not be told to insert a fallthrough");
668668 assert(!BytesAdded && "code size not handled");
669669
670670 // If condition is empty then an unconditional branch is being inserted.
132132 bool ReverseBranchCondition(
133133 SmallVectorImpl &Condition) const override;
134134
135 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TrueBlock,
135 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TrueBlock,
136136 MachineBasicBlock *FalseBlock,
137137 ArrayRef Condition,
138138 const DebugLoc &DL,
262262 return false;
263263 }
264264
265 unsigned MSP430InstrInfo::InsertBranch(MachineBasicBlock &MBB,
265 unsigned MSP430InstrInfo::insertBranch(MachineBasicBlock &MBB,
266266 MachineBasicBlock *TBB,
267267 MachineBasicBlock *FBB,
268268 ArrayRef Cond,
269269 const DebugLoc &DL,
270270 int *BytesAdded) const {
271271 // Shouldn't be a fall through.
272 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
272 assert(TBB && "insertBranch must not be told to insert a fallthrough");
273273 assert((Cond.size() == 1 || Cond.size() == 0) &&
274274 "MSP430 branch conditions have one component!");
275275 assert(!BytesAdded && "code size not handled");
8080
8181 unsigned RemoveBranch(MachineBasicBlock &MBB,
8282 int *BytesRemoved = nullptr) const override;
83 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
83 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
8484 MachineBasicBlock *FBB, ArrayRef Cond,
8585 const DebugLoc &DL,
8686 int *BytesAdded = nullptr) const override;
112112 MIB.addMBB(TBB);
113113 }
114114
115 unsigned MipsInstrInfo::InsertBranch(MachineBasicBlock &MBB,
115 unsigned MipsInstrInfo::insertBranch(MachineBasicBlock &MBB,
116116 MachineBasicBlock *TBB,
117117 MachineBasicBlock *FBB,
118118 ArrayRef Cond,
119119 const DebugLoc &DL,
120120 int *BytesAdded) const {
121121 // Shouldn't be a fall through.
122 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
122 assert(TBB && "insertBranch must not be told to insert a fallthrough");
123123 assert(!BytesAdded && "code size not handled");
124124
125125 // # of condition operands:
5757 unsigned RemoveBranch(MachineBasicBlock &MBB,
5858 int *BytesRemoved = nullptr) const override;
5959
60 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
60 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
6161 MachineBasicBlock *FBB, ArrayRef Cond,
6262 const DebugLoc &DL,
6363 int *BytesAdded = nullptr) const override;
142142 /// operands can be passed to other TargetInstrInfo methods to create new
143143 /// branches.
144144 ///
145 /// Note that RemoveBranch and InsertBranch must be implemented to support
145 /// Note that RemoveBranch and insertBranch must be implemented to support
146146 /// cases where this method returns success.
147147 ///
148148 bool NVPTXInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
230230 return 2;
231231 }
232232
233 unsigned NVPTXInstrInfo::InsertBranch(MachineBasicBlock &MBB,
233 unsigned NVPTXInstrInfo::insertBranch(MachineBasicBlock &MBB,
234234 MachineBasicBlock *TBB,
235235 MachineBasicBlock *FBB,
236236 ArrayRef Cond,
239239 assert(!BytesAdded && "code size not handled");
240240
241241 // Shouldn't be a fall through.
242 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
242 assert(TBB && "insertBranch must not be told to insert a fallthrough");
243243 assert((Cond.size() == 1 || Cond.size() == 0) &&
244244 "NVPTX branch conditions have two components!");
245245
6464 bool AllowModify) const override;
6565 unsigned RemoveBranch(MachineBasicBlock &MBB,
6666 int *BytesRemoved = nullptr) const override;
67 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
67 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
6868 MachineBasicBlock *FBB, ArrayRef Cond,
6969 const DebugLoc &DL,
7070 int *BytesAdded = nullptr) const override;
636636 return 2;
637637 }
638638
639 unsigned PPCInstrInfo::InsertBranch(MachineBasicBlock &MBB,
639 unsigned PPCInstrInfo::insertBranch(MachineBasicBlock &MBB,
640640 MachineBasicBlock *TBB,
641641 MachineBasicBlock *FBB,
642642 ArrayRef Cond,
643643 const DebugLoc &DL,
644644 int *BytesAdded) const {
645645 // Shouldn't be a fall through.
646 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
646 assert(TBB && "insertBranch must not be told to insert a fallthrough");
647647 assert((Cond.size() == 2 || Cond.size() == 0) &&
648648 "PPC branch conditions have two components!");
649649 assert(!BytesAdded && "code size not handled");
169169 bool AllowModify) const override;
170170 unsigned RemoveBranch(MachineBasicBlock &MBB,
171171 int *BytesRemoved = nullptr) const override;
172 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
172 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
173173 MachineBasicBlock *FBB, ArrayRef Cond,
174174 const DebugLoc &DL,
175175 int *BytesAdded = nullptr) const override;
239239 return true;
240240 }
241241
242 unsigned SparcInstrInfo::InsertBranch(MachineBasicBlock &MBB,
242 unsigned SparcInstrInfo::insertBranch(MachineBasicBlock &MBB,
243243 MachineBasicBlock *TBB,
244244 MachineBasicBlock *FBB,
245245 ArrayRef Cond,
246246 const DebugLoc &DL,
247247 int *BytesAdded) const {
248 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
248 assert(TBB && "insertBranch must not be told to insert a fallthrough");
249249 assert((Cond.size() == 1 || Cond.size() == 0) &&
250250 "Sparc branch conditions should have one component!");
251251 assert(!BytesAdded && "code size not handled");
7272 unsigned RemoveBranch(MachineBasicBlock &MBB,
7373 int *BytesRemoved = nullptr) const override;
7474
75 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
75 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
7676 MachineBasicBlock *FBB, ArrayRef Cond,
7777 const DebugLoc &DL,
7878 int *BytesAdded = nullptr) const override;
394394 return false;
395395 }
396396
397 unsigned SystemZInstrInfo::InsertBranch(MachineBasicBlock &MBB,
397 unsigned SystemZInstrInfo::insertBranch(MachineBasicBlock &MBB,
398398 MachineBasicBlock *TBB,
399399 MachineBasicBlock *FBB,
400400 ArrayRef Cond,
405405 // in the pipeline, if desired.
406406
407407 // Shouldn't be a fall through.
408 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
408 assert(TBB && "insertBranch must not be told to insert a fallthrough");
409409 assert((Cond.size() == 2 || Cond.size() == 0) &&
410410 "SystemZ branch conditions have one component!");
411411 assert(!BytesAdded && "code size not handled");
165165 bool AllowModify) const override;
166166 unsigned RemoveBranch(MachineBasicBlock &MBB,
167167 int *BytesRemoved = nullptr) const override;
168 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
168 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
169169 MachineBasicBlock *FBB, ArrayRef Cond,
170170 const DebugLoc &DL,
171171 int *BytesAdded = nullptr) const override;
163163 return Count;
164164 }
165165
166 unsigned WebAssemblyInstrInfo::InsertBranch(MachineBasicBlock &MBB,
166 unsigned WebAssemblyInstrInfo::insertBranch(MachineBasicBlock &MBB,
167167 MachineBasicBlock *TBB,
168168 MachineBasicBlock *FBB,
169169 ArrayRef Cond,
4949 bool AllowModify = false) const override;
5050 unsigned RemoveBranch(MachineBasicBlock &MBB,
5151 int *BytesRemoved = nullptr) const override;
52 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
52 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
5353 MachineBasicBlock *FBB, ArrayRef Cond,
5454 const DebugLoc &DL,
5555 int *BytesAdded = nullptr) const override;
44634463 return Count;
44644464 }
44654465
4466 unsigned X86InstrInfo::InsertBranch(MachineBasicBlock &MBB,
4466 unsigned X86InstrInfo::insertBranch(MachineBasicBlock &MBB,
44674467 MachineBasicBlock *TBB,
44684468 MachineBasicBlock *FBB,
44694469 ArrayRef Cond,
44704470 const DebugLoc &DL,
44714471 int *BytesAdded) const {
44724472 // Shouldn't be a fall through.
4473 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
4473 assert(TBB && "insertBranch must not be told to insert a fallthrough");
44744474 assert((Cond.size() == 1 || Cond.size() == 0) &&
44754475 "X86 branch conditions have one component!");
44764476 assert(!BytesAdded && "code size not handled");
336336
337337 unsigned RemoveBranch(MachineBasicBlock &MBB,
338338 int *BytesRemoved = nullptr) const override;
339 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
339 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
340340 MachineBasicBlock *FBB, ArrayRef Cond,
341341 const DebugLoc &DL,
342342 int *BytesAdded = nullptr) const override;
183183 /// operands can be passed to other TargetInstrInfo methods to create new
184184 /// branches.
185185 ///
186 /// Note that RemoveBranch and InsertBranch must be implemented to support
186 /// Note that RemoveBranch and insertBranch must be implemented to support
187187 /// cases where this method returns success.
188188 ///
189189 bool XCoreInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
268268 return true;
269269 }
270270
271 unsigned XCoreInstrInfo::InsertBranch(MachineBasicBlock &MBB,
271 unsigned XCoreInstrInfo::insertBranch(MachineBasicBlock &MBB,
272272 MachineBasicBlock *TBB,
273273 MachineBasicBlock *FBB,
274274 ArrayRef Cond,
275275 const DebugLoc &DL,
276276 int *BytesAdded) const {
277277 // Shouldn't be a fall through.
278 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
278 assert(TBB && "insertBranch must not be told to insert a fallthrough");
279279 assert((Cond.size() == 2 || Cond.size() == 0) &&
280280 "Unexpected number of components!");
281281 assert(!BytesAdded && "code size not handled");
5454 SmallVectorImpl &Cond,
5555 bool AllowModify) const override;
5656
57 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
57 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
5858 MachineBasicBlock *FBB, ArrayRef Cond,
5959 const DebugLoc &DL,
6060 int *BytesAdded = nullptr) const override;