90#define DEBUG_TYPE "hexagon-eif"
97 cl::desc(
"Size limit in Hexagon early if-conversion"));
106 const MachineBasicBlock *MB;
110 return OS <<
"<none>";
111 return OS <<
'#' <<
P.MB->getNumber();
115 FlowPattern() =
default;
116 FlowPattern(MachineBasicBlock *
B,
unsigned PR, MachineBasicBlock *TB,
117 MachineBasicBlock *FB, MachineBasicBlock *JB)
118 : SplitB(
B), TrueB(
TB), FalseB(FB), JoinB(JB), PredR(PR) {}
120 MachineBasicBlock *SplitB =
nullptr;
121 MachineBasicBlock *TrueB =
nullptr;
122 MachineBasicBlock *FalseB =
nullptr;
123 MachineBasicBlock *JoinB =
nullptr;
128 PrintFP(
const FlowPattern &
P,
const TargetRegisterInfo &
T)
131 const FlowPattern &FP;
132 const TargetRegisterInfo &TRI;
133 friend raw_ostream &
operator<< (raw_ostream &OS,
const PrintFP &
P);
137 OS <<
"{ SplitB:" << PrintMB(
P.FP.SplitB)
139 <<
", TrueB:" << PrintMB(
P.FP.TrueB)
140 <<
", FalseB:" << PrintMB(
P.FP.FalseB)
141 <<
", JoinB:" << PrintMB(
P.FP.JoinB) <<
" }";
149 HexagonEarlyIfConversion() : MachineFunctionPass(ID) {}
151 StringRef getPassName()
const override {
152 return "Hexagon early if conversion";
155 void getAnalysisUsage(AnalysisUsage &AU)
const override {
156 AU.
addRequired<MachineBranchProbabilityInfoWrapperPass>();
163 bool runOnMachineFunction(MachineFunction &MF)
override;
166 using BlockSetType = DenseSet<MachineBasicBlock *>;
168 bool isPreheader(
const MachineBasicBlock *
B)
const;
169 bool matchFlowPattern(MachineBasicBlock *
B, MachineLoop *L,
171 bool visitBlock(MachineBasicBlock *
B, MachineLoop *L);
172 bool visitLoop(MachineLoop *L);
174 bool hasEHLabel(
const MachineBasicBlock *
B)
const;
175 bool hasUncondBranch(
const MachineBasicBlock *
B)
const;
176 bool isValidCandidate(
const MachineBasicBlock *
B)
const;
177 bool usesUndefVReg(
const MachineInstr *
MI)
const;
178 bool isValid(
const FlowPattern &
FP)
const;
179 unsigned countPredicateDefs(
const MachineBasicBlock *
B)
const;
180 unsigned computePhiCost(
const MachineBasicBlock *
B,
181 const FlowPattern &
FP)
const;
183 bool isPredicableStore(
const MachineInstr *
MI)
const;
184 bool isSafeToSpeculate(
const MachineInstr *
MI)
const;
185 bool isPredicate(
unsigned R)
const;
187 unsigned getCondStoreOpcode(
unsigned Opc,
bool IfTrue)
const;
189 MachineInstr *
MI,
unsigned PredR,
bool IfTrue);
190 void predicateBlockNB(MachineBasicBlock *ToB,
192 unsigned PredR,
bool IfTrue);
195 const TargetRegisterClass *DRC,
unsigned PredR,
unsigned TR,
196 unsigned TSR,
unsigned FR,
unsigned FSR);
198 void convert(
const FlowPattern &
FP);
200 void removeBlock(MachineBasicBlock *
B);
201 void eliminatePhis(MachineBasicBlock *
B);
202 void mergeBlocks(MachineBasicBlock *PredB, MachineBasicBlock *SuccB);
203 void simplifyFlowGraph(
const FlowPattern &
FP);
205 const HexagonInstrInfo *HII =
nullptr;
206 const TargetRegisterInfo *TRI =
nullptr;
207 MachineFunction *MFN =
nullptr;
208 MachineRegisterInfo *MRI =
nullptr;
209 MachineDominatorTree *MDT =
nullptr;
210 MachineLoopInfo *MLI =
nullptr;
211 BlockSetType Deleted;
212 const MachineBranchProbabilityInfo *MBPI =
nullptr;
217char HexagonEarlyIfConversion::ID = 0;
220 "Hexagon early if conversion",
false,
false)
223 if (
B->succ_size() != 1)
227 return L && SB == L->getHeader() && MDT->dominates(
B, SB);
238 MachineBasicBlock *
TB =
nullptr, *FB =
nullptr;
242 unsigned Opc = T1I->getOpcode();
243 if (
Opc != Hexagon::J2_jumpt &&
Opc != Hexagon::J2_jumpf)
245 Register PredR = T1I->getOperand(0).getReg();
249 MachineBasicBlock *NextB = (NextBI != MFN->
end()) ? &*NextBI :
nullptr;
251 MachineBasicBlock *T1B = T1I->getOperand(1).getMBB();
254 assert(T2I ==
B->end() || T2I->getOpcode() == Hexagon::J2_jump);
255 MachineBasicBlock *T2B = (T2I ==
B->end()) ? NextB
256 : T2I->getOperand(0).getMBB();
265 if (
Opc == Hexagon::J2_jumpt)
277 assert(TB && FB &&
"Failed to find triangle control flow blocks");
278 unsigned TNP =
TB->pred_size(), FNP = FB->pred_size();
279 unsigned TNS =
TB->succ_size(), FNS = FB->succ_size();
286 bool TOk = (TNP == 1 && TNS == 1 && MLI->
getLoopFor(TB) == L);
287 bool FOk = (FNP == 1 && FNS == 1 && MLI->
getLoopFor(FB) == L);
298 MachineBasicBlock *TSB = (TNS > 0) ? *
TB->succ_begin() :
nullptr;
299 MachineBasicBlock *FSB = (FNS > 0) ? *FB->succ_begin() :
nullptr;
300 MachineBasicBlock *JB =
nullptr;
320 if ((TB && isPreheader(TB)) || (FB && isPreheader(FB))) {
321 LLVM_DEBUG(
dbgs() <<
"One of blocks " << PrintMB(TB) <<
", " << PrintMB(FB)
322 <<
" is a loop preheader. Skipping.\n");
326 FP = FlowPattern(
B, PredR, TB, FB, JB);
333bool HexagonEarlyIfConversion::hasEHLabel(
const MachineBasicBlock *
B)
const {
342bool HexagonEarlyIfConversion::hasUncondBranch(
const MachineBasicBlock *
B)
353bool HexagonEarlyIfConversion::isValidCandidate(
const MachineBasicBlock *
B)
357 if (
B->isEHPad() ||
B->hasAddressTaken())
362 for (
auto &
MI : *
B) {
363 if (
MI.isDebugInstr())
365 if (
MI.isConditionalBranch())
367 unsigned Opc =
MI.getOpcode();
368 bool IsJMP = (
Opc == Hexagon::J2_jump);
369 if (!isPredicableStore(&
MI) && !IsJMP && !isSafeToSpeculate(&
MI))
377 for (
const MachineOperand &MO :
MI.operands()) {
378 if (!MO.isReg() || !MO.isDef())
385 for (
const MachineOperand &U :
MRI->use_operands(R))
386 if (
U.getParent()->isPHI())
393bool HexagonEarlyIfConversion::usesUndefVReg(
const MachineInstr *
MI)
const {
394 for (
const MachineOperand &MO :
MI->operands()) {
395 if (!MO.isReg() || !MO.isUse())
400 const MachineInstr *DefI =
MRI->getVRegDef(R);
402 assert(DefI &&
"Expecting a reaching def in MRI");
409bool HexagonEarlyIfConversion::isValid(
const FlowPattern &
FP)
const {
410 if (hasEHLabel(
FP.SplitB))
412 if (
FP.TrueB && !isValidCandidate(
FP.TrueB))
414 if (
FP.FalseB && !isValidCandidate(
FP.FalseB))
427 const MachineBasicBlock &
B = *
FP.JoinB;
431 if (usesUndefVReg(&
MI))
434 if (isPredicate(DefR))
441unsigned HexagonEarlyIfConversion::computePhiCost(
const MachineBasicBlock *
B,
442 const FlowPattern &
FP)
const {
443 if (
B->pred_size() < 2)
447 for (
const MachineInstr &
MI : *
B) {
454 SmallVector<unsigned,2> Inc;
455 for (
unsigned i = 1, e =
MI.getNumOperands(); i != e; i += 2) {
456 const MachineBasicBlock *BB =
MI.getOperand(i+1).getMBB();
457 if (BB ==
FP.SplitB || BB ==
FP.TrueB || BB ==
FP.FalseB)
464 const MachineOperand &
RA =
MI.getOperand(1);
465 const MachineOperand &RB =
MI.getOperand(3);
472 const MachineInstr *Def1 =
MRI->getVRegDef(
RA.getReg());
473 const MachineInstr *Def3 =
MRI->getVRegDef(RB.
getReg());
480unsigned HexagonEarlyIfConversion::countPredicateDefs(
481 const MachineBasicBlock *
B)
const {
482 unsigned PredDefs = 0;
483 for (
auto &
MI : *
B) {
484 for (
const MachineOperand &MO :
MI.operands()) {
485 if (!MO.isReg() || !MO.isDef())
497bool HexagonEarlyIfConversion::isProfitable(
const FlowPattern &
FP)
const {
498 BranchProbability JumpProb(1, 10);
499 BranchProbability Prob(9, 10);
500 if (MBPI &&
FP.TrueB && !
FP.FalseB &&
505 if (MBPI && !
FP.TrueB &&
FP.FalseB &&
510 if (
FP.TrueB &&
FP.FalseB) {
534 auto TotalCount = [] (
const MachineBasicBlock *
B,
unsigned &Spare) {
537 unsigned T = std::count_if(
B->begin(),
B->getFirstTerminator(),
538 [](
const MachineInstr &
MI) {
539 return !MI.isMetaInstruction();
546 unsigned TotalIn = TotalCount(
FP.TrueB, Spare) + TotalCount(
FP.FalseB, Spare);
548 dbgs() <<
"Total number of instructions to be predicated/speculated: "
549 << TotalIn <<
", spare room: " << Spare <<
"\n");
559 unsigned TotalPh = 0;
560 unsigned PredDefs = countPredicateDefs(
FP.SplitB);
562 TotalPh = computePhiCost(
FP.JoinB,
FP);
563 PredDefs += countPredicateDefs(
FP.JoinB);
565 if (
FP.TrueB && !
FP.TrueB->succ_empty()) {
566 MachineBasicBlock *SB = *
FP.TrueB->succ_begin();
567 TotalPh += computePhiCost(SB,
FP);
568 PredDefs += countPredicateDefs(SB);
570 if (
FP.FalseB && !
FP.FalseB->succ_empty()) {
572 TotalPh += computePhiCost(SB,
FP);
573 PredDefs += countPredicateDefs(SB);
576 LLVM_DEBUG(
dbgs() <<
"Total number of extra muxes from converted phis: "
581 LLVM_DEBUG(
dbgs() <<
"Total number of predicate registers: " << PredDefs
589bool HexagonEarlyIfConversion::visitBlock(MachineBasicBlock *
B,
606 MachineBasicBlock *SB =
I->getBlock();
617 if (!matchFlowPattern(
B, L,
FP))
630 simplifyFlowGraph(
FP);
634bool HexagonEarlyIfConversion::visitLoop(MachineLoop *L) {
635 MachineBasicBlock *HB =
L ?
L->getHeader() :
nullptr;
637 :
dbgs() <<
"Visiting function")
641 for (MachineLoop *
I : *L)
646 Changed |= visitBlock(L ? HB : EntryB, L);
650bool HexagonEarlyIfConversion::isPredicableStore(
const MachineInstr *
MI)
655 unsigned Opc =
MI->getOpcode();
657 case Hexagon::S2_storerb_io:
658 case Hexagon::S2_storerbnew_io:
659 case Hexagon::S2_storerh_io:
660 case Hexagon::S2_storerhnew_io:
661 case Hexagon::S2_storeri_io:
662 case Hexagon::S2_storerinew_io:
663 case Hexagon::S2_storerd_io:
664 case Hexagon::S4_storeirb_io:
665 case Hexagon::S4_storeirh_io:
666 case Hexagon::S4_storeiri_io:
674bool HexagonEarlyIfConversion::isSafeToSpeculate(
const MachineInstr *
MI)
676 if (
MI->mayLoadOrStore())
678 if (
MI->isCall() ||
MI->isBarrier() ||
MI->isBranch())
680 if (
MI->hasUnmodeledSideEffects())
682 if (
MI->getOpcode() == TargetOpcode::LIFETIME_END)
688bool HexagonEarlyIfConversion::isPredicate(
unsigned R)
const {
689 const TargetRegisterClass *RC =
MRI->getRegClass(R);
690 return RC == &Hexagon::PredRegsRegClass ||
691 RC == &Hexagon::HvxQRRegClass;
694unsigned HexagonEarlyIfConversion::getCondStoreOpcode(
unsigned Opc,
699void HexagonEarlyIfConversion::predicateInstr(MachineBasicBlock *ToB,
701 unsigned PredR,
bool IfTrue) {
703 if (At != ToB->
end())
704 DL = At->getDebugLoc();
705 else if (!ToB->
empty())
708 unsigned Opc =
MI->getOpcode();
710 if (isPredicableStore(
MI)) {
711 unsigned COpc = getCondStoreOpcode(
Opc, IfTrue);
713 MachineInstrBuilder MIB =
BuildMI(*ToB, At,
DL, HII->get(COpc));
720 for (
const MachineOperand &MO :
make_range(MOI,
MI->operands_end()))
726 MI->eraseFromParent();
730 if (
Opc == Hexagon::J2_jump) {
731 MachineBasicBlock *
TB =
MI->getOperand(0).getMBB();
732 const MCInstrDesc &
D = HII->get(IfTrue ? Hexagon::J2_jumpt
733 : Hexagon::J2_jumpf);
737 MI->eraseFromParent();
750void HexagonEarlyIfConversion::predicateBlockNB(MachineBasicBlock *ToB,
752 unsigned PredR,
bool IfTrue) {
753 LLVM_DEBUG(
dbgs() <<
"Predicating block " << PrintMB(FromB) <<
"\n");
757 for (
I = FromB->
begin();
I != End;
I = NextI) {
759 NextI = std::next(
I);
760 if (isSafeToSpeculate(&*
I))
763 predicateInstr(ToB, At, &*
I, PredR, IfTrue);
767unsigned HexagonEarlyIfConversion::buildMux(MachineBasicBlock *
B,
769 unsigned PredR,
unsigned TR,
unsigned TSR,
unsigned FR,
unsigned FSR) {
771 switch (DRC->
getID()) {
772 case Hexagon::IntRegsRegClassID:
773 case Hexagon::IntRegsLow8RegClassID:
774 Opc = Hexagon::C2_mux;
776 case Hexagon::DoubleRegsRegClassID:
777 case Hexagon::GeneralDoubleLow8RegsRegClassID:
778 Opc = Hexagon::PS_pselect;
780 case Hexagon::HvxVRRegClassID:
781 Opc = Hexagon::PS_vselect;
783 case Hexagon::HvxWRRegClassID:
784 Opc = Hexagon::PS_wselect;
789 const MCInstrDesc &
D = HII->get(
Opc);
800void HexagonEarlyIfConversion::updatePhiNodes(MachineBasicBlock *WhereB,
801 const FlowPattern &
FP) {
805 for (
auto I = WhereB->
begin();
I != NonPHI; ++
I) {
806 MachineInstr *PN = &*
I;
808 unsigned TR = 0, TSR = 0, FR = 0, FSR = 0, SR = 0, SSR = 0;
811 if (BO.getMBB() ==
FP.SplitB)
813 else if (BO.getMBB() ==
FP.TrueB)
815 else if (BO.getMBB() ==
FP.FalseB)
828 unsigned MuxR = 0, MuxSR = 0;
832 const TargetRegisterClass *RC =
MRI->getRegClass(DR);
833 MuxR = buildMux(
FP.SplitB,
FP.SplitB->getFirstTerminator(), RC,
834 FP.PredR, TR, TSR, FR, FSR);
844 false,
false, MuxSR));
849void HexagonEarlyIfConversion::convert(
const FlowPattern &
FP) {
850 MachineBasicBlock *TSB =
nullptr, *FSB =
nullptr;
857 predicateBlockNB(
FP.SplitB, OldTI,
FP.TrueB,
FP.PredR,
true);
862 predicateBlockNB(
FP.SplitB, At,
FP.FalseB,
FP.PredR,
false);
868 MachineBasicBlock *SSB =
nullptr;
869 FP.SplitB->erase(OldTI,
FP.SplitB->end());
870 while (!
FP.SplitB->succ_empty()) {
871 MachineBasicBlock *
T = *
FP.SplitB->succ_begin();
886 if (
T !=
FP.TrueB &&
T !=
FP.FalseB) {
890 FP.SplitB->removeSuccessor(
FP.SplitB->succ_begin());
899 BuildMI(*
FP.SplitB,
FP.SplitB->end(),
DL, HII->get(Hexagon::J2_jump))
901 FP.SplitB->addSuccessor(
FP.JoinB);
903 bool HasBranch =
false;
905 BuildMI(*
FP.SplitB,
FP.SplitB->end(),
DL, HII->get(Hexagon::J2_jumpt))
908 FP.SplitB->addSuccessor(TSB);
912 const MCInstrDesc &
D = HasBranch ? HII->get(Hexagon::J2_jump)
913 : HII->get(Hexagon::J2_jumpf);
914 MachineInstrBuilder MIB =
BuildMI(*
FP.SplitB,
FP.SplitB->end(),
DL,
D);
918 FP.SplitB->addSuccessor(FSB);
925 BuildMI(*
FP.SplitB,
FP.SplitB->end(),
DL, HII->get(Hexagon::J2_jump))
927 FP.SplitB->addSuccessor(SSB);
944void HexagonEarlyIfConversion::removeBlock(MachineBasicBlock *
B) {
951 MachineBasicBlock *IDB = IDN->
getBlock();
953 using GTN = GraphTraits<MachineDomTreeNode *>;
956 DTNodeVectType Cn(GTN::child_begin(
N), GTN::child_end(
N));
958 MachineBasicBlock *SB =
I->getBlock();
963 while (!
B->succ_empty())
964 B->removeSuccessor(
B->succ_begin());
966 for (MachineBasicBlock *Pred :
B->predecessors())
967 Pred->removeSuccessor(
B,
true);
971 MFN->
erase(
B->getIterator());
974void HexagonEarlyIfConversion::eliminatePhis(MachineBasicBlock *
B) {
975 LLVM_DEBUG(
dbgs() <<
"Removing phi nodes from block " << PrintMB(
B) <<
"\n");
977 for (
I =
B->begin();
I != NonPHI;
I = NextI) {
978 NextI = std::next(
I);
979 MachineInstr *PN = &*
I;
984 unsigned NewR = UseR;
990 const TargetRegisterClass *RC =
MRI->getRegClass(DefR);
991 NewR =
MRI->createVirtualRegister(RC);
992 NonPHI =
BuildMI(*
B, NonPHI,
DL, HII->get(TargetOpcode::COPY), NewR)
995 MRI->replaceRegWith(DefR, NewR);
1000void HexagonEarlyIfConversion::mergeBlocks(MachineBasicBlock *PredB,
1001 MachineBasicBlock *SuccB) {
1002 LLVM_DEBUG(
dbgs() <<
"Merging blocks " << PrintMB(PredB) <<
" and "
1003 << PrintMB(SuccB) <<
"\n");
1004 bool TermOk = hasUncondBranch(SuccB);
1005 eliminatePhis(SuccB);
1010 MachineBasicBlock *OldLayoutSuccessor = SuccB->
getNextNode();
1016void HexagonEarlyIfConversion::simplifyFlowGraph(
const FlowPattern &
FP) {
1017 MachineBasicBlock *OldLayoutSuccessor =
FP.SplitB->
getNextNode();
1019 removeBlock(
FP.TrueB);
1021 removeBlock(
FP.FalseB);
1023 FP.SplitB->updateTerminator(OldLayoutSuccessor);
1024 if (
FP.SplitB->succ_size() != 1)
1036 if (!hasEHLabel(SB) || hasUncondBranch(SB))
1037 mergeBlocks(
FP.SplitB, SB);
1040bool HexagonEarlyIfConversion::runOnMachineFunction(MachineFunction &MF) {
1045 HII =
ST.getInstrInfo();
1046 TRI =
ST.getRegisterInfo();
1049 MDT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
1050 MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI();
1052 ? &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI()
1058 for (MachineLoop *L : *MLI)
1060 Changed |= visitLoop(
nullptr);
1069 return new HexagonEarlyIfConversion();
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the DenseSet and SmallDenseSet classes.
static cl::opt< bool > EnableHexagonBP("enable-hexagon-br-prob", cl::Hidden, cl::init(true), cl::desc("Enable branch probability info"))
static cl::opt< bool > SkipExitBranches("eif-no-loop-exit", cl::init(false), cl::Hidden, cl::desc("Do not convert branches that may exit the loop"))
static cl::opt< unsigned > SizeLimit("eif-limit", cl::init(6), cl::Hidden, cl::desc("Size limit in Hexagon early if-conversion"))
#define HEXAGON_PACKET_SIZE
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
SI optimize exec mask operations pre RA
This file defines the SmallVector class.
static bool isProfitable(const StableFunctionMap::StableFunctionEntries &SFS)
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
DomTreeNodeBase * getIDom() const
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
void eraseNode(NodeT *BB)
eraseNode - Removes a node from the dominator tree.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
bool properlyDominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
FunctionPass class - This class is used to implement most global optimizations.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
Remove the branching code at the end of the specific MBB.
int getCondOpcode(int Opc, bool sense) const
bool isPostIncrement(const MachineInstr &MI) const override
Return true for post-incremented instructions.
bool isPredicable(const MachineInstr &MI) const override
Return true if the specified instruction can be predicated.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
unsigned pred_size() const
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
MachineInstrBundleIterator< const MachineInstr > const_iterator
LLVM_ABI void updateTerminator(MachineBasicBlock *PreviousLayoutSuccessor)
Update the terminator instructions in block to account for changes to block layout which may have bee...
succ_iterator succ_begin()
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
LLVM_ABI void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)
Remove successor from the successors list of this MachineBasicBlock.
LLVM_ABI iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
LLVM_ABI DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
BranchProbability getEdgeProbability(const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
BasicBlockListType::iterator iterator
void erase(iterator MBBI)
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
bool isImplicitDef() const
unsigned getNumOperands() const
Retuns the total number of operands.
LLVM_ABI void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
MachineOperand * mop_iterator
iterator/begin/end - Iterate over all operands of a machine instruction.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
LLVM_ABI void removeOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with.
const MachineOperand & getOperand(unsigned i) const
unsigned getSubReg() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0)
void push_back(const T &Elt)
unsigned getID() const
Return the register class ID number.
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ TB
TB - TwoByte - Set if this instruction has a two byte opcode, which starts with a 0x0F byte before th...
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
FunctionPass * createHexagonEarlyIfConversion()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
DomTreeNodeBase< MachineBasicBlock > MachineDomTreeNode
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
LLVM_ABI void updatePhiNodes(BasicBlock *DestBB, BasicBlock *OldPred, BasicBlock *NewPred, PHINode *Until=nullptr)
Replaces all uses of OldPred with the NewPred block in all PHINodes in a block.
iterator_range< typename GraphTraits< GraphType >::ChildIteratorType > children(const typename GraphTraits< GraphType >::NodeRef &G)
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
static NodeRef getEntryNode(MachineFunction *F)