Refactor the code that checks that all operands of a node are UNDEFs.
[oota-llvm.git] / include / llvm / CodeGen / MachineInstrBundle.h
index 9552e21fca2b2661b18e7b133d143916be4df2cc..dc5f9a6ec82d13766355feece8638b74eeb2a997 100644 (file)
@@ -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.
+///
+inline MachineInstr *getBundleStart(MachineInstr *MI) {
+  MachineBasicBlock::instr_iterator I = MI;
+  while (I->isInsideBundle())
+    --I;
+  return I;
+}
+
+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;