diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
commit | 01095a5d43bbfde13731688ddcf6048ebb8b7721 (patch) | |
tree | 4def12e759965de927d963ac65840d663ef9d1ea /include/llvm/CodeGen/MachineBasicBlock.h | |
parent | f0f4822ed4b66e3579e92a89f368f8fb860e218e (diff) | |
download | src-01095a5d43bbfde13731688ddcf6048ebb8b7721.tar.gz src-01095a5d43bbfde13731688ddcf6048ebb8b7721.zip |
Vendor import of llvm release_39 branch r276489:vendor/llvm/llvm-release_39-r276489
Notes
Notes:
svn path=/vendor/llvm/dist/; revision=303231
svn path=/vendor/llvm/llvm-release_39-r276489/; revision=303232; tag=vendor/llvm/llvm-release_39-r276489
Diffstat (limited to 'include/llvm/CodeGen/MachineBasicBlock.h')
-rw-r--r-- | include/llvm/CodeGen/MachineBasicBlock.h | 95 |
1 files changed, 20 insertions, 75 deletions
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index 3d58c499823e..d5f918eb2bb9 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -15,6 +15,8 @@ #define LLVM_CODEGEN_MACHINEBASICBLOCK_H #include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/CodeGen/MachineInstrBundleIterator.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Support/BranchProbability.h" #include "llvm/MC/MCRegisterInfo.h" @@ -157,80 +159,14 @@ public: const MachineFunction *getParent() const { return xParent; } MachineFunction *getParent() { return xParent; } - /// MachineBasicBlock iterator that automatically skips over MIs that are - /// inside bundles (i.e. walk top level MIs only). - template<typename Ty, typename IterTy> - class bundle_iterator - : public std::iterator<std::bidirectional_iterator_tag, Ty, ptrdiff_t> { - IterTy MII; - - public: - bundle_iterator(IterTy MI) : MII(MI) {} - - bundle_iterator(Ty &MI) : MII(MI) { - assert(!MI.isBundledWithPred() && - "It's not legal to initialize bundle_iterator with a bundled MI"); - } - bundle_iterator(Ty *MI) : MII(MI) { - assert((!MI || !MI->isBundledWithPred()) && - "It's not legal to initialize bundle_iterator with a bundled MI"); - } - // Template allows conversion from const to nonconst. - template<class OtherTy, class OtherIterTy> - bundle_iterator(const bundle_iterator<OtherTy, OtherIterTy> &I) - : MII(I.getInstrIterator()) {} - bundle_iterator() : MII(nullptr) {} - - Ty &operator*() const { return *MII; } - Ty *operator->() const { return &operator*(); } - - operator Ty *() const { return MII.getNodePtrUnchecked(); } - - bool operator==(const bundle_iterator &X) const { - return MII == X.MII; - } - bool operator!=(const bundle_iterator &X) const { - return !operator==(X); - } - - // Increment and decrement operators... - bundle_iterator &operator--() { // predecrement - Back up - do --MII; - while (MII->isBundledWithPred()); - return *this; - } - bundle_iterator &operator++() { // preincrement - Advance - while (MII->isBundledWithSucc()) - ++MII; - ++MII; - return *this; - } - bundle_iterator operator--(int) { // postdecrement operators... - bundle_iterator tmp = *this; - --*this; - return tmp; - } - bundle_iterator operator++(int) { // postincrement operators... - bundle_iterator tmp = *this; - ++*this; - return tmp; - } - - IterTy getInstrIterator() const { - return MII; - } - }; - typedef Instructions::iterator instr_iterator; typedef Instructions::const_iterator const_instr_iterator; typedef std::reverse_iterator<instr_iterator> reverse_instr_iterator; typedef std::reverse_iterator<const_instr_iterator> const_reverse_instr_iterator; - typedef - bundle_iterator<MachineInstr,instr_iterator> iterator; - typedef - bundle_iterator<const MachineInstr,const_instr_iterator> const_iterator; + typedef MachineInstrBundleIterator<MachineInstr> iterator; + typedef MachineInstrBundleIterator<const MachineInstr> const_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator; @@ -257,6 +193,13 @@ 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; + instr_range instrs() { return instr_range(instr_begin(), instr_end()); } + const_instr_range instrs() const { + return const_instr_range(instr_begin(), instr_end()); + } + iterator begin() { return instr_begin(); } const_iterator begin() const { return instr_begin(); } iterator end () { return instr_end(); } @@ -399,10 +342,6 @@ public: /// via an exception handler. void setIsEHPad(bool V = true) { IsEHPad = V; } - /// If this block has a successor that is a landing pad, return it. Otherwise - /// return NULL. - const MachineBasicBlock *getLandingPadSuccessor() const; - bool hasEHPadSuccessor() const; /// Returns true if this is the entry block of an EH funclet. @@ -563,7 +502,13 @@ public: /// /// This function updates LiveVariables, MachineDominatorTree, and /// MachineLoopInfo, as applicable. - MachineBasicBlock *SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P); + MachineBasicBlock *SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P); + + /// Check if the edge between this block and the given successor \p + /// Succ, can be split. If this returns true a subsequent call to + /// SplitCriticalEdge is guaranteed to return a valid basic block if + /// no changes occured in the meantime. + bool canSplitCriticalEdge(const MachineBasicBlock *Succ) const; void pop_front() { Insts.pop_front(); } void pop_back() { Insts.pop_back(); } @@ -729,9 +674,9 @@ public: // Debugging methods. void dump() const; - void print(raw_ostream &OS, SlotIndexes* = nullptr) const; + void print(raw_ostream &OS, const SlotIndexes* = nullptr) const; void print(raw_ostream &OS, ModuleSlotTracker &MST, - SlotIndexes * = nullptr) const; + const SlotIndexes* = nullptr) const; // Printing method used by LoopInfo. void printAsOperand(raw_ostream &OS, bool PrintType = true) const; |