Add a getBundleEnd() function to go with the existing getBundleStart().

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
This commit is contained in:
Jakob Stoklund Olesen 2013-01-09 01:02:19 +00:00
parent c3d6de2fe5
commit d700a2f9c5
2 changed files with 22 additions and 7 deletions

View File

@ -18,6 +18,7 @@
#define LLVM_CODEGEN_MACHINEINSTRBUILDER_H #define LLVM_CODEGEN_MACHINEINSTRBUILDER_H
#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
namespace llvm { namespace llvm {
@ -391,11 +392,7 @@ public:
/// Create an MIBundleBuilder representing an existing instruction or bundle /// Create an MIBundleBuilder representing an existing instruction or bundle
/// that has MI as its head. /// that has MI as its head.
explicit MIBundleBuilder(MachineInstr *MI) explicit MIBundleBuilder(MachineInstr *MI)
: MBB(*MI->getParent()), Begin(MI) { : MBB(*MI->getParent()), Begin(MI), End(getBundleEnd(MI)) {}
MachineBasicBlock::iterator I = MI;
++I;
End = I.getInstrIterator();
}
/// Return a reference to the basic block containing this bundle. /// Return a reference to the basic block containing this bundle.
MachineBasicBlock &getMBB() const { return MBB; } MachineBasicBlock &getMBB() const { return MBB; }

View File

@ -45,18 +45,36 @@ bool finalizeBundles(MachineFunction &MF);
/// ///
inline MachineInstr *getBundleStart(MachineInstr *MI) { inline MachineInstr *getBundleStart(MachineInstr *MI) {
MachineBasicBlock::instr_iterator I = MI; MachineBasicBlock::instr_iterator I = MI;
while (I->isInsideBundle()) while (I->isBundledWithPred())
--I; --I;
return I; return I;
} }
inline const MachineInstr *getBundleStart(const MachineInstr *MI) { inline const MachineInstr *getBundleStart(const MachineInstr *MI) {
MachineBasicBlock::const_instr_iterator I = MI; MachineBasicBlock::const_instr_iterator I = MI;
while (I->isInsideBundle()) while (I->isBundledWithPred())
--I; --I;
return 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 // MachineOperand iterator
// //