Don't require BUNDLE headers in MachineInstr::getBundleSize().

It is possible to build MI bundles that don't begin with a BUNDLE
header. Add support for such bundles, counting all instructions inside
the bundle.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171985 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2013-01-09 18:28:16 +00:00
parent d9cc865787
commit 25377c8c6d
2 changed files with 10 additions and 11 deletions

View File

@ -699,7 +699,11 @@ public:
} }
} }
/// getBundleSize - Return the number of instructions inside the MI bundle. /// Return the number of instructions inside the MI bundle, excluding the
/// bundle header.
///
/// This is the number of instructions that MachineBasicBlock::iterator
/// skips, 0 for unbundled instructions.
unsigned getBundleSize() const; unsigned getBundleSize() const;
/// readsRegister - Return true if the MachineInstr reads the specified /// readsRegister - Return true if the MachineInstr reads the specified

View File

@ -982,18 +982,13 @@ MachineInstr::getRegClassConstraint(unsigned OpIdx,
return NULL; return NULL;
} }
/// getBundleSize - Return the number of instructions inside the MI bundle. /// Return the number of instructions inside the MI bundle, not counting the
/// header instruction.
unsigned MachineInstr::getBundleSize() const { unsigned MachineInstr::getBundleSize() const {
assert(isBundle() && "Expecting a bundle"); MachineBasicBlock::const_instr_iterator I = this;
const MachineBasicBlock *MBB = getParent();
MachineBasicBlock::const_instr_iterator I = *this, E = MBB->instr_end();
unsigned Size = 0; unsigned Size = 0;
while ((++I != E) && I->isInsideBundle()) { while (I->isBundledWithSucc())
++Size; ++Size, ++I;
}
assert(Size > 1 && "Malformed bundle");
return Size; return Size;
} }