diff options
-rw-r--r-- | include/llvm/CodeGen/MachineInstr.h | 5 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineInstrBundle.h | 18 | ||||
-rw-r--r-- | include/llvm/CodeGen/SlotIndexes.h | 7 | ||||
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/MachineInstr.cpp | 10 |
5 files changed, 20 insertions, 22 deletions
diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index cd94aba..7f29d31 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -234,11 +234,6 @@ public: /// 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; } diff --git a/include/llvm/CodeGen/MachineInstrBundle.h b/include/llvm/CodeGen/MachineInstrBundle.h index 9552e21..0fb4969 100644 --- a/include/llvm/CodeGen/MachineInstrBundle.h +++ b/include/llvm/CodeGen/MachineInstrBundle.h @@ -41,6 +41,22 @@ MachineBasicBlock::instr_iterator finalizeBundle(MachineBasicBlock &MBB, /// 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 // @@ -82,7 +98,7 @@ protected: /// explicit MachineOperandIteratorBase(MachineInstr *MI, bool WholeBundle) { if (WholeBundle) { - InstrI = MI->getBundleStart(); + InstrI = getBundleStart(MI); InstrE = MI->getParent()->instr_end(); } else { InstrI = InstrE = MI; diff --git a/include/llvm/CodeGen/SlotIndexes.h b/include/llvm/CodeGen/SlotIndexes.h index 6c09526..d868cb8 100644 --- a/include/llvm/CodeGen/SlotIndexes.h +++ b/include/llvm/CodeGen/SlotIndexes.h @@ -19,7 +19,7 @@ #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" @@ -495,10 +495,7 @@ namespace llvm { /// 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; } diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 03ca72e..3e16efa 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -1522,7 +1522,7 @@ void LiveIntervals::handleMove(MachineInstr* MI) { 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()) && diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 3ab98e1..ff32a66 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -900,16 +900,6 @@ bool MachineInstr::isBundled() const { 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(); |