diff options
author | Mark Lacey <mark.lacey@apple.com> | 2013-08-14 23:50:11 +0000 |
---|---|---|
committer | Mark Lacey <mark.lacey@apple.com> | 2013-08-14 23:50:11 +0000 |
commit | 3bbd96e90be56c39a0b527fc6d5ccd8af4426a03 (patch) | |
tree | 78fe6f719f813d58a3ddf17e0c552a5f041e1714 /include/llvm | |
parent | 03fe68e0a9c0fdd196f62899cb44b6f9a56dd7c8 (diff) | |
download | external_llvm-3bbd96e90be56c39a0b527fc6d5ccd8af4426a03.zip external_llvm-3bbd96e90be56c39a0b527fc6d5ccd8af4426a03.tar.gz external_llvm-3bbd96e90be56c39a0b527fc6d5ccd8af4426a03.tar.bz2 |
Add the MachineInstrSpan class.
MachineInstrSpan is initialized with a MachineBasicBlock::iterator,
and is intended to track which instructions are inserted before/after
that instruction from the time the MachineInstrSpan is created.
It provides a begin()/end() interface to walk the range of
instructions inserted around the initial instruction (including that
initial instruction).
It also provides a getInitial() interface to return the initial
iterator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188436 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/CodeGen/MachineBasicBlock.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index d6f5883..e126f86 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -733,6 +733,31 @@ template <> struct GraphTraits<Inverse<const MachineBasicBlock*> > { } }; + + +/// MachineInstrSpan provides an interface to get an iteration range +/// containing the instruction it was initialized with, along with all +/// those instructions inserted prior to or following that instruction +/// at some point after the MachineInstrSpan is constructed. +class MachineInstrSpan { + MachineBasicBlock &MBB; + MachineBasicBlock::iterator I, B, E; +public: + MachineInstrSpan(MachineBasicBlock::iterator I) + : MBB(*I->getParent()), + I(I), + B(I == MBB.begin() ? MBB.end() : llvm::prior(I)), + E(llvm::next(I)) {} + + MachineBasicBlock::iterator begin() { + return B == MBB.end() ? MBB.begin() : llvm::next(B); + } + MachineBasicBlock::iterator end() { return E; } + bool empty() { return begin() == end(); } + + MachineBasicBlock::iterator getInitial() { return I; } +}; + } // End llvm namespace #endif |