aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineInstrBundle.h
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
commit741981adf3a2bc0c6652c9c4ec846250950f3e68 (patch)
treeff48140195f34e487c7ea9178a12a397e04b8c37 /include/llvm/CodeGen/MachineInstrBundle.h
parentb519a0fe0ee02804cc77cb9c40ded6604341b71c (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151782 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineInstrBundle.h')
-rw-r--r--include/llvm/CodeGen/MachineInstrBundle.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/llvm/CodeGen/MachineInstrBundle.h b/include/llvm/CodeGen/MachineInstrBundle.h
index 9552e21fca..0fb4969822 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;