Instructions inside a bundle have the same number as the bundle itself.

SlotIndexes are not assigned to instructions inside bundles, but it is
still valid to look up the index of those instructions.

The reverse getInstructionFromIndex() will return the first instruction
in the bundle.

llvm-svn: 151672
This commit is contained in:
Jakob Stoklund Olesen 2012-02-28 23:52:31 +00:00
parent 1df4b84db4
commit 3a184f903c
1 changed files with 6 additions and 2 deletions

View File

@ -493,8 +493,12 @@ namespace llvm {
}
/// Returns the base index for the given instruction.
SlotIndex getInstructionIndex(const MachineInstr *instr) const {
Mi2IndexMap::const_iterator itr = mi2iMap.find(instr);
SlotIndex getInstructionIndex(const MachineInstr *MI) const {
// Instructions inside a bundle have the same number as the bundle itself.
MachineBasicBlock::const_instr_iterator I = MI;
while (I->isInsideBundle())
--I;
Mi2IndexMap::const_iterator itr = mi2iMap.find(I);
assert(itr != mi2iMap.end() && "Instruction not found in maps.");
return itr->second;
}