This allows the function to be inlined, and makes it suitable for use in
getInstructionIndex().
Also provide a const version. C++ is great for touch typing practice.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151782
91177308-0d34-0410-b5e6-
96231b3b80d8
/// if either itself or its following instruction is marked "InsideBundle".
bool isBundled() const;
- /// getBundleStart - If this instruction is inside a bundle return the
- /// instruction at the start of the bundle. Otherwise just returns the
- /// instruction itself.
- MachineInstr* getBundleStart();
-
/// getDebugLoc - Returns the debug location id of this MachineInstr.
///
DebugLoc getDebugLoc() const { return debugLoc; }
/// MachineFunction. Return true if any bundles are finalized.
bool finalizeBundles(MachineFunction &MF);
+/// getBundleStart - Returns the first instruction in the bundle containing MI.
+///
+static inline MachineInstr *getBundleStart(MachineInstr *MI) {
+ MachineBasicBlock::instr_iterator I = MI;
+ while (I->isInsideBundle())
+ --I;
+ return I;
+}
+
+static inline const MachineInstr *getBundleStart(const MachineInstr *MI) {
+ MachineBasicBlock::const_instr_iterator I = MI;
+ while (I->isInsideBundle())
+ --I;
+ return I;
+}
+
//===----------------------------------------------------------------------===//
// MachineOperand iterator
//
///
explicit MachineOperandIteratorBase(MachineInstr *MI, bool WholeBundle) {
if (WholeBundle) {
- InstrI = MI->getBundleStart();
+ InstrI = getBundleStart(MI);
InstrE = MI->getParent()->instr_end();
} else {
InstrI = InstrE = MI;
#ifndef LLVM_CODEGEN_SLOTINDEXES_H
#define LLVM_CODEGEN_SLOTINDEXES_H
-#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/ADT/PointerIntPair.h"
/// Returns the base index for the given instruction.
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);
+ Mi2IndexMap::const_iterator itr = mi2iMap.find(getBundleStart(MI));
assert(itr != mi2iMap.end() && "Instruction not found in maps.");
return itr->second;
}
SlotIndex OldIndex = indexes_->getInstructionIndex(MI);
indexes_->removeMachineInstrFromMaps(MI);
SlotIndex NewIndex = MI->isInsideBundle() ?
- indexes_->getInstructionIndex(MI->getBundleStart()) :
+ indexes_->getInstructionIndex(MI) :
indexes_->insertMachineInstrInMaps(MI);
assert(getMBBStartIdx(MI->getParent()) <= OldIndex &&
OldIndex < getMBBEndIdx(MI->getParent()) &&
return nextMI != Parent->instr_end() && nextMI->isInsideBundle();
}
-MachineInstr* MachineInstr::getBundleStart() {
- if (!isInsideBundle())
- return this;
- MachineBasicBlock::reverse_instr_iterator MII(this);
- ++MII;
- while (MII->isInsideBundle())
- ++MII;
- return &*MII;
-}
-
bool MachineInstr::isStackAligningInlineAsm() const {
if (isInlineAsm()) {
unsigned ExtraInfo = getOperand(InlineAsm::MIOp_ExtraInfo).getImm();