27 #include "llvm/Config/llvm-config.h" 41 #define DEBUG_TYPE "codegen" 44 : BB(B),
Number(-1), xParent(&MF) {
50 MachineBasicBlock::~MachineBasicBlock() {
55 if (!CachedMCSymbol) {
65 return CachedMCSymbol;
94 I->AddRegOperandsToUseLists(RegInfo);
106 assert(!N->
getParent() &&
"machine instruction already in a basic block");
107 N->setParent(Parent);
112 N->AddRegOperandsToUseLists(MF->
getRegInfo());
122 N->RemoveRegOperandsFromUseLists(MF->getRegInfo());
124 N->setParent(
nullptr);
132 assert(Parent->getParent() == FromList.Parent->getParent() &&
133 "MachineInstr parent mismatch!");
134 assert(
this != &FromList &&
"Called without a real transfer...");
135 assert(Parent != FromList.Parent &&
"Two lists have the same parent?");
139 for (; First != Last; ++First)
140 First->setParent(Parent);
145 Parent->getParent()->DeleteMachineInstr(MI);
150 while (I !=
E && I->isPHI())
152 assert((I ==
E || !I->isInsideBundle()) &&
153 "First non-phi MI cannot be inside a bundle!");
162 while (I != E && (I->isPHI() || I->isPosition() ||
167 assert((I == E || !I->isInsideBundle()) &&
168 "First non-phi / non-label instruction is inside a bundle!");
177 while (I != E && (I->isPHI() || I->isPosition() || I->isDebugInstr() ||
182 assert((I == E || !I->isInsideBundle()) &&
183 "First non-phi / non-label / non-debug " 184 "instruction is inside a bundle!");
190 while (
I != B && ((--
I)->isTerminator() ||
I->isDebugInstr()))
192 while (
I !=
E && !
I->isTerminator())
199 while (
I != B && ((--
I)->isTerminator() ||
I->isDebugInstr()))
201 while (
I !=
E && !
I->isTerminator())
217 if (
I->isDebugInstr() ||
I->isInsideBundle())
232 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 246 return LBB->getName();
264 bool IsStandalone)
const {
267 OS <<
"Can't print out MachineBasicBlock because parent MachineFunction" 275 print(OS, MST, Indexes, IsStandalone);
280 bool IsStandalone)
const {
283 OS <<
"Can't print out MachineBasicBlock because parent MachineFunction" 292 bool HasAttributes =
false;
297 HasAttributes =
true;
301 OS <<
"<ir-block badref>";
303 OS << (
Twine(
"%ir-block.") +
Twine(Slot)).str();
308 OS << (HasAttributes ?
", " :
" (");
309 OS <<
"address-taken";
310 HasAttributes =
true;
313 OS << (HasAttributes ?
", " :
" (");
315 HasAttributes =
true;
318 OS << (HasAttributes ?
", " :
" (");
320 HasAttributes =
true;
329 bool HasLineAttributes =
false;
333 if (Indexes) OS <<
'\t';
335 OS <<
"; predecessors: ";
342 HasLineAttributes =
true;
346 if (Indexes) OS <<
'\t';
348 OS.
indent(2) <<
"successors: ";
358 if (!Probs.empty() && IsStandalone) {
375 HasLineAttributes =
true;
379 if (Indexes) OS <<
'\t';
380 OS.
indent(2) <<
"liveins: ";
383 for (
const auto &LI :
liveins()) {
388 if (!LI.LaneMask.all())
391 HasLineAttributes =
true;
394 if (HasLineAttributes)
397 bool IsInBundle =
false;
410 OS.
indent(IsInBundle ? 4 : 2);
411 MI.
print(OS, MST, IsStandalone,
false,
false,
424 if (IrrLoopHeaderWeight && IsStandalone) {
425 if (Indexes) OS <<
'\t';
426 OS.
indent(2) <<
"; Irreducible loop header weight: " 427 << IrrLoopHeaderWeight.
getValue() <<
'\n';
439 if (I == LiveIns.end())
442 I->LaneMask &= ~LaneMask;
443 if (I->LaneMask.none())
450 LiveInVector::iterator LI = LiveIns.begin() + (I - LiveIns.begin());
451 return LiveIns.erase(LI);
457 return I !=
livein_end() && (I->LaneMask & LaneMask).any();
463 return LI0.
PhysReg < LI1.PhysReg;
466 LiveInVector::const_iterator
I = LiveIns.begin();
467 LiveInVector::const_iterator J;
468 LiveInVector::iterator Out = LiveIns.begin();
469 for (; I != LiveIns.end(); ++Out, I = J) {
470 unsigned PhysReg = I->PhysReg;
472 for (J = std::next(I); J != LiveIns.end() && J->PhysReg == PhysReg; ++J)
473 LaneMask |= J->LaneMask;
474 Out->PhysReg = PhysReg;
475 Out->LaneMask = LaneMask;
477 LiveIns.erase(Out, LiveIns.end());
484 assert(RC &&
"Register class is required");
486 "Only the entry block and landing pads can have physreg live ins");
495 for (;I !=
E && I->isCopy(); ++
I)
496 if (I->getOperand(1).getReg() == PhysReg) {
497 unsigned VirtReg = I->getOperand(0).getReg();
531 assert(!B &&
"UpdateTerminators requires analyzable predecessors!");
543 if ((*SI)->isEHPad())
545 assert(!TBB &&
"Found more than one non-landing-pad successor!");
583 if ((*SI)->isEHPad() || *
SI == TBB)
585 assert(!FallthroughBB &&
"Found more than one fallthrough successor.");
589 if (!FallthroughBB) {
618 TII->
insertBranch(*
this, FallthroughBB,
nullptr, Cond, DL);
622 TII->
insertBranch(*
this, FallthroughBB,
nullptr, Cond, DL);
632 for (
auto Prob : Probs)
633 Sum += Prob.getNumerator();
639 "The sum of successors's probabilities exceeds one.");
647 if (!(Probs.empty() && !Successors.empty()))
648 Probs.push_back(Prob);
649 Successors.push_back(Succ);
650 Succ->addPredecessor(
this);
658 Successors.push_back(Succ);
659 Succ->addPredecessor(
this);
664 bool NormalizeSuccProbs) {
666 assert(OldI !=
succ_end() &&
"Old is not a successor of this block!");
668 "New is already a successor of this block!");
676 : *getProbabilityIterator(OldI));
677 if (NormalizeSuccProbs)
682 bool NormalizeSuccProbs) {
689 assert(I != Successors.end() &&
"Not a current successor!");
693 if (!Probs.empty()) {
694 probability_iterator WI = getProbabilityIterator(I);
696 if (NormalizeSuccProbs)
700 (*I)->removePredecessor(
this);
701 return Successors.erase(I);
724 assert(OldI != E &&
"Old is not a successor of this block");
728 Old->removePredecessor(
this);
729 New->addPredecessor(
this);
736 if (!Probs.empty()) {
737 auto ProbIter = getProbabilityIterator(NewI);
738 if (!ProbIter->isUnknown())
739 *ProbIter += *getProbabilityIterator(OldI);
746 if (Orig->Probs.empty())
753 Predecessors.push_back(Pred);
758 assert(I != Predecessors.end() &&
"Pred is not a predecessor of this block!");
759 Predecessors.erase(I);
770 if (!FromMBB->Probs.empty()) {
771 auto Prob = *FromMBB->Probs.begin();
787 if (!FromMBB->Probs.empty()) {
788 auto Prob = *FromMBB->Probs.begin();
797 for (
unsigned i = 2, e = MI->
getNumOperands()+1; i != e; i += 2) {
799 if (MO.
getMBB() == FromMBB)
846 if (!TBB)
return &*Fallthrough;
852 return &*Fallthrough;
856 if (Cond.
empty())
return nullptr;
860 return (FBB ==
nullptr) ? &*Fallthrough :
nullptr;
886 Indexes->insertMBBInMaps(NMBB);
901 if (!OI->isReg() || OI->getReg() == 0 ||
902 !OI->isUse() || !OI->isKill() || OI->isUndef())
904 unsigned Reg = OI->getReg();
907 KilledRegs.push_back(Reg);
909 OI->setIsKill(
false);
922 if (!OI->isReg() || OI->getReg() == 0)
925 unsigned Reg = OI->getReg();
952 E = Terminators.
end();
I !=
E; ++
I) {
954 Indexes->removeMachineInstrFromMaps(**
I);
969 if (Indexes->hasIndex(MI))
970 Indexes->removeMachineInstrFromMaps(MI);
971 Indexes->insertMachineInstrInMaps(MI);
979 i != e && i->isPHI(); ++i)
980 for (
unsigned ni = 1, ne = i->getNumOperands(); ni != ne; ni += 2)
981 if (i->getOperand(ni+1).getMBB() ==
this)
982 i->getOperand(ni+1).setMBB(NMBB);
985 for (
const auto &LI : Succ->
liveins())
992 while (!KilledRegs.empty()) {
993 unsigned Reg = KilledRegs.pop_back_val();
995 if (!(--
I)->addRegisterKilled(Reg, TRI,
false))
1018 SlotIndex StartIndex = Indexes->getMBBEndIdx(
this);
1020 SlotIndex EndIndex = Indexes->getMBBEndIdx(NMBB);
1026 I !=
E &&
I->isPHI(); ++
I) {
1027 for (
unsigned ni = 1, ne =
I->getNumOperands(); ni != ne; ni += 2) {
1028 if (
I->getOperand(ni+1).getMBB() == NMBB) {
1038 "PHI sources should be live out of their predecessors.");
1051 if (!LI.
liveAt(PrevIndex))
1055 if (isLiveOut && isLastMBB) {
1057 assert(VNI &&
"LiveInterval should have VNInfo where it is live.");
1059 }
else if (!isLiveOut && !isLastMBB) {
1071 MDT->recordSplitCriticalEdge(
this, Succ, NMBB);
1077 if (
MachineLoop *DestLoop = MLI->getLoopFor(Succ)) {
1078 if (TIL == DestLoop) {
1080 DestLoop->addBasicBlockToLoop(NMBB, MLI->getBase());
1081 }
else if (TIL->contains(DestLoop)) {
1083 TIL->addBasicBlockToLoop(NMBB, MLI->getBase());
1084 }
else if (DestLoop->contains(TIL)) {
1086 DestLoop->addBasicBlockToLoop(NMBB, MLI->getBase());
1092 assert(DestLoop->getHeader() == Succ &&
1093 "Should not create irreducible loops!");
1095 P->addBasicBlockToLoop(NMBB, MLI->getBase());
1123 if (TII->
analyzeBranch(*const_cast<MachineBasicBlock *>(
this), TBB, FBB, Cond,
1131 if (TBB && TBB == FBB) {
1132 LLVM_DEBUG(
dbgs() <<
"Won't split critical edge after degenerate " 1155 return Insts.
erase(I);
1168 "Cannot insert instruction with bundle flags");
1170 if (I !=
instr_end() && I->isBundledWithPred()) {
1174 return Insts.
insert(I, MI);
1195 assert(Old != New &&
"Cannot replace self with self!");
1200 if (!I->isTerminator())
break;
1204 for (
unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
1205 if (I->getOperand(i).isMBB() &&
1206 I->getOperand(i).getMBB() == Old)
1207 I->getOperand(i).setMBB(New);
1238 bool Changed =
false;
1242 if (!DestA && !DestB) {
1246 }
else if (DestA && !DestB) {
1251 assert(DestA && DestB && IsCond &&
1252 "CFG in a bad state. Cannot correct CFG edges");
1261 if (!SeenMBBs.
insert(MBB).second ||
1262 (MBB != DestA && MBB != DestB && !MBB->
isEHPad())) {
1283 return MBBI->getDebugLoc();
1293 if (!MBBI->isDebugInstr())
return MBBI->getDebugLoc();
1303 while (TI !=
end() && !TI->isBranch())
1307 DL = TI->getDebugLoc();
1308 for (++TI ; TI !=
end() ; ++TI)
1321 const auto &Prob = *getProbabilityIterator(Succ);
1322 if (Prob.isUnknown()) {
1325 unsigned KnownProbNum = 0;
1327 for (
auto &
P : Probs) {
1328 if (!
P.isUnknown()) {
1333 return Sum.getCompl() / (Probs.size() - KnownProbNum);
1344 *getProbabilityIterator(I) = Prob;
1348 MachineBasicBlock::const_probability_iterator
1349 MachineBasicBlock::getProbabilityIterator(
1351 assert(Probs.size() == Successors.size() &&
"Async probability list!");
1352 const size_t index = std::distance(Successors.begin(),
I);
1353 assert(index < Probs.size() &&
"Not a current successor!");
1354 return Probs.begin() + index;
1358 MachineBasicBlock::probability_iterator
1360 assert(Probs.size() == Successors.size() &&
"Async probability list!");
1361 const size_t index = std::distance(Successors.begin(),
I);
1362 assert(index < Probs.size() &&
"Not a current successor!");
1363 return Probs.begin() + index;
1375 unsigned Neighborhood)
const {
1376 unsigned N = Neighborhood;
1409 }
while (I !=
begin() && --N > 0);
1429 for (++I; I !=
end() && N > 0; ++
I, --
N) {
1467 "Liveness information is accurate");
1468 return LiveIns.begin();
Pass interface - Implemented by all 'passes'.
void print(raw_ostream &OS, const SlotIndexes *=nullptr, bool IsStandalone=true) const
const MCAsmInfo * getAsmInfo() const
void push_back(const T &Elt)
mop_iterator operands_end()
void validateSuccProbs() const
Validate successors' probabilities and check if the sum of them is approximate one.
instr_iterator instr_begin()
instr_iterator instr_end()
MachineBasicBlock * getMBB() const
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
MachineBasicBlock * getNextNode()
Get the next node, or nullptr for the list tail.
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
iterator erase(iterator where)
Compute iterated dominance frontiers using a linear time algorithm.
void addNodeToList(NodeTy *)
When an MBB is added to an MF, we need to update the parent pointer of the MBB, the MBB numbering...
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI, unsigned Reg, const_iterator Before, unsigned Neighborhood=10) const
Return whether (physical) register Reg has been defined and not killed as of just before Before...
static unsigned index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
A Module instance is used to store all the information related to an LLVM module. ...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool isBundledWithPred() const
Return true if this instruction is part of a bundle, and it is not the first instruction in the bundl...
instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
iterator getFirstNonDebugInstr()
Returns an iterator to the first non-debug instruction in the basic block, or end().
LiveInterval - This class represents the liveness of a register, or stack slot.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
bool requiresStructuredCFG() const
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
void transferSuccessors(MachineBasicBlock *FromMBB)
Transfers all the successors from MBB to this machine basic block (i.e., copies all the successors Fr...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
int getLocalSlot(const Value *V)
Return the slot number of the specified local value.
virtual const uint32_t * getNoPreservedMask() const
Return a register mask that clobbers everything.
virtual unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const
Insert branch code into the end of the specified MachineBasicBlock.
Template traits for intrusive list.
void addSuccessorWithoutProb(MachineBasicBlock *Succ)
Add Succ as a successor of this MachineBasicBlock.
This represents a simple continuous liveness interval for a value.
void moveAfter(MachineBasicBlock *NewBefore)
unsigned const TargetRegisterInfo * TRI
Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
Manage lifetime of a slot tracker for printing IR.
MachineInstrBundleIterator< const MachineInstr > const_iterator
VNInfo - Value Number Information.
virtual unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const
Remove the branching code at the end of the specific MBB.
MachineBasicBlock * removeFromParent()
This method unlinks 'this' from the containing function, and returns it, but does not delete it...
BasicBlockListType::const_iterator const_iterator
void removeLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Remove the specified register from the live in set.
iterator_range< succ_iterator > successors()
bool removeKill(MachineInstr &MI)
removeKill - Delete a kill corresponding to the specified machine instruction.
void ReplaceUsesOfBlockWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Given a machine basic block that branched to 'Old', change the code and CFG so that it branches to 'N...
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
bool isReturnBlock() const
Convenience function that returns true if the block ends in a return instruction. ...
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
bool canSplitCriticalEdge(const MachineBasicBlock *Succ) const
Check if the edge between this block and the given successor Succ, can be split.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
bool isBundledWithSucc() const
Return true if this instruction is part of a bundle, and it is not the last instruction in the bundle...
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
MachineBasicBlock * getFallThrough()
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
bool hasEHPadSuccessor() const
SlotIndex getInstructionIndex(const MachineInstr &MI) const
Returns the base index for the given instruction.
static void unbundleSingleMI(MachineInstr *MI)
Prepare MI to be removed from its bundle.
MachineInstr * remove_instr(MachineInstr *I)
Remove the possibly bundled instruction from the instruction list without deleting it...
virtual bool isBasicBlockPrologue(const MachineInstr &MI) const
True if the instruction is bound to the top of its basic block and no other instructions shall be ins...
PhysRegInfo analyzePhysReg(unsigned Reg, const TargetRegisterInfo *TRI)
analyzePhysReg - Analyze how the current instruction or bundle uses a physical register.
LiveInVector::const_iterator livein_iterator
Context object for machine code objects.
void unbundleFromPred()
Break bundle above this instruction.
DebugLoc findPrevDebugLoc(instr_iterator MBBI)
Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE instructions.
void insertMBBInMaps(MachineBasicBlock *MBB)
iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
const T & getValue() const LLVM_LVALUE_FUNCTION
bool canFallThrough()
Return true if the block can implicitly transfer control to the block after it by falling off the end...
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
virtual const TargetInstrInfo * getInstrInfo() const
const uint32_t * getEndClobberMask(const TargetRegisterInfo *TRI) const
Get the clobber mask for the end of the basic block.
void setSuccProbability(succ_iterator I, BranchProbability Prob)
Set successor probability of a given iterator.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
bool isInsideBundle() const
Return true if MI is in a bundle (but not the first MI in a bundle).
bool PartialDeadDef
Reg is Defined and all defs of reg or an overlapping register are dead.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
BasicBlockListType::iterator iterator
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
TargetInstrInfo - Interface to description of machine instruction set.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
MCContext & getContext() const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
iterator SkipPHIsAndLabels(iterator I)
Return the first instruction in MBB after I that is not a PHI or a label.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
bool hasInterval(unsigned Reg) const
LLVM Basic Block Representation.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool liveAt(SlotIndex index) const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
bool Read
Reg or one of its aliases is read.
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE and DBG_LABEL instructions...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
livein_iterator livein_end() const
unsigned getAlignment() const
Return alignment of the basic block.
bool Clobbered
There is a regmask operand indicating Reg is clobbered.
bool hasIndex(const MachineInstr &instr) const
Returns true if the given machine instr is mapped to an index, otherwise returns false.
bool isPredecessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a predecessor of this block.
void setMBB(MachineBasicBlock *MBB)
Register is known to be fully dead.
void setFlag(MIFlag Flag)
Set a MI flag.
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
MCRegAliasIterator enumerates all registers aliasing Reg.
void clearFlag(MIFlag Flag)
clearFlag - Clear a MI flag.
StringRef getPrivateLabelPrefix() const
bool isLegalToHoistInto() const
Returns true if it is legal to hoist instructions into this block.
void clearLiveIns()
Clear live in list.
bool Killed
There is a use operand of reg or a super-register with kill flag set.
std::vector< MachineBasicBlock * >::const_iterator const_succ_iterator
void remove(iterator MBBI)
self_iterator getIterator()
bool livein_empty() const
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
iterator_range< pred_iterator > predecessors()
void print(raw_ostream &OS, bool IsStandalone=true, bool SkipOpers=false, bool SkipDebugLoc=false, bool AddNewLine=true, const TargetInstrInfo *TII=nullptr) const
Print this MI to OS.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
std::vector< MachineBasicBlock * >::iterator pred_iterator
LivenessQueryResult
Possible outcome of a register liveness query to computeRegisterLiveness()
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
Register is known to be (at least partially) live.
succ_iterator succ_begin()
void incorporateFunction(const Function &F)
Incorporate the given function.
void repairIntervalsInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, ArrayRef< unsigned > OrigRegs)
Update live intervals for instructions in a range of iterators.
bool hasAddressTaken() const
Test whether this block is potentially the target of an indirect branch.
void moveBefore(MachineBasicBlock *NewAfter)
Move 'this' block before or after the specified block.
VarInfo & getVarInfo(unsigned RegIdx)
getVarInfo - Return the VarInfo structure for the specified VIRTUAL register.
virtual bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
pred_iterator pred_begin()
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
virtual bool isPredicated(const MachineInstr &MI) const
Returns true if the instruction is already predicated.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void sort(IteratorTy Start, IteratorTy End)
void addNewBlock(MachineBasicBlock *BB, MachineBasicBlock *DomBB, MachineBasicBlock *SuccBB)
addNewBlock - Add a new basic block BB between DomBB and SuccBB.
std::vector< MachineInstr * > Kills
Kills - List of MachineInstruction's which are the last use of this virtual register (kill it) in the...
static BranchProbability getUnknown()
void removeSegment(SlotIndex Start, SlotIndex End, bool RemoveDeadValNo=false)
Remove the specified segment from this range.
static const DILocation * getMergedLocation(const DILocation *LocA, const DILocation *LocB, bool GenerateLocation=NoGeneratedLocation)
When two instructions are combined into a single instruction we also need to combine the original loc...
Iterator for intrusive lists based on ilist_node.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
static uint32_t getDenominator()
void splice(iterator InsertPt, iterator MBBI)
void removeNodeFromList(NodeTy *)
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void updateTerminator()
Update the terminator instructions in block to account for changes to the layout. ...
bool FullyDefined
Reg or a super-register is defined.
LiveInterval & getInterval(unsigned Reg)
static void deleteNode(NodeTy *V)
void sortUniqueLiveIns()
Sorts and uniques the LiveIns vector.
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
IterT skipDebugInstructionsBackward(IterT It, IterT Begin)
Decrement It until it points to a non-debug instruction or to Begin and return the resulting iterator...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
ConstMIOperands - Iterate over operands of a single const instruction.
void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New)
Replace successor OLD with NEW and update probability info.
DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
unsigned succ_size() const
IterT skipDebugInstructionsForward(IterT It, IterT End)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator...
void copySuccessor(MachineBasicBlock *Orig, succ_iterator I)
Copy a successor (and any probability info) from original block to this block's.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
pointer remove(iterator &IT)
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
iterator insert(iterator where, pointer New)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
bool isEHPad() const
Returns true if the block is a landing pad.
LLVM_NODISCARD bool empty() const
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
Register liveness not decidable from local neighborhood.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
StringRef getName() const
Return a constant reference to the value's name.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
APFloat abs(APFloat X)
Returns the absolute value of the argument.
Pair of physical register and lane mask.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
Optional< uint64_t > getIrrLoopHeaderWeight() const
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
Information about how a physical register Reg is used by a set of operands.
void removeFromMBBNumbering(unsigned N)
removeFromMBBNumbering - Remove the specific machine basic block from our tracker, this is only really to be used by the MachineBasicBlock implementation.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)
Remove successor from the successors list of this MachineBasicBlock.
void splitSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New, bool NormalizeSuccProbs=false)
Split the old successor into old plus new and updates the probability info.
iterator_range< livein_iterator > liveins() const
Instructions::iterator instr_iterator
bool Defined
Reg or one of its aliases is defined.
virtual bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const
Reverses the branch condition of the specified condition list, returning false on success and true if...
void erase(iterator MBBI)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void insert(iterator MBBI, MachineBasicBlock *MBB)
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P)
Split the critical edge from this block to the given successor block, and return the newly created bl...
void unbundleFromSucc()
Break bundle below this instruction.
std::string getFullName() const
Return a formatted string to identify this block and its parent function.
unsigned addToMBBNumbering(MachineBasicBlock *MBB)
Adds the MBB to the internal numbering.
Module * getParent()
Get the module that this global value is contained inside of...
mop_iterator operands_begin()
AnalysisType * getAnalysisIfAvailable() const
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information tha...
This class implements an extremely fast bulk output stream that can only output to a stream...
static bool isLiveOut(const MachineBasicBlock &MBB, unsigned Reg)
iterator SkipPHIsLabelsAndDebug(iterator I)
Return the first instruction in MBB after I that is not a PHI, label or debug.
bool isBarrier(QueryType Type=AnyInBundle) const
Returns true if the specified instruction stops control flow from executing the instruction immediate...
StringRef - Represent a constant reference to a string, i.e.
void printAsOperand(raw_ostream &OS, bool PrintType=true) const
static BranchProbability getZero()
const uint32_t * getBeginClobberMask(const TargetRegisterInfo *TRI) const
Get the clobber mask for the start of this basic block.
Simple wrapper around std::function<void(raw_ostream&)>.
const MachineOperand & getOperand(unsigned i) const
SlotIndex - An opaque wrapper around machine indexes.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
uint32_t getNumerator() const
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
std::vector< MachineBasicBlock * >::iterator succ_iterator
livein_iterator livein_begin() const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool CorrectExtraCFGEdges(MachineBasicBlock *DestA, MachineBasicBlock *DestB, bool IsCond)
Various pieces of code can cause excess edges in the CFG to be inserted.
void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator)
Callback before transferring nodes to this list.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.