diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-02-29 00:33:41 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-02-29 00:33:41 +0000 |
commit | 30e98a03a3c524026e2da2607e04bb655b0b6350 (patch) | |
tree | 918eb0da58d10019f3f26e1de5fb0eb955db2f8b /include/llvm/CodeGen/MachineBasicBlock.h | |
parent | d1d721660edf3f4e76ea69fd5579f857b97a3150 (diff) |
Move the operand iterator into MachineInstrBundle.h where it belongs.
Extract a base class and provide four specific sub-classes for iterating
over const/non-const bundles/instructions.
This eliminates the mystery bool constructor argument.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineBasicBlock.h')
-rw-r--r-- | include/llvm/CodeGen/MachineBasicBlock.h | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index 1138f92bf8..576ce94446 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -699,73 +699,6 @@ template <> struct GraphTraits<Inverse<const MachineBasicBlock*> > { } }; -//===----------------------------------------------------------------------===// -// MachineOperand iterator -// - -/// MachineOperands - Iterator that can visit all operands on a MachineInstr, -/// or all operands on a bundle of MachineInstrs. -/// -/// Intended use: -/// -/// for (MIOperands MIO(MI, true); MIO.isValid(); ++MIO) { -/// if (!MIO->isReg()) -/// continue; -/// ... -/// } -/// -class MIOperands { - MachineBasicBlock::instr_iterator InstrI, InstrE; - MachineInstr::mop_iterator OpI, OpE; - - // If the operands on InstrI are exhausted, advance InstrI to the next - // bundled instruction with operands. - void advance() { - while (OpI == OpE) { - // Don't advance off the basic block, or into a new bundle. - if (++InstrI == InstrE || !InstrI->isInsideBundle()) - break; - OpI = InstrI->operands_begin(); - OpE = InstrI->operands_end(); - } - } - -public: - /// MIOperands - Create an iterator that visits all operands on MI, or all - /// operands on every instruction in the bundle containing MI. - /// - /// @param MI The instruction to examine. - /// @param WholeBundle When true, visit all operands on the entire bundle. - /// - explicit MIOperands(MachineInstr *MI, bool WholeBundle = false) { - if (WholeBundle) { - InstrI = MI->getBundleStart(); - InstrE = MI->getParent()->instr_end(); - } else { - InstrI = InstrE = MI; - ++InstrE; - } - OpI = InstrI->operands_begin(); - OpE = InstrI->operands_end(); - if (WholeBundle) - advance(); - } - - /// isValid - Returns true until all the operands have been visited. - bool isValid() const { return OpI != OpE; } - - /// Preincrement. Move to the next operand. - MIOperands &operator++() { - assert(isValid() && "Cannot advance MIOperands beyond the last operand"); - ++OpI; - advance(); - return *this; - } - - MachineOperand &operator* () const { return *OpI; } - MachineOperand *operator->() const { return &*OpI; } -}; - } // End llvm namespace #endif |