summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-03-01 01:26:01 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-03-01 01:26:01 +0000
commitd256c21666a883b2baafed84732a57f737223cfa (patch)
tree2aec7db9ccf4b027a05117cf640b9154a59ddada /llvm/include
parentaba3503639178eef6a1074b9ce8f44df4e7d0b8b (diff)
downloadbcm5719-llvm-d256c21666a883b2baafed84732a57f737223cfa.tar.gz
bcm5719-llvm-d256c21666a883b2baafed84732a57f737223cfa.zip
Move getBundleStart() into MachineInstrBundle.h.
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. llvm-svn: 151782
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/CodeGen/MachineInstr.h5
-rw-r--r--llvm/include/llvm/CodeGen/MachineInstrBundle.h18
-rw-r--r--llvm/include/llvm/CodeGen/SlotIndexes.h7
3 files changed, 19 insertions, 11 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h
index cd94abae7ec..7f29d316ea8 100644
--- a/llvm/include/llvm/CodeGen/MachineInstr.h
+++ b/llvm/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/llvm/include/llvm/CodeGen/MachineInstrBundle.h b/llvm/include/llvm/CodeGen/MachineInstrBundle.h
index 9552e21fca2..0fb49698227 100644
--- a/llvm/include/llvm/CodeGen/MachineInstrBundle.h
+++ b/llvm/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/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h
index 6c09526b59d..d868cb8dade 100644
--- a/llvm/include/llvm/CodeGen/SlotIndexes.h
+++ b/llvm/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;
}
OpenPOWER on IntegriCloud