Add a getBundleEnd() function to go with the existing getBundleStart().
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 9 Jan 2013 01:02:19 +0000 (01:02 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 9 Jan 2013 01:02:19 +0000 (01:02 +0000)
This is easier implemented now that bundle flags are symmetric.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171927 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineInstrBuilder.h
include/llvm/CodeGen/MachineInstrBundle.h

index a2d3d63bdbbd11e063f757fdc28688532fca6f5e..92c8da991ca44da3a79d2d2cf5ac45e3c32cd2fa 100644 (file)
@@ -18,6 +18,7 @@
 #define LLVM_CODEGEN_MACHINEINSTRBUILDER_H
 
 #include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineInstrBundle.h"
 #include "llvm/Support/ErrorHandling.h"
 
 namespace llvm {
@@ -391,11 +392,7 @@ public:
   /// Create an MIBundleBuilder representing an existing instruction or bundle
   /// that has MI as its head.
   explicit MIBundleBuilder(MachineInstr *MI)
-    : MBB(*MI->getParent()), Begin(MI) {
-    MachineBasicBlock::iterator I = MI;
-    ++I;
-    End = I.getInstrIterator();
-  }
+    : MBB(*MI->getParent()), Begin(MI), End(getBundleEnd(MI)) {}
 
   /// Return a reference to the basic block containing this bundle.
   MachineBasicBlock &getMBB() const { return MBB; }
index 3c60ad1f29531a67d357f8d2a7bb94ad6ad3a1c3..9519edb3ebaeea55a36d448dfc452eb70b805a6c 100644 (file)
@@ -45,18 +45,36 @@ bool finalizeBundles(MachineFunction &MF);
 ///
 inline MachineInstr *getBundleStart(MachineInstr *MI) {
   MachineBasicBlock::instr_iterator I = MI;
-  while (I->isInsideBundle())
+  while (I->isBundledWithPred())
     --I;
   return I;
 }
 
 inline const MachineInstr *getBundleStart(const MachineInstr *MI) {
   MachineBasicBlock::const_instr_iterator I = MI;
-  while (I->isInsideBundle())
+  while (I->isBundledWithPred())
     --I;
   return I;
 }
 
+/// Return an iterator pointing beyond the bundle containing MI.
+inline MachineBasicBlock::instr_iterator
+getBundleEnd(MachineInstr *MI) {
+  MachineBasicBlock::instr_iterator I = MI;
+  while (I->isBundledWithSucc())
+    ++I;
+  return ++I;
+}
+
+/// Return an iterator pointing beyond the bundle containing MI.
+inline MachineBasicBlock::const_instr_iterator
+getBundleEnd(const MachineInstr *MI) {
+  MachineBasicBlock::const_instr_iterator I = MI;
+  while (I->isBundledWithSucc())
+    ++I;
+  return ++I;
+}
+
 //===----------------------------------------------------------------------===//
 // MachineOperand iterator
 //