LLVM  10.0.0svn
MachineBasicBlock.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/MachineBasicBlock.h -------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Collect the sequence of machine instructions for a basic block.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H
14 #define LLVM_CODEGEN_MACHINEBASICBLOCK_H
15 
16 #include "llvm/ADT/GraphTraits.h"
17 #include "llvm/ADT/ilist.h"
18 #include "llvm/ADT/ilist_node.h"
20 #include "llvm/ADT/simple_ilist.h"
23 #include "llvm/IR/DebugLoc.h"
24 #include "llvm/MC/LaneBitmask.h"
25 #include "llvm/MC/MCRegisterInfo.h"
27 #include "llvm/Support/Printable.h"
28 #include <cassert>
29 #include <cstdint>
30 #include <functional>
31 #include <iterator>
32 #include <string>
33 #include <vector>
34 
35 namespace llvm {
36 
37 class BasicBlock;
38 class MachineFunction;
39 class MCSymbol;
40 class ModuleSlotTracker;
41 class Pass;
42 class SlotIndexes;
43 class StringRef;
44 class raw_ostream;
45 class TargetRegisterClass;
46 class TargetRegisterInfo;
47 
48 template <> struct ilist_traits<MachineInstr> {
49 private:
50  friend class MachineBasicBlock; // Set by the owning MachineBasicBlock.
51 
52  MachineBasicBlock *Parent;
53 
54  using instr_iterator =
56 
57 public:
61  instr_iterator Last);
62  void deleteNode(MachineInstr *MI);
63 };
64 
66  : public ilist_node_with_parent<MachineBasicBlock, MachineFunction> {
67 public:
68  /// Pair of physical register and lane mask.
69  /// This is not simply a std::pair typedef because the members should be named
70  /// clearly as they both have an integer type.
72  public:
75 
77  : PhysReg(PhysReg), LaneMask(LaneMask) {}
78  };
79 
80 private:
82 
83  Instructions Insts;
84  const BasicBlock *BB;
85  int Number;
86  MachineFunction *xParent;
87 
88  /// Keep track of the predecessor / successor basic blocks.
89  std::vector<MachineBasicBlock *> Predecessors;
90  std::vector<MachineBasicBlock *> Successors;
91 
92  /// Keep track of the probabilities to the successors. This vector has the
93  /// same order as Successors, or it is empty if we don't use it (disable
94  /// optimization).
95  std::vector<BranchProbability> Probs;
96  using probability_iterator = std::vector<BranchProbability>::iterator;
97  using const_probability_iterator =
98  std::vector<BranchProbability>::const_iterator;
99 
100  Optional<uint64_t> IrrLoopHeaderWeight;
101 
102  /// Keep track of the physical registers that are livein of the basicblock.
103  using LiveInVector = std::vector<RegisterMaskPair>;
104  LiveInVector LiveIns;
105 
106  /// Alignment of the basic block. One if the basic block does not need to be
107  /// aligned.
108  llvm::Align Alignment;
109 
110  /// Indicate that this basic block is entered via an exception handler.
111  bool IsEHPad = false;
112 
113  /// Indicate that this basic block is potentially the target of an indirect
114  /// branch.
115  bool AddressTaken = false;
116 
117  /// Indicate that this basic block needs its symbol be emitted regardless of
118  /// whether the flow just falls-through to it.
119  bool LabelMustBeEmitted = false;
120 
121  /// Indicate that this basic block is the entry block of an EH scope, i.e.,
122  /// the block that used to have a catchpad or cleanuppad instruction in the
123  /// LLVM IR.
124  bool IsEHScopeEntry = false;
125 
126  /// Indicate that this basic block is the entry block of an EH funclet.
127  bool IsEHFuncletEntry = false;
128 
129  /// Indicate that this basic block is the entry block of a cleanup funclet.
130  bool IsCleanupFuncletEntry = false;
131 
132  /// since getSymbol is a relatively heavy-weight operation, the symbol
133  /// is only computed once and is cached.
134  mutable MCSymbol *CachedMCSymbol = nullptr;
135 
136  // Intrusive list support
137  MachineBasicBlock() = default;
138 
139  explicit MachineBasicBlock(MachineFunction &MF, const BasicBlock *BB);
140 
142 
143  // MachineBasicBlocks are allocated and owned by MachineFunction.
144  friend class MachineFunction;
145 
146 public:
147  /// Return the LLVM basic block that this instance corresponded to originally.
148  /// Note that this may be NULL if this instance does not correspond directly
149  /// to an LLVM basic block.
150  const BasicBlock *getBasicBlock() const { return BB; }
151 
152  /// Return the name of the corresponding LLVM basic block, or an empty string.
153  StringRef getName() const;
154 
155  /// Return a formatted string to identify this block and its parent function.
156  std::string getFullName() const;
157 
158  /// Test whether this block is potentially the target of an indirect branch.
159  bool hasAddressTaken() const { return AddressTaken; }
160 
161  /// Set this block to reflect that it potentially is the target of an indirect
162  /// branch.
163  void setHasAddressTaken() { AddressTaken = true; }
164 
165  /// Test whether this block must have its label emitted.
166  bool hasLabelMustBeEmitted() const { return LabelMustBeEmitted; }
167 
168  /// Set this block to reflect that, regardless how we flow to it, we need
169  /// its label be emitted.
170  void setLabelMustBeEmitted() { LabelMustBeEmitted = true; }
171 
172  /// Return the MachineFunction containing this basic block.
173  const MachineFunction *getParent() const { return xParent; }
174  MachineFunction *getParent() { return xParent; }
175 
176  using instr_iterator = Instructions::iterator;
177  using const_instr_iterator = Instructions::const_iterator;
180 
184  using const_reverse_iterator =
186 
187  unsigned size() const { return (unsigned)Insts.size(); }
188  bool empty() const { return Insts.empty(); }
189 
190  MachineInstr &instr_front() { return Insts.front(); }
191  MachineInstr &instr_back() { return Insts.back(); }
192  const MachineInstr &instr_front() const { return Insts.front(); }
193  const MachineInstr &instr_back() const { return Insts.back(); }
194 
195  MachineInstr &front() { return Insts.front(); }
196  MachineInstr &back() { return *--end(); }
197  const MachineInstr &front() const { return Insts.front(); }
198  const MachineInstr &back() const { return *--end(); }
199 
200  instr_iterator instr_begin() { return Insts.begin(); }
201  const_instr_iterator instr_begin() const { return Insts.begin(); }
202  instr_iterator instr_end() { return Insts.end(); }
203  const_instr_iterator instr_end() const { return Insts.end(); }
204  reverse_instr_iterator instr_rbegin() { return Insts.rbegin(); }
205  const_reverse_instr_iterator instr_rbegin() const { return Insts.rbegin(); }
206  reverse_instr_iterator instr_rend () { return Insts.rend(); }
207  const_reverse_instr_iterator instr_rend () const { return Insts.rend(); }
208 
211  instr_range instrs() { return instr_range(instr_begin(), instr_end()); }
213  return const_instr_range(instr_begin(), instr_end());
214  }
215 
216  iterator begin() { return instr_begin(); }
217  const_iterator begin() const { return instr_begin(); }
218  iterator end () { return instr_end(); }
219  const_iterator end () const { return instr_end(); }
221  return reverse_iterator::getAtBundleBegin(instr_rbegin());
222  }
224  return const_reverse_iterator::getAtBundleBegin(instr_rbegin());
225  }
226  reverse_iterator rend() { return reverse_iterator(instr_rend()); }
228  return const_reverse_iterator(instr_rend());
229  }
230 
231  /// Support for MachineInstr::getNextNode().
233  return &MachineBasicBlock::Insts;
234  }
235 
237  return make_range(getFirstTerminator(), end());
238  }
240  return make_range(getFirstTerminator(), end());
241  }
242 
243  /// Returns a range that iterates over the phis in the basic block.
245  return make_range(begin(), getFirstNonPHI());
246  }
248  return const_cast<MachineBasicBlock *>(this)->phis();
249  }
250 
251  // Machine-CFG iterators
252  using pred_iterator = std::vector<MachineBasicBlock *>::iterator;
253  using const_pred_iterator = std::vector<MachineBasicBlock *>::const_iterator;
254  using succ_iterator = std::vector<MachineBasicBlock *>::iterator;
255  using const_succ_iterator = std::vector<MachineBasicBlock *>::const_iterator;
256  using pred_reverse_iterator =
257  std::vector<MachineBasicBlock *>::reverse_iterator;
259  std::vector<MachineBasicBlock *>::const_reverse_iterator;
260  using succ_reverse_iterator =
261  std::vector<MachineBasicBlock *>::reverse_iterator;
263  std::vector<MachineBasicBlock *>::const_reverse_iterator;
264  pred_iterator pred_begin() { return Predecessors.begin(); }
265  const_pred_iterator pred_begin() const { return Predecessors.begin(); }
266  pred_iterator pred_end() { return Predecessors.end(); }
267  const_pred_iterator pred_end() const { return Predecessors.end(); }
269  { return Predecessors.rbegin();}
271  { return Predecessors.rbegin();}
273  { return Predecessors.rend(); }
275  { return Predecessors.rend(); }
276  unsigned pred_size() const {
277  return (unsigned)Predecessors.size();
278  }
279  bool pred_empty() const { return Predecessors.empty(); }
280  succ_iterator succ_begin() { return Successors.begin(); }
281  const_succ_iterator succ_begin() const { return Successors.begin(); }
282  succ_iterator succ_end() { return Successors.end(); }
283  const_succ_iterator succ_end() const { return Successors.end(); }
285  { return Successors.rbegin(); }
287  { return Successors.rbegin(); }
289  { return Successors.rend(); }
291  { return Successors.rend(); }
292  unsigned succ_size() const {
293  return (unsigned)Successors.size();
294  }
295  bool succ_empty() const { return Successors.empty(); }
296 
298  return make_range(pred_begin(), pred_end());
299  }
301  return make_range(pred_begin(), pred_end());
302  }
304  return make_range(succ_begin(), succ_end());
305  }
307  return make_range(succ_begin(), succ_end());
308  }
309 
310  // LiveIn management methods.
311 
312  /// Adds the specified register as a live in. Note that it is an error to add
313  /// the same register to the same set more than once unless the intention is
314  /// to call sortUniqueLiveIns after all registers are added.
315  void addLiveIn(MCRegister PhysReg,
316  LaneBitmask LaneMask = LaneBitmask::getAll()) {
317  LiveIns.push_back(RegisterMaskPair(PhysReg, LaneMask));
318  }
319  void addLiveIn(const RegisterMaskPair &RegMaskPair) {
320  LiveIns.push_back(RegMaskPair);
321  }
322 
323  /// Sorts and uniques the LiveIns vector. It can be significantly faster to do
324  /// this than repeatedly calling isLiveIn before calling addLiveIn for every
325  /// LiveIn insertion.
326  void sortUniqueLiveIns();
327 
328  /// Clear live in list.
329  void clearLiveIns();
330 
331  /// Add PhysReg as live in to this block, and ensure that there is a copy of
332  /// PhysReg to a virtual register of class RC. Return the virtual register
333  /// that is a copy of the live in PhysReg.
334  unsigned addLiveIn(MCRegister PhysReg, const TargetRegisterClass *RC);
335 
336  /// Remove the specified register from the live in set.
337  void removeLiveIn(MCPhysReg Reg,
338  LaneBitmask LaneMask = LaneBitmask::getAll());
339 
340  /// Return true if the specified register is in the live in set.
341  bool isLiveIn(MCPhysReg Reg,
342  LaneBitmask LaneMask = LaneBitmask::getAll()) const;
343 
344  // Iteration support for live in sets. These sets are kept in sorted
345  // order by their register number.
346  using livein_iterator = LiveInVector::const_iterator;
347 #ifndef NDEBUG
348  /// Unlike livein_begin, this method does not check that the liveness
349  /// information is accurate. Still for debug purposes it may be useful
350  /// to have iterators that won't assert if the liveness information
351  /// is not current.
352  livein_iterator livein_begin_dbg() const { return LiveIns.begin(); }
354  return make_range(livein_begin_dbg(), livein_end());
355  }
356 #endif
357  livein_iterator livein_begin() const;
358  livein_iterator livein_end() const { return LiveIns.end(); }
359  bool livein_empty() const { return LiveIns.empty(); }
361  return make_range(livein_begin(), livein_end());
362  }
363 
364  /// Remove entry from the livein set and return iterator to the next.
365  livein_iterator removeLiveIn(livein_iterator I);
366 
367  /// Get the clobber mask for the start of this basic block. Funclets use this
368  /// to prevent register allocation across funclet transitions.
369  const uint32_t *getBeginClobberMask(const TargetRegisterInfo *TRI) const;
370 
371  /// Get the clobber mask for the end of the basic block.
372  /// \see getBeginClobberMask()
373  const uint32_t *getEndClobberMask(const TargetRegisterInfo *TRI) const;
374 
375  /// Return alignment of the basic block.
376  llvm::Align getAlignment() const { return Alignment; }
377 
378  /// Set alignment of the basic block.
379  void setAlignment(llvm::Align A) { Alignment = A; }
380 
381  /// Returns true if the block is a landing pad. That is this basic block is
382  /// entered via an exception handler.
383  bool isEHPad() const { return IsEHPad; }
384 
385  /// Indicates the block is a landing pad. That is this basic block is entered
386  /// via an exception handler.
387  void setIsEHPad(bool V = true) { IsEHPad = V; }
388 
389  bool hasEHPadSuccessor() const;
390 
391  /// Returns true if this is the entry block of an EH scope, i.e., the block
392  /// that used to have a catchpad or cleanuppad instruction in the LLVM IR.
393  bool isEHScopeEntry() const { return IsEHScopeEntry; }
394 
395  /// Indicates if this is the entry block of an EH scope, i.e., the block that
396  /// that used to have a catchpad or cleanuppad instruction in the LLVM IR.
397  void setIsEHScopeEntry(bool V = true) { IsEHScopeEntry = V; }
398 
399  /// Returns true if this is the entry block of an EH funclet.
400  bool isEHFuncletEntry() const { return IsEHFuncletEntry; }
401 
402  /// Indicates if this is the entry block of an EH funclet.
403  void setIsEHFuncletEntry(bool V = true) { IsEHFuncletEntry = V; }
404 
405  /// Returns true if this is the entry block of a cleanup funclet.
406  bool isCleanupFuncletEntry() const { return IsCleanupFuncletEntry; }
407 
408  /// Indicates if this is the entry block of a cleanup funclet.
409  void setIsCleanupFuncletEntry(bool V = true) { IsCleanupFuncletEntry = V; }
410 
411  /// Returns true if it is legal to hoist instructions into this block.
412  bool isLegalToHoistInto() const;
413 
414  // Code Layout methods.
415 
416  /// Move 'this' block before or after the specified block. This only moves
417  /// the block, it does not modify the CFG or adjust potential fall-throughs at
418  /// the end of the block.
419  void moveBefore(MachineBasicBlock *NewAfter);
420  void moveAfter(MachineBasicBlock *NewBefore);
421 
422  /// Update the terminator instructions in block to account for changes to the
423  /// layout. If the block previously used a fallthrough, it may now need a
424  /// branch, and if it previously used branching it may now be able to use a
425  /// fallthrough.
426  void updateTerminator();
427 
428  // Machine-CFG mutators
429 
430  /// Add Succ as a successor of this MachineBasicBlock. The Predecessors list
431  /// of Succ is automatically updated. PROB parameter is stored in
432  /// Probabilities list. The default probability is set as unknown. Mixing
433  /// known and unknown probabilities in successor list is not allowed. When all
434  /// successors have unknown probabilities, 1 / N is returned as the
435  /// probability for each successor, where N is the number of successors.
436  ///
437  /// Note that duplicate Machine CFG edges are not allowed.
438  void addSuccessor(MachineBasicBlock *Succ,
440 
441  /// Add Succ as a successor of this MachineBasicBlock. The Predecessors list
442  /// of Succ is automatically updated. The probability is not provided because
443  /// BPI is not available (e.g. -O0 is used), in which case edge probabilities
444  /// won't be used. Using this interface can save some space.
445  void addSuccessorWithoutProb(MachineBasicBlock *Succ);
446 
447  /// Set successor probability of a given iterator.
448  void setSuccProbability(succ_iterator I, BranchProbability Prob);
449 
450  /// Normalize probabilities of all successors so that the sum of them becomes
451  /// one. This is usually done when the current update on this MBB is done, and
452  /// the sum of its successors' probabilities is not guaranteed to be one. The
453  /// user is responsible for the correct use of this function.
454  /// MBB::removeSuccessor() has an option to do this automatically.
456  BranchProbability::normalizeProbabilities(Probs.begin(), Probs.end());
457  }
458 
459  /// Validate successors' probabilities and check if the sum of them is
460  /// approximate one. This only works in DEBUG mode.
461  void validateSuccProbs() const;
462 
463  /// Remove successor from the successors list of this MachineBasicBlock. The
464  /// Predecessors list of Succ is automatically updated.
465  /// If NormalizeSuccProbs is true, then normalize successors' probabilities
466  /// after the successor is removed.
467  void removeSuccessor(MachineBasicBlock *Succ,
468  bool NormalizeSuccProbs = false);
469 
470  /// Remove specified successor from the successors list of this
471  /// MachineBasicBlock. The Predecessors list of Succ is automatically updated.
472  /// If NormalizeSuccProbs is true, then normalize successors' probabilities
473  /// after the successor is removed.
474  /// Return the iterator to the element after the one removed.
475  succ_iterator removeSuccessor(succ_iterator I,
476  bool NormalizeSuccProbs = false);
477 
478  /// Replace successor OLD with NEW and update probability info.
479  void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New);
480 
481  /// Copy a successor (and any probability info) from original block to this
482  /// block's. Uses an iterator into the original blocks successors.
483  ///
484  /// This is useful when doing a partial clone of successors. Afterward, the
485  /// probabilities may need to be normalized.
486  void copySuccessor(MachineBasicBlock *Orig, succ_iterator I);
487 
488  /// Split the old successor into old plus new and updates the probability
489  /// info.
490  void splitSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New,
491  bool NormalizeSuccProbs = false);
492 
493  /// Transfers all the successors from MBB to this machine basic block (i.e.,
494  /// copies all the successors FromMBB and remove all the successors from
495  /// FromMBB).
496  void transferSuccessors(MachineBasicBlock *FromMBB);
497 
498  /// Transfers all the successors, as in transferSuccessors, and update PHI
499  /// operands in the successor blocks which refer to FromMBB to refer to this.
500  void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB);
501 
502  /// Return true if any of the successors have probabilities attached to them.
503  bool hasSuccessorProbabilities() const { return !Probs.empty(); }
504 
505  /// Return true if the specified MBB is a predecessor of this block.
506  bool isPredecessor(const MachineBasicBlock *MBB) const;
507 
508  /// Return true if the specified MBB is a successor of this block.
509  bool isSuccessor(const MachineBasicBlock *MBB) const;
510 
511  /// Return true if the specified MBB will be emitted immediately after this
512  /// block, such that if this block exits by falling through, control will
513  /// transfer to the specified MBB. Note that MBB need not be a successor at
514  /// all, for example if this block ends with an unconditional branch to some
515  /// other block.
516  bool isLayoutSuccessor(const MachineBasicBlock *MBB) const;
517 
518  /// Return the fallthrough block if the block can implicitly
519  /// transfer control to the block after it by falling off the end of
520  /// it. This should return null if it can reach the block after
521  /// it, but it uses an explicit branch to do so (e.g., a table
522  /// jump). Non-null return is a conservative answer.
523  MachineBasicBlock *getFallThrough();
524 
525  /// Return true if the block can implicitly transfer control to the
526  /// block after it by falling off the end of it. This should return
527  /// false if it can reach the block after it, but it uses an
528  /// explicit branch to do so (e.g., a table jump). True is a
529  /// conservative answer.
530  bool canFallThrough();
531 
532  /// Returns a pointer to the first instruction in this block that is not a
533  /// PHINode instruction. When adding instructions to the beginning of the
534  /// basic block, they should be added before the returned value, not before
535  /// the first instruction, which might be PHI.
536  /// Returns end() is there's no non-PHI instruction.
537  iterator getFirstNonPHI();
538 
539  /// Return the first instruction in MBB after I that is not a PHI or a label.
540  /// This is the correct point to insert lowered copies at the beginning of a
541  /// basic block that must be before any debugging information.
542  iterator SkipPHIsAndLabels(iterator I);
543 
544  /// Return the first instruction in MBB after I that is not a PHI, label or
545  /// debug. This is the correct point to insert copies at the beginning of a
546  /// basic block.
547  iterator SkipPHIsLabelsAndDebug(iterator I);
548 
549  /// Returns an iterator to the first terminator instruction of this basic
550  /// block. If a terminator does not exist, it returns end().
551  iterator getFirstTerminator();
553  return const_cast<MachineBasicBlock *>(this)->getFirstTerminator();
554  }
555 
556  /// Same getFirstTerminator but it ignores bundles and return an
557  /// instr_iterator instead.
558  instr_iterator getFirstInstrTerminator();
559 
560  /// Returns an iterator to the first non-debug instruction in the basic block,
561  /// or end().
562  iterator getFirstNonDebugInstr();
564  return const_cast<MachineBasicBlock *>(this)->getFirstNonDebugInstr();
565  }
566 
567  /// Returns an iterator to the last non-debug instruction in the basic block,
568  /// or end().
569  iterator getLastNonDebugInstr();
571  return const_cast<MachineBasicBlock *>(this)->getLastNonDebugInstr();
572  }
573 
574  /// Convenience function that returns true if the block ends in a return
575  /// instruction.
576  bool isReturnBlock() const {
577  return !empty() && back().isReturn();
578  }
579 
580  /// Convenience function that returns true if the bock ends in a EH scope
581  /// return instruction.
582  bool isEHScopeReturnBlock() const {
583  return !empty() && back().isEHScopeReturn();
584  }
585 
586  /// Split the critical edge from this block to the given successor block, and
587  /// return the newly created block, or null if splitting is not possible.
588  ///
589  /// This function updates LiveVariables, MachineDominatorTree, and
590  /// MachineLoopInfo, as applicable.
592 
593  /// Check if the edge between this block and the given successor \p
594  /// Succ, can be split. If this returns true a subsequent call to
595  /// SplitCriticalEdge is guaranteed to return a valid basic block if
596  /// no changes occurred in the meantime.
597  bool canSplitCriticalEdge(const MachineBasicBlock *Succ) const;
598 
599  void pop_front() { Insts.pop_front(); }
600  void pop_back() { Insts.pop_back(); }
601  void push_back(MachineInstr *MI) { Insts.push_back(MI); }
602 
603  /// Insert MI into the instruction list before I, possibly inside a bundle.
604  ///
605  /// If the insertion point is inside a bundle, MI will be added to the bundle,
606  /// otherwise MI will not be added to any bundle. That means this function
607  /// alone can't be used to prepend or append instructions to bundles. See
608  /// MIBundleBuilder::insert() for a more reliable way of doing that.
610 
611  /// Insert a range of instructions into the instruction list before I.
612  template<typename IT>
613  void insert(iterator I, IT S, IT E) {
614  assert((I == end() || I->getParent() == this) &&
615  "iterator points outside of basic block");
616  Insts.insert(I.getInstrIterator(), S, E);
617  }
618 
619  /// Insert MI into the instruction list before I.
621  assert((I == end() || I->getParent() == this) &&
622  "iterator points outside of basic block");
623  assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
624  "Cannot insert instruction with bundle flags");
625  return Insts.insert(I.getInstrIterator(), MI);
626  }
627 
628  /// Insert MI into the instruction list after I.
630  assert((I == end() || I->getParent() == this) &&
631  "iterator points outside of basic block");
632  assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
633  "Cannot insert instruction with bundle flags");
634  return Insts.insertAfter(I.getInstrIterator(), MI);
635  }
636 
637  /// If I is bundled then insert MI into the instruction list after the end of
638  /// the bundle, otherwise insert MI immediately after I.
640  assert((I == instr_end() || I->getParent() == this) &&
641  "iterator points outside of basic block");
642  assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
643  "Cannot insert instruction with bundle flags");
644  while (I->isBundledWithSucc())
645  ++I;
646  return Insts.insertAfter(I, MI);
647  }
648 
649  /// Remove an instruction from the instruction list and delete it.
650  ///
651  /// If the instruction is part of a bundle, the other instructions in the
652  /// bundle will still be bundled after removing the single instruction.
654 
655  /// Remove an instruction from the instruction list and delete it.
656  ///
657  /// If the instruction is part of a bundle, the other instructions in the
658  /// bundle will still be bundled after removing the single instruction.
660  return erase(instr_iterator(I));
661  }
662 
663  /// Remove a range of instructions from the instruction list and delete them.
665  return Insts.erase(I.getInstrIterator(), E.getInstrIterator());
666  }
667 
668  /// Remove an instruction or bundle from the instruction list and delete it.
669  ///
670  /// If I points to a bundle of instructions, they are all erased.
672  return erase(I, std::next(I));
673  }
674 
675  /// Remove an instruction from the instruction list and delete it.
676  ///
677  /// If I is the head of a bundle of instructions, the whole bundle will be
678  /// erased.
680  return erase(iterator(I));
681  }
682 
683  /// Remove the unbundled instruction from the instruction list without
684  /// deleting it.
685  ///
686  /// This function can not be used to remove bundled instructions, use
687  /// remove_instr to remove individual instructions from a bundle.
689  assert(!I->isBundled() && "Cannot remove bundled instructions");
690  return Insts.remove(instr_iterator(I));
691  }
692 
693  /// Remove the possibly bundled instruction from the instruction list
694  /// without deleting it.
695  ///
696  /// If the instruction is part of a bundle, the other instructions in the
697  /// bundle will still be bundled after removing the single instruction.
698  MachineInstr *remove_instr(MachineInstr *I);
699 
700  void clear() {
701  Insts.clear();
702  }
703 
704  /// Take an instruction from MBB 'Other' at the position From, and insert it
705  /// into this MBB right before 'Where'.
706  ///
707  /// If From points to a bundle of instructions, the whole bundle is moved.
709  // The range splice() doesn't allow noop moves, but this one does.
710  if (Where != From)
711  splice(Where, Other, From, std::next(From));
712  }
713 
714  /// Take a block of instructions from MBB 'Other' in the range [From, To),
715  /// and insert them into this MBB right before 'Where'.
716  ///
717  /// The instruction at 'Where' must not be included in the range of
718  /// instructions to move.
720  iterator From, iterator To) {
721  Insts.splice(Where.getInstrIterator(), Other->Insts,
722  From.getInstrIterator(), To.getInstrIterator());
723  }
724 
725  /// This method unlinks 'this' from the containing function, and returns it,
726  /// but does not delete it.
727  MachineBasicBlock *removeFromParent();
728 
729  /// This method unlinks 'this' from the containing function and deletes it.
730  void eraseFromParent();
731 
732  /// Given a machine basic block that branched to 'Old', change the code and
733  /// CFG so that it branches to 'New' instead.
734  void ReplaceUsesOfBlockWith(MachineBasicBlock *Old, MachineBasicBlock *New);
735 
736  /// Update all phi nodes in this basic block to refer to basic block \p New
737  /// instead of basic block \p Old.
738  void replacePhiUsesWith(MachineBasicBlock *Old, MachineBasicBlock *New);
739 
740  /// Various pieces of code can cause excess edges in the CFG to be inserted.
741  /// If we have proven that MBB can only branch to DestA and DestB, remove any
742  /// other MBB successors from the CFG. DestA and DestB can be null. Besides
743  /// DestA and DestB, retain other edges leading to LandingPads (currently
744  /// there can be only one; we don't check or require that here). Note it is
745  /// possible that DestA and/or DestB are LandingPads.
746  bool CorrectExtraCFGEdges(MachineBasicBlock *DestA,
747  MachineBasicBlock *DestB,
748  bool IsCond);
749 
750  /// Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE
751  /// and DBG_LABEL instructions. Return UnknownLoc if there is none.
752  DebugLoc findDebugLoc(instr_iterator MBBI);
754  return findDebugLoc(MBBI.getInstrIterator());
755  }
756 
757  /// Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE
758  /// instructions. Return UnknownLoc if there is none.
759  DebugLoc findPrevDebugLoc(instr_iterator MBBI);
761  return findPrevDebugLoc(MBBI.getInstrIterator());
762  }
763 
764  /// Find and return the merged DebugLoc of the branch instructions of the
765  /// block. Return UnknownLoc if there is none.
766  DebugLoc findBranchDebugLoc();
767 
768  /// Possible outcome of a register liveness query to computeRegisterLiveness()
770  LQR_Live, ///< Register is known to be (at least partially) live.
771  LQR_Dead, ///< Register is known to be fully dead.
772  LQR_Unknown ///< Register liveness not decidable from local neighborhood.
773  };
774 
775  /// Return whether (physical) register \p Reg has been defined and not
776  /// killed as of just before \p Before.
777  ///
778  /// Search is localised to a neighborhood of \p Neighborhood instructions
779  /// before (searching for defs or kills) and \p Neighborhood instructions
780  /// after (searching just for defs) \p Before.
781  ///
782  /// \p Reg must be a physical register.
783  LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI,
784  unsigned Reg,
785  const_iterator Before,
786  unsigned Neighborhood = 10) const;
787 
788  // Debugging methods.
789  void dump() const;
790  void print(raw_ostream &OS, const SlotIndexes * = nullptr,
791  bool IsStandalone = true) const;
792  void print(raw_ostream &OS, ModuleSlotTracker &MST,
793  const SlotIndexes * = nullptr, bool IsStandalone = true) const;
794 
795  // Printing method used by LoopInfo.
796  void printAsOperand(raw_ostream &OS, bool PrintType = true) const;
797 
798  /// MachineBasicBlocks are uniquely numbered at the function level, unless
799  /// they're not in a MachineFunction yet, in which case this will return -1.
800  int getNumber() const { return Number; }
801  void setNumber(int N) { Number = N; }
802 
803  /// Return the MCSymbol for this basic block.
804  MCSymbol *getSymbol() const;
805 
807  return IrrLoopHeaderWeight;
808  }
809 
810  void setIrrLoopHeaderWeight(uint64_t Weight) {
811  IrrLoopHeaderWeight = Weight;
812  }
813 
814 private:
815  /// Return probability iterator corresponding to the I successor iterator.
816  probability_iterator getProbabilityIterator(succ_iterator I);
817  const_probability_iterator
818  getProbabilityIterator(const_succ_iterator I) const;
819 
821  friend class MIPrinter;
822 
823  /// Return probability of the edge from this block to MBB. This method should
824  /// NOT be called directly, but by using getEdgeProbability method from
825  /// MachineBranchProbabilityInfo class.
826  BranchProbability getSuccProbability(const_succ_iterator Succ) const;
827 
828  // Methods used to maintain doubly linked list of blocks...
830 
831  // Machine-CFG mutators
832 
833  /// Add Pred as a predecessor of this MachineBasicBlock. Don't do this
834  /// unless you know what you're doing, because it doesn't update Pred's
835  /// successors list. Use Pred->addSuccessor instead.
836  void addPredecessor(MachineBasicBlock *Pred);
837 
838  /// Remove Pred as a predecessor of this MachineBasicBlock. Don't do this
839  /// unless you know what you're doing, because it doesn't update Pred's
840  /// successors list. Use Pred->removeSuccessor instead.
841  void removePredecessor(MachineBasicBlock *Pred);
842 };
843 
845 
846 /// Prints a machine basic block reference.
847 ///
848 /// The format is:
849 /// %bb.5 - a machine basic block with MBB.getNumber() == 5.
850 ///
851 /// Usage: OS << printMBBReference(MBB) << '\n';
853 
854 // This is useful when building IndexedMaps keyed on basic block pointers.
857  unsigned operator()(const MachineBasicBlock *MBB) const {
858  return MBB->getNumber();
859  }
860 };
861 
862 //===--------------------------------------------------------------------===//
863 // GraphTraits specializations for machine basic block graphs (machine-CFGs)
864 //===--------------------------------------------------------------------===//
865 
866 // Provide specializations of GraphTraits to be able to treat a
867 // MachineFunction as a graph of MachineBasicBlocks.
868 //
869 
870 template <> struct GraphTraits<MachineBasicBlock *> {
873 
874  static NodeRef getEntryNode(MachineBasicBlock *BB) { return BB; }
876  static ChildIteratorType child_end(NodeRef N) { return N->succ_end(); }
877 };
878 
879 template <> struct GraphTraits<const MachineBasicBlock *> {
880  using NodeRef = const MachineBasicBlock *;
882 
883  static NodeRef getEntryNode(const MachineBasicBlock *BB) { return BB; }
885  static ChildIteratorType child_end(NodeRef N) { return N->succ_end(); }
886 };
887 
888 // Provide specializations of GraphTraits to be able to treat a
889 // MachineFunction as a graph of MachineBasicBlocks and to walk it
890 // in inverse order. Inverse order for a function is considered
891 // to be when traversing the predecessor edges of a MBB
892 // instead of the successor edges.
893 //
894 template <> struct GraphTraits<Inverse<MachineBasicBlock*>> {
897 
899  return G.Graph;
900  }
901 
903  static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }
904 };
905 
907  using NodeRef = const MachineBasicBlock *;
909 
911  return G.Graph;
912  }
913 
915  static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }
916 };
917 
918 /// MachineInstrSpan provides an interface to get an iteration range
919 /// containing the instruction it was initialized with, along with all
920 /// those instructions inserted prior to or following that instruction
921 /// at some point after the MachineInstrSpan is constructed.
923  MachineBasicBlock &MBB;
925 
926 public:
928  : MBB(*BB), I(I), B(I == MBB.begin() ? MBB.end() : std::prev(I)),
929  E(std::next(I)) {
930  assert(I == BB->end() || I->getParent() == BB);
931  }
932 
934  return B == MBB.end() ? MBB.begin() : std::next(B);
935  }
937  bool empty() { return begin() == end(); }
938 
940 };
941 
942 /// Increment \p It until it points to a non-debug instruction or to \p End
943 /// and return the resulting iterator. This function should only be used
944 /// MachineBasicBlock::{iterator, const_iterator, instr_iterator,
945 /// const_instr_iterator} and the respective reverse iterators.
946 template<typename IterT>
947 inline IterT skipDebugInstructionsForward(IterT It, IterT End) {
948  while (It != End && It->isDebugInstr())
949  It++;
950  return It;
951 }
952 
953 /// Decrement \p It until it points to a non-debug instruction or to \p Begin
954 /// and return the resulting iterator. This function should only be used
955 /// MachineBasicBlock::{iterator, const_iterator, instr_iterator,
956 /// const_instr_iterator} and the respective reverse iterators.
957 template<class IterT>
958 inline IterT skipDebugInstructionsBackward(IterT It, IterT Begin) {
959  while (It != Begin && It->isDebugInstr())
960  It--;
961  return It;
962 }
963 
964 } // end namespace llvm
965 
966 #endif // LLVM_CODEGEN_MACHINEBASICBLOCK_H
Pass interface - Implemented by all &#39;passes&#39;.
Definition: Pass.h:80
pred_reverse_iterator pred_rbegin()
const_iterator getLastNonDebugInstr() const
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
bool hasSuccessorProbabilities() const
Return true if any of the successors have probabilities attached to them.
A common definition of LaneBitmask for use in TableGen and CodeGen.
pred_reverse_iterator pred_rend()
instr_iterator instr_begin()
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:22
instr_iterator instr_end()
instr_iterator insertAfterBundle(instr_iterator I, MachineInstr *MI)
If I is bundled then insert MI into the instruction list after the end of the bundle, otherwise insert MI immediately after I.
iterator erase(iterator where)
Definition: ilist.h:265
bool isEHScopeReturnBlock() const
Convenience function that returns true if the bock ends in a EH scope return instruction.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Various leaf nodes.
Definition: ISDOpcodes.h:59
void addNodeToList(NodeTy *)
When an MBB is added to an MF, we need to update the parent pointer of the MBB, the MBB numbering...
Definition: ilist.h:65
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
const_pred_reverse_iterator pred_rbegin() const
RegisterMaskPair(MCPhysReg PhysReg, LaneBitmask LaneMask)
void setIsEHPad(bool V=true)
Indicates the block is a landing pad.
MachineInstr & instr_front()
const_succ_iterator succ_begin() const
bool isBundledWithPred() const
Return true if this instruction is part of a bundle, and it is not the first instruction in the bundl...
Definition: MachineInstr.h:364
static ChildIteratorType child_begin(NodeRef N)
const_succ_reverse_iterator succ_rbegin() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
bool isCleanupFuncletEntry() const
Returns true if this is the entry block of a cleanup funclet.
void setIrrLoopHeaderWeight(uint64_t Weight)
MachineBasicBlock::succ_iterator ChildIteratorType
const_reverse_instr_iterator instr_rbegin() const
unsigned Reg
MachineInstr & instr_back()
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:952
iterator_range< iterator > phis()
Returns a range that iterates over the phis in the basic block.
iterator insertAfter(iterator I, MachineInstr *MI)
Insert MI into the instruction list after I.
Template traits for intrusive list.
Definition: ilist.h:89
const_pred_iterator pred_end() const
DebugLoc findDebugLoc(iterator MBBI)
unsigned const TargetRegisterInfo * TRI
A debug info location.
Definition: DebugLoc.h:33
Manage lifetime of a slot tracker for printing IR.
std::vector< MachineBasicBlock * >::const_iterator const_pred_iterator
iterator insert(iterator I, MachineInstr *MI)
Insert MI into the instruction list before I.
static ChildIteratorType child_begin(NodeRef N)
iterator_range< succ_iterator > successors()
void splice(iterator Where, MachineBasicBlock *Other, iterator From, iterator To)
Take a block of instructions from MBB &#39;Other&#39; in the range [From, To), and insert them into this MBB ...
const MachineInstr & back() const
MachineInstrSpan provides an interface to get an iteration range containing the instruction it was in...
Definition: BitVector.h:937
bool isReturnBlock() const
Convenience function that returns true if the block ends in a return instruction. ...
MachineBasicBlock::pred_iterator ChildIteratorType
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
static unsigned addLiveIn(MachineFunction &MF, unsigned PReg, const TargetRegisterClass *RC)
bool isBundledWithSucc() const
Return true if this instruction is part of a bundle, and it is not the last instruction in the bundle...
Definition: MachineInstr.h:368
iterator erase(MachineInstr *I)
Remove an instruction from the instruction list and delete it.
void insert(iterator I, IT S, IT E)
Insert a range of instructions into the instruction list before I.
static constexpr LaneBitmask getAll()
Definition: LaneBitmask.h:83
static StringRef getName(Value *V)
iterator_range< iterator > terminators()
LiveInVector::const_iterator livein_iterator
void setIsCleanupFuncletEntry(bool V=true)
Indicates if this is the entry block of a cleanup funclet.
MachineBasicBlock::iterator end()
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Definition: Interval.h:102
A simple intrusive list implementation.
Definition: simple_ilist.h:78
static ChildIteratorType child_end(NodeRef N)
SlotIndexes pass.
Definition: SlotIndexes.h:314
const_pred_reverse_iterator pred_rend() const
static void normalizeProbabilities(ProbabilityIter Begin, ProbabilityIter End)
const_succ_reverse_iterator succ_rend() const
static Instructions MachineBasicBlock::* getSublistAccess(MachineInstr *)
Support for MachineInstr::getNextNode().
BasicBlock * SplitCriticalEdge(Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions())
If this edge is a critical edge, insert a new node to split the critical edge.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they&#39;re not in a MachineFuncti...
succ_reverse_iterator succ_rend()
reverse_iterator rend()
reverse_iterator rbegin()
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
unsigned operator()(const MachineBasicBlock *MBB) const
Interval::succ_iterator succ_end(Interval *I)
Definition: Interval.h:105
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition: MCRegister.h:19
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
void setIsEHScopeEntry(bool V=true)
Indicates if this is the entry block of an EH scope, i.e., the block that that used to have a catchpa...
#define P(N)
std::vector< MachineBasicBlock * >::const_reverse_iterator const_succ_reverse_iterator
An ilist node that can access its parent list.
Definition: ilist_node.h:256
instr_iterator erase_instr(MachineInstr *I)
Remove an instruction from the instruction list and delete it.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
const_reverse_iterator rbegin() const
LLVM Basic Block Representation.
Definition: BasicBlock.h:57
static ChildIteratorType child_end(NodeRef N)
succ_reverse_iterator succ_rbegin()
bool isEHScopeEntry() const
Returns true if this is the entry block of an EH scope, i.e., the block that used to have a catchpad ...
static ChildIteratorType child_begin(NodeRef N)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void setAlignment(llvm::Align A)
Set alignment of the basic block.
livein_iterator livein_end() const
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Definition: Interval.h:112
Register is known to be fully dead.
void pop_front()
Definition: ilist.h:312
void splice(iterator where, iplist_impl &L2)
Definition: ilist.h:327
This class prints out the machine instructions using the MIR serialization format.
Definition: MIRPrinter.cpp:142
Interval::pred_iterator pred_end(Interval *I)
Definition: Interval.h:115
std::vector< MachineBasicBlock * >::const_iterator const_succ_iterator
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
MachineBasicBlock::const_succ_iterator ChildIteratorType
iterator_range< pred_iterator > predecessors()
std::vector< MachineBasicBlock * >::iterator pred_iterator
LivenessQueryResult
Possible outcome of a register liveness query to computeRegisterLiveness()
Register is known to be (at least partially) live.
bool hasAddressTaken() const
Test whether this block is potentially the target of an indirect branch.
iterator erase(iterator I)
Remove an instruction or bundle from the instruction list and delete it.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
iterator erase(iterator I, iterator E)
Remove a range of instructions from the instruction list and delete them.
An intrusive list with ownership and callbacks specified/controlled by ilist_traits, only with API safe for polymorphic types.
Definition: ilist.h:388
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:40
const_iterator begin() const
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:197
static BranchProbability getUnknown()
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
print lazy value Lazy Value Info Printer Pass
const MachineInstr & instr_back() const
Iterator for intrusive lists based on ilist_node.
const GraphType & Graph
Definition: GraphTraits.h:96
reverse_instr_iterator instr_rbegin()
iterator_range< const_iterator > phis() const
BlockVerifier::State From
void setLabelMustBeEmitted()
Set this block to reflect that, regardless how we flow to it, we need its label be emitted...
void removeNodeFromList(NodeTy *)
Definition: ilist.h:66
livein_iterator livein_begin_dbg() const
Unlike livein_begin, this method does not check that the liveness information is accurate.
const_instr_iterator instr_end() const
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
iterator_range< livein_iterator > liveins_dbg() const
MachineBasicBlock::iterator getInitial()
void addLiveIn(const RegisterMaskPair &RegMaskPair)
static void deleteNode(NodeTy *V)
Definition: ilist.h:41
unsigned pred_size() const
IterT skipDebugInstructionsBackward(IterT It, IterT Begin)
Decrement It until it points to a non-debug instruction or to Begin and return the resulting iterator...
llvm::Align getAlignment() const
Return alignment of the basic block.
reverse_instr_iterator instr_rend()
const_iterator getFirstTerminator() const
MachineBasicBlock::const_pred_iterator ChildIteratorType
A range adaptor for a pair of iterators.
static NodeRef getEntryNode(Inverse< MachineBasicBlock *> G)
void push_back(pointer val)
Definition: ilist.h:311
DebugLoc findPrevDebugLoc(iterator MBBI)
const MachineInstr & front() const
void setHasAddressTaken()
Set this block to reflect that it potentially is the target of an indirect branch.
std::vector< MachineBasicBlock * >::const_reverse_iterator const_pred_reverse_iterator
MachineFunction * getParent()
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...
iterator_range< const_succ_iterator > successors() const
void setIsEHFuncletEntry(bool V=true)
Indicates if this is the entry block of an EH funclet.
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::ZeroOrMore, cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate IT block based on arch"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow deprecated IT based on ARMv8"), clEnumValN(NoRestrictedIT, "arm-no-restrict-it", "Allow IT blocks based on ARMv7")))
iterator_range< const_pred_iterator > predecessors() const
Representation of each machine instruction.
Definition: MachineInstr.h:64
pointer remove(iterator &IT)
Definition: ilist.h:249
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
iterator insert(iterator where, pointer New)
Definition: ilist.h:226
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB &#39;Other&#39; at the position From, and insert it into this MBB right before &#39;...
void clear()
Definition: ilist.h:307
std::vector< MachineBasicBlock * >::reverse_iterator pred_reverse_iterator
bool isEHPad() const
Returns true if the block is a landing pad.
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
static NodeRef getEntryNode(const MachineBasicBlock *BB)
static NodeRef getEntryNode(Inverse< const MachineBasicBlock *> G)
void push_back(MachineInstr *MI)
#define I(x, y, z)
Definition: MD5.cpp:58
#define N
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Pair of physical register and lane mask.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
const_instr_iterator instr_begin() const
const_iterator end() const
const_succ_iterator succ_end() const
std::vector< MachineBasicBlock * >::reverse_iterator succ_reverse_iterator
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:2047
bool hasLabelMustBeEmitted() const
Test whether this block must have its label emitted.
iterator_range< livein_iterator > liveins() const
Instructions::iterator instr_iterator
const_iterator getFirstNonDebugInstr() const
iterator_range< const_iterator > terminators() const
Optional< uint64_t > getIrrLoopHeaderWeight() const
const_reverse_instr_iterator instr_rend() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static ChildIteratorType child_end(NodeRef N)
aarch64 promote const
const_instr_range instrs() const
const_pred_iterator pred_begin() const
Callbacks do nothing by default in iplist and ilist.
Definition: ilist.h:64
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Simple wrapper around std::function<void(raw_ostream&)>.
Definition: Printable.h:37
void pop_back()
Definition: ilist.h:316
iterator insertAfter(iterator where, pointer New)
Definition: ilist.h:235
Instructions::const_iterator const_instr_iterator
const_reverse_iterator rend() const
std::vector< MachineBasicBlock * >::iterator succ_iterator
MachineInstrSpan(MachineBasicBlock::iterator I, MachineBasicBlock *BB)
const MachineInstr & instr_front() const
static NodeRef getEntryNode(MachineBasicBlock *BB)
void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator)
Callback before transferring nodes to this list.
Definition: ilist.h:71
MachineBasicBlock::iterator begin()