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());
113 MF->handleInsertion(*N);
123 MF->handleRemoval(*N);
124 N->RemoveRegOperandsFromUseLists(MF->getRegInfo());
127 N->setParent(
nullptr);
135 assert(Parent->getParent() == FromList.Parent->getParent() &&
136 "MachineInstr parent mismatch!");
137 assert(
this != &FromList &&
"Called without a real transfer...");
138 assert(Parent != FromList.Parent &&
"Two lists have the same parent?");
142 for (; First != Last; ++First)
143 First->setParent(Parent);
148 Parent->getParent()->DeleteMachineInstr(MI);
153 while (I !=
E && I->isPHI())
155 assert((I ==
E || !I->isInsideBundle()) &&
156 "First non-phi MI cannot be inside a bundle!");
165 while (I != E && (I->isPHI() || I->isPosition() ||
170 assert((I == E || !I->isInsideBundle()) &&
171 "First non-phi / non-label instruction is inside a bundle!");
180 while (I != E && (I->isPHI() || I->isPosition() || I->isDebugInstr() ||
185 assert((I == E || !I->isInsideBundle()) &&
186 "First non-phi / non-label / non-debug " 187 "instruction is inside a bundle!");
193 while (
I != B && ((--
I)->isTerminator() ||
I->isDebugInstr()))
195 while (
I !=
E && !
I->isTerminator())
202 while (
I != B && ((--
I)->isTerminator() ||
I->isDebugInstr()))
204 while (
I !=
E && !
I->isTerminator())
220 if (
I->isDebugInstr() ||
I->isInsideBundle())
235 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 249 return LBB->getName();
267 bool IsStandalone)
const {
270 OS <<
"Can't print out MachineBasicBlock because parent MachineFunction" 278 print(OS, MST, Indexes, IsStandalone);
283 bool IsStandalone)
const {
286 OS <<
"Can't print out MachineBasicBlock because parent MachineFunction" 295 bool HasAttributes =
false;
300 HasAttributes =
true;
304 OS <<
"<ir-block badref>";
306 OS << (
Twine(
"%ir-block.") +
Twine(Slot)).str();
311 OS << (HasAttributes ?
", " :
" (");
312 OS <<
"address-taken";
313 HasAttributes =
true;
316 OS << (HasAttributes ?
", " :
" (");
318 HasAttributes =
true;
321 OS << (HasAttributes ?
", " :
" (");
323 HasAttributes =
true;
332 bool HasLineAttributes =
false;
336 if (Indexes) OS <<
'\t';
338 OS <<
"; predecessors: ";
345 HasLineAttributes =
true;
349 if (Indexes) OS <<
'\t';
351 OS.
indent(2) <<
"successors: ";
361 if (!Probs.empty() && IsStandalone) {
378 HasLineAttributes =
true;
382 if (Indexes) OS <<
'\t';
383 OS.
indent(2) <<
"liveins: ";
386 for (
const auto &LI :
liveins()) {
391 if (!LI.LaneMask.all())
394 HasLineAttributes =
true;
397 if (HasLineAttributes)
400 bool IsInBundle =
false;
413 OS.
indent(IsInBundle ? 4 : 2);
414 MI.
print(OS, MST, IsStandalone,
false,
false,
427 if (IrrLoopHeaderWeight && IsStandalone) {
428 if (Indexes) OS <<
'\t';
429 OS.
indent(2) <<
"; Irreducible loop header weight: " 430 << IrrLoopHeaderWeight.
getValue() <<
'\n';
442 if (I == LiveIns.end())
445 I->LaneMask &= ~LaneMask;
446 if (I->LaneMask.none())
453 LiveInVector::iterator LI = LiveIns.begin() + (I - LiveIns.begin());
454 return LiveIns.erase(LI);
460 return I !=
livein_end() && (I->LaneMask & LaneMask).any();
469 LiveInVector::const_iterator
I = LiveIns.begin();
470 LiveInVector::const_iterator J;
471 LiveInVector::iterator Out = LiveIns.begin();
472 for (; I != LiveIns.end(); ++Out, I = J) {
473 unsigned PhysReg = I->PhysReg;
475 for (J = std::next(I); J != LiveIns.end() && J->PhysReg == PhysReg; ++J)
476 LaneMask |= J->LaneMask;
477 Out->PhysReg = PhysReg;
478 Out->LaneMask = LaneMask;
480 LiveIns.erase(Out, LiveIns.end());
487 assert(RC &&
"Register class is required");
489 "Only the entry block and landing pads can have physreg live ins");
498 for (;I !=
E && I->isCopy(); ++
I)
499 if (I->getOperand(1).getReg() == PhysReg) {
500 unsigned VirtReg = I->getOperand(0).getReg();
534 assert(!B &&
"UpdateTerminators requires analyzable predecessors!");
546 if ((*SI)->isEHPad())
548 assert(!TBB &&
"Found more than one non-landing-pad successor!");
586 if ((*SI)->isEHPad() || *
SI == TBB)
588 assert(!FallthroughBB &&
"Found more than one fallthrough successor.");
592 if (!FallthroughBB) {
621 TII->
insertBranch(*
this, FallthroughBB,
nullptr, Cond, DL);
625 TII->
insertBranch(*
this, FallthroughBB,
nullptr, Cond, DL);
635 for (
auto Prob : Probs)
636 Sum += Prob.getNumerator();
642 "The sum of successors's probabilities exceeds one.");
650 if (!(Probs.empty() && !Successors.empty()))
651 Probs.push_back(Prob);
652 Successors.push_back(Succ);
653 Succ->addPredecessor(
this);
661 Successors.push_back(Succ);
662 Succ->addPredecessor(
this);
667 bool NormalizeSuccProbs) {
669 assert(OldI !=
succ_end() &&
"Old is not a successor of this block!");
671 "New is already a successor of this block!");
679 : *getProbabilityIterator(OldI));
680 if (NormalizeSuccProbs)
685 bool NormalizeSuccProbs) {
692 assert(I != Successors.end() &&
"Not a current successor!");
696 if (!Probs.empty()) {
697 probability_iterator WI = getProbabilityIterator(I);
699 if (NormalizeSuccProbs)
703 (*I)->removePredecessor(
this);
704 return Successors.erase(I);
727 assert(OldI != E &&
"Old is not a successor of this block");
731 Old->removePredecessor(
this);
732 New->addPredecessor(
this);
739 if (!Probs.empty()) {
740 auto ProbIter = getProbabilityIterator(NewI);
741 if (!ProbIter->isUnknown())
742 *ProbIter += *getProbabilityIterator(OldI);
749 if (Orig->Probs.empty())
756 Predecessors.push_back(Pred);
761 assert(I != Predecessors.end() &&
"Pred is not a predecessor of this block!");
762 Predecessors.erase(I);
773 if (!FromMBB->Probs.empty()) {
774 auto Prob = *FromMBB->Probs.begin();
790 if (!FromMBB->Probs.empty()) {
791 auto Prob = *FromMBB->Probs.begin();
800 for (
unsigned i = 2, e = MI->
getNumOperands()+1; i != e; i += 2) {
802 if (MO.
getMBB() == FromMBB)
849 if (!TBB)
return &*Fallthrough;
855 return &*Fallthrough;
859 if (Cond.
empty())
return nullptr;
863 return (FBB ==
nullptr) ? &*Fallthrough :
nullptr;
889 Indexes->insertMBBInMaps(NMBB);
904 if (!OI->isReg() || OI->getReg() == 0 ||
905 !OI->isUse() || !OI->isKill() || OI->isUndef())
907 unsigned Reg = OI->getReg();
910 KilledRegs.push_back(Reg);
912 OI->setIsKill(
false);
925 if (!OI->isReg() || OI->getReg() == 0)
928 unsigned Reg = OI->getReg();
955 E = Terminators.
end();
I !=
E; ++
I) {
957 Indexes->removeMachineInstrFromMaps(**
I);
972 if (Indexes->hasIndex(MI))
973 Indexes->removeMachineInstrFromMaps(MI);
974 Indexes->insertMachineInstrInMaps(MI);
982 i != e && i->isPHI(); ++i)
983 for (
unsigned ni = 1, ne = i->getNumOperands(); ni != ne; ni += 2)
984 if (i->getOperand(ni+1).getMBB() ==
this)
985 i->getOperand(ni+1).setMBB(NMBB);
988 for (
const auto &LI : Succ->
liveins())
995 while (!KilledRegs.empty()) {
996 unsigned Reg = KilledRegs.pop_back_val();
998 if (!(--
I)->addRegisterKilled(Reg, TRI,
false))
1021 SlotIndex StartIndex = Indexes->getMBBEndIdx(
this);
1023 SlotIndex EndIndex = Indexes->getMBBEndIdx(NMBB);
1029 I !=
E &&
I->isPHI(); ++
I) {
1030 for (
unsigned ni = 1, ne =
I->getNumOperands(); ni != ne; ni += 2) {
1031 if (
I->getOperand(ni+1).getMBB() == NMBB) {
1041 "PHI sources should be live out of their predecessors.");
1054 if (!LI.
liveAt(PrevIndex))
1058 if (isLiveOut && isLastMBB) {
1060 assert(VNI &&
"LiveInterval should have VNInfo where it is live.");
1062 }
else if (!isLiveOut && !isLastMBB) {
1074 MDT->recordSplitCriticalEdge(
this, Succ, NMBB);
1080 if (
MachineLoop *DestLoop = MLI->getLoopFor(Succ)) {
1081 if (TIL == DestLoop) {
1083 DestLoop->addBasicBlockToLoop(NMBB, MLI->getBase());
1084 }
else if (TIL->contains(DestLoop)) {
1086 TIL->addBasicBlockToLoop(NMBB, MLI->getBase());
1087 }
else if (DestLoop->contains(TIL)) {
1089 DestLoop->addBasicBlockToLoop(NMBB, MLI->getBase());
1095 assert(DestLoop->getHeader() == Succ &&
1096 "Should not create irreducible loops!");
1098 P->addBasicBlockToLoop(NMBB, MLI->getBase());
1126 if (TII->
analyzeBranch(*const_cast<MachineBasicBlock *>(
this), TBB, FBB, Cond,
1134 if (TBB && TBB == FBB) {
1135 LLVM_DEBUG(
dbgs() <<
"Won't split critical edge after degenerate " 1158 return Insts.
erase(I);
1171 "Cannot insert instruction with bundle flags");
1173 if (I !=
instr_end() && I->isBundledWithPred()) {
1177 return Insts.
insert(I, MI);
1198 assert(Old != New &&
"Cannot replace self with self!");
1203 if (!I->isTerminator())
break;
1207 for (
unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
1208 if (I->getOperand(i).isMBB() &&
1209 I->getOperand(i).getMBB() == Old)
1210 I->getOperand(i).setMBB(New);
1241 bool Changed =
false;
1245 if (!DestA && !DestB) {
1249 }
else if (DestA && !DestB) {
1254 assert(DestA && DestB && IsCond &&
1255 "CFG in a bad state. Cannot correct CFG edges");
1264 if (!SeenMBBs.
insert(MBB).second ||
1265 (MBB != DestA && MBB != DestB && !MBB->
isEHPad())) {
1286 return MBBI->getDebugLoc();
1296 if (!MBBI->isDebugInstr())
return MBBI->getDebugLoc();
1306 while (TI !=
end() && !TI->isBranch())
1310 DL = TI->getDebugLoc();
1311 for (++TI ; TI !=
end() ; ++TI)
1324 const auto &Prob = *getProbabilityIterator(Succ);
1325 if (Prob.isUnknown()) {
1328 unsigned KnownProbNum = 0;
1330 for (
auto &
P : Probs) {
1331 if (!
P.isUnknown()) {
1336 return Sum.getCompl() / (Probs.size() - KnownProbNum);
1347 *getProbabilityIterator(I) = Prob;
1351 MachineBasicBlock::const_probability_iterator
1352 MachineBasicBlock::getProbabilityIterator(
1354 assert(Probs.size() == Successors.size() &&
"Async probability list!");
1355 const size_t index = std::distance(Successors.begin(),
I);
1356 assert(index < Probs.size() &&
"Not a current successor!");
1357 return Probs.begin() + index;
1361 MachineBasicBlock::probability_iterator
1363 assert(Probs.size() == Successors.size() &&
"Async probability list!");
1364 const size_t index = std::distance(Successors.begin(),
I);
1365 assert(index < Probs.size() &&
"Not a current successor!");
1366 return Probs.begin() + index;
1378 unsigned Neighborhood)
const {
1379 unsigned N = Neighborhood;
1383 for (; I !=
end() && N > 0; ++
I) {
1384 if (I->isDebugInstr())
1423 if (I->isDebugInstr())
1453 }
while (I !=
begin() && N > 0);
1491 "Liveness information is accurate");
1492 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
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)
This class represents lattice values for constants.
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. ...
static const DILocation * getMergedLocation(const DILocation *LocA, const DILocation *LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
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.
void push_back(const T &Elt)
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.
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.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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
Retuns the total number of operands.
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...
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...
Analysis containing CSE Info
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.
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.
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()
bool regsOverlap(unsigned regA, unsigned regB) const
Returns true if the two registers are equal or alias each other.
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.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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.