diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-29 16:25:25 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-29 16:25:25 +0000 | 
| commit | ab44ce3d598882e51a25eb82eb7ae6308de85ae6 (patch) | |
| tree | 568d786a59d49bef961dcb9bd09d422701b9da5b /include/llvm/CodeGen/MachineBasicBlock.h | |
| parent | b5630dbadf9a2a06754194387d6b0fd9962a67f1 (diff) | |
Notes
Diffstat (limited to 'include/llvm/CodeGen/MachineBasicBlock.h')
| -rw-r--r-- | include/llvm/CodeGen/MachineBasicBlock.h | 121 | 
1 files changed, 66 insertions, 55 deletions
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index 18d40564856d..8da48c379d00 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/MachineBasicBlock.h ------------------------*- C++ -*-===// +//===- llvm/CodeGen/MachineBasicBlock.h -------------------------*- C++ -*-===//  //  //                     The LLVM Compiler Infrastructure  // @@ -15,41 +15,50 @@  #define LLVM_CODEGEN_MACHINEBASICBLOCK_H  #include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/ilist.h" +#include "llvm/ADT/ilist_node.h"  #include "llvm/ADT/iterator_range.h" +#include "llvm/ADT/simple_ilist.h"  #include "llvm/CodeGen/MachineInstrBundleIterator.h"  #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/IR/DebugLoc.h"  #include "llvm/Support/BranchProbability.h"  #include "llvm/MC/LaneBitmask.h"  #include "llvm/MC/MCRegisterInfo.h" -#include "llvm/Support/DataTypes.h" +#include <cassert> +#include <cstdint>  #include <functional> +#include <iterator> +#include <string> +#include <vector>  namespace llvm { -class Pass;  class BasicBlock;  class MachineFunction;  class MCSymbol; -class MIPrinter; +class ModuleSlotTracker; +class Pass;  class SlotIndexes;  class StringRef;  class raw_ostream; -class MachineBranchProbabilityInfo; +class TargetRegisterClass; +class TargetRegisterInfo;  template <> struct ilist_traits<MachineInstr> {  private:    friend class MachineBasicBlock; // Set by the owning MachineBasicBlock. +    MachineBasicBlock *Parent; -  typedef simple_ilist<MachineInstr, ilist_sentinel_tracking<true>>::iterator -      instr_iterator; +  using instr_iterator = +      simple_ilist<MachineInstr, ilist_sentinel_tracking<true>>::iterator;  public:    void addNodeToList(MachineInstr *N);    void removeNodeFromList(MachineInstr *N);    void transferNodesFromList(ilist_traits &OldList, instr_iterator First,                               instr_iterator Last); -    void deleteNode(MachineInstr *MI);  }; @@ -69,7 +78,8 @@ public:    };  private: -  typedef ilist<MachineInstr, ilist_sentinel_tracking<true>> Instructions; +  using Instructions = ilist<MachineInstr, ilist_sentinel_tracking<true>>; +    Instructions Insts;    const BasicBlock *BB;    int Number; @@ -83,12 +93,12 @@ private:    /// same order as Successors, or it is empty if we don't use it (disable    /// optimization).    std::vector<BranchProbability> Probs; -  typedef std::vector<BranchProbability>::iterator probability_iterator; -  typedef std::vector<BranchProbability>::const_iterator -      const_probability_iterator; +  using probability_iterator = std::vector<BranchProbability>::iterator; +  using const_probability_iterator = +      std::vector<BranchProbability>::const_iterator;    /// Keep track of the physical registers that are livein of the basicblock. -  typedef std::vector<RegisterMaskPair> LiveInVector; +  using LiveInVector = std::vector<RegisterMaskPair>;    LiveInVector LiveIns;    /// Alignment of the basic block. Zero if the basic block does not need to be @@ -113,7 +123,7 @@ private:    mutable MCSymbol *CachedMCSymbol = nullptr;    // Intrusive list support -  MachineBasicBlock() {} +  MachineBasicBlock() = default;    explicit MachineBasicBlock(MachineFunction &MF, const BasicBlock *BB); @@ -145,16 +155,16 @@ public:    const MachineFunction *getParent() const { return xParent; }    MachineFunction *getParent() { return xParent; } -  typedef Instructions::iterator                                 instr_iterator; -  typedef Instructions::const_iterator                     const_instr_iterator; -  typedef Instructions::reverse_iterator reverse_instr_iterator; -  typedef Instructions::const_reverse_iterator const_reverse_instr_iterator; +  using instr_iterator = Instructions::iterator; +  using const_instr_iterator = Instructions::const_iterator; +  using reverse_instr_iterator = Instructions::reverse_iterator; +  using const_reverse_instr_iterator = Instructions::const_reverse_iterator; -  typedef MachineInstrBundleIterator<MachineInstr> iterator; -  typedef MachineInstrBundleIterator<const MachineInstr> const_iterator; -  typedef MachineInstrBundleIterator<MachineInstr, true> reverse_iterator; -  typedef MachineInstrBundleIterator<const MachineInstr, true> -      const_reverse_iterator; +  using iterator = MachineInstrBundleIterator<MachineInstr>; +  using const_iterator = MachineInstrBundleIterator<const MachineInstr>; +  using reverse_iterator = MachineInstrBundleIterator<MachineInstr, true>; +  using const_reverse_iterator = +      MachineInstrBundleIterator<const MachineInstr, true>;    unsigned size() const { return (unsigned)Insts.size(); }    bool empty() const { return Insts.empty(); } @@ -178,8 +188,8 @@ public:    reverse_instr_iterator       instr_rend  ()       { return Insts.rend();   }    const_reverse_instr_iterator instr_rend  () const { return Insts.rend();   } -  typedef iterator_range<instr_iterator> instr_range; -  typedef iterator_range<const_instr_iterator> const_instr_range; +  using instr_range = iterator_range<instr_iterator>; +  using const_instr_range = iterator_range<const_instr_iterator>;    instr_range instrs() { return instr_range(instr_begin(), instr_end()); }    const_instr_range instrs() const {      return const_instr_range(instr_begin(), instr_end()); @@ -213,18 +223,18 @@ public:    }    // Machine-CFG iterators -  typedef std::vector<MachineBasicBlock *>::iterator       pred_iterator; -  typedef std::vector<MachineBasicBlock *>::const_iterator const_pred_iterator; -  typedef std::vector<MachineBasicBlock *>::iterator       succ_iterator; -  typedef std::vector<MachineBasicBlock *>::const_iterator const_succ_iterator; -  typedef std::vector<MachineBasicBlock *>::reverse_iterator -                                                         pred_reverse_iterator; -  typedef std::vector<MachineBasicBlock *>::const_reverse_iterator -                                                   const_pred_reverse_iterator; -  typedef std::vector<MachineBasicBlock *>::reverse_iterator -                                                         succ_reverse_iterator; -  typedef std::vector<MachineBasicBlock *>::const_reverse_iterator -                                                   const_succ_reverse_iterator; +  using pred_iterator = std::vector<MachineBasicBlock *>::iterator; +  using const_pred_iterator = std::vector<MachineBasicBlock *>::const_iterator; +  using succ_iterator = std::vector<MachineBasicBlock *>::iterator; +  using const_succ_iterator = std::vector<MachineBasicBlock *>::const_iterator; +  using pred_reverse_iterator = +      std::vector<MachineBasicBlock *>::reverse_iterator; +  using const_pred_reverse_iterator = +      std::vector<MachineBasicBlock *>::const_reverse_iterator; +  using succ_reverse_iterator = +      std::vector<MachineBasicBlock *>::reverse_iterator; +  using const_succ_reverse_iterator = +      std::vector<MachineBasicBlock *>::const_reverse_iterator;    pred_iterator        pred_begin()       { return Predecessors.begin(); }    const_pred_iterator  pred_begin() const { return Predecessors.begin(); }    pred_iterator        pred_end()         { return Predecessors.end();   } @@ -307,7 +317,7 @@ public:    // Iteration support for live in sets.  These sets are kept in sorted    // order by their register number. -  typedef LiveInVector::const_iterator livein_iterator; +  using livein_iterator = LiveInVector::const_iterator;  #ifndef NDEBUG    /// Unlike livein_begin, this method does not check that the liveness    /// information is accurate. Still for debug purposes it may be useful @@ -455,7 +465,6 @@ public:    /// other block.    bool isLayoutSuccessor(const MachineBasicBlock *MBB) const; -    /// Return the fallthrough block if the block can implicitly    /// transfer control to the block after it by falling off the end of    /// it.  This should return null if it can reach the block after @@ -695,7 +704,7 @@ public:    LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI,                                                unsigned Reg,                                                const_iterator Before, -                                              unsigned Neighborhood=10) const; +                                              unsigned Neighborhood = 10) const;    // Debugging methods.    void dump() const; @@ -714,7 +723,6 @@ public:    /// Return the MCSymbol for this basic block.    MCSymbol *getSymbol() const; -  private:    /// Return probability iterator corresponding to the I successor iterator.    probability_iterator getProbabilityIterator(succ_iterator I); @@ -764,8 +772,8 @@ struct MBB2NumberFunctor :  //  template <> struct GraphTraits<MachineBasicBlock *> { -  typedef MachineBasicBlock *NodeRef; -  typedef MachineBasicBlock::succ_iterator ChildIteratorType; +  using NodeRef = MachineBasicBlock *; +  using ChildIteratorType = MachineBasicBlock::succ_iterator;    static NodeRef getEntryNode(MachineBasicBlock *BB) { return BB; }    static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); } @@ -773,8 +781,8 @@ template <> struct GraphTraits<MachineBasicBlock *> {  };  template <> struct GraphTraits<const MachineBasicBlock *> { -  typedef const MachineBasicBlock *NodeRef; -  typedef MachineBasicBlock::const_succ_iterator ChildIteratorType; +  using NodeRef = const MachineBasicBlock *; +  using ChildIteratorType = MachineBasicBlock::const_succ_iterator;    static NodeRef getEntryNode(const MachineBasicBlock *BB) { return BB; }    static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); } @@ -787,28 +795,30 @@ template <> struct GraphTraits<const MachineBasicBlock *> {  // to be when traversing the predecessor edges of a MBB  // instead of the successor edges.  // -template <> struct GraphTraits<Inverse<MachineBasicBlock*> > { -  typedef MachineBasicBlock *NodeRef; -  typedef MachineBasicBlock::pred_iterator ChildIteratorType; +template <> struct GraphTraits<Inverse<MachineBasicBlock*>> { +  using NodeRef = MachineBasicBlock *; +  using ChildIteratorType = MachineBasicBlock::pred_iterator; +    static NodeRef getEntryNode(Inverse<MachineBasicBlock *> G) {      return G.Graph;    } +    static ChildIteratorType child_begin(NodeRef N) { return N->pred_begin(); }    static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }  }; -template <> struct GraphTraits<Inverse<const MachineBasicBlock*> > { -  typedef const MachineBasicBlock *NodeRef; -  typedef MachineBasicBlock::const_pred_iterator ChildIteratorType; +template <> struct GraphTraits<Inverse<const MachineBasicBlock*>> { +  using NodeRef = const MachineBasicBlock *; +  using ChildIteratorType = MachineBasicBlock::const_pred_iterator; +    static NodeRef getEntryNode(Inverse<const MachineBasicBlock *> G) {      return G.Graph;    } +    static ChildIteratorType child_begin(NodeRef N) { return N->pred_begin(); }    static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }  }; - -  /// MachineInstrSpan provides an interface to get an iteration range  /// containing the instruction it was initialized with, along with all  /// those instructions inserted prior to or following that instruction @@ -816,6 +826,7 @@ template <> struct GraphTraits<Inverse<const MachineBasicBlock*> > {  class MachineInstrSpan {    MachineBasicBlock &MBB;    MachineBasicBlock::iterator I, B, E; +  public:    MachineInstrSpan(MachineBasicBlock::iterator I)      : MBB(*I->getParent()), @@ -854,6 +865,6 @@ inline IterT skipDebugInstructionsBackward(IterT It, IterT Begin) {    return It;  } -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_CODEGEN_MACHINEBASICBLOCK_H  | 
