mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 07:34:33 +00:00
Fix a problem with the reverse bundle iterators.
This showed up the first time rend() was called on a bundled instruction in the Mips backend. Also avoid dereferencing end() in bundle_iterator::operator++(). We still don't have a place to put unit tests for this stuff. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158310 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
773ef61299
commit
20aedcdfa3
@ -143,10 +143,7 @@ public:
|
||||
IterTy MII;
|
||||
|
||||
public:
|
||||
bundle_iterator(IterTy mii) : MII(mii) {
|
||||
assert(!MII->isInsideBundle() &&
|
||||
"It's not legal to initialize bundle_iterator with a bundled MI");
|
||||
}
|
||||
bundle_iterator(IterTy mii) : MII(mii) {}
|
||||
|
||||
bundle_iterator(Ty &mi) : MII(mi) {
|
||||
assert(!mi.isInsideBundle() &&
|
||||
@ -176,29 +173,24 @@ public:
|
||||
|
||||
// Increment and decrement operators...
|
||||
bundle_iterator &operator--() { // predecrement - Back up
|
||||
do {
|
||||
--MII;
|
||||
} while (MII->isInsideBundle());
|
||||
do --MII;
|
||||
while (MII->isInsideBundle());
|
||||
return *this;
|
||||
}
|
||||
bundle_iterator &operator++() { // preincrement - Advance
|
||||
do {
|
||||
++MII;
|
||||
} while (MII->isInsideBundle());
|
||||
IterTy E = MII->getParent()->instr_end();
|
||||
do ++MII;
|
||||
while (MII != E && MII->isInsideBundle());
|
||||
return *this;
|
||||
}
|
||||
bundle_iterator operator--(int) { // postdecrement operators...
|
||||
bundle_iterator tmp = *this;
|
||||
do {
|
||||
--MII;
|
||||
} while (MII->isInsideBundle());
|
||||
--*this;
|
||||
return tmp;
|
||||
}
|
||||
bundle_iterator operator++(int) { // postincrement operators...
|
||||
bundle_iterator tmp = *this;
|
||||
do {
|
||||
++MII;
|
||||
} while (MII->isInsideBundle());
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@ -238,42 +230,14 @@ public:
|
||||
reverse_instr_iterator instr_rend () { return Insts.rend(); }
|
||||
const_reverse_instr_iterator instr_rend () const { return Insts.rend(); }
|
||||
|
||||
iterator begin() { return Insts.begin(); }
|
||||
const_iterator begin() const { return Insts.begin(); }
|
||||
iterator end() {
|
||||
instr_iterator II = instr_end();
|
||||
if (II != instr_begin()) {
|
||||
while (II->isInsideBundle())
|
||||
--II;
|
||||
}
|
||||
return II;
|
||||
}
|
||||
const_iterator end() const {
|
||||
const_instr_iterator II = instr_end();
|
||||
if (II != instr_begin()) {
|
||||
while (II->isInsideBundle())
|
||||
--II;
|
||||
}
|
||||
return II;
|
||||
}
|
||||
reverse_iterator rbegin() {
|
||||
reverse_instr_iterator II = instr_rbegin();
|
||||
if (II != instr_rend()) {
|
||||
while (II->isInsideBundle())
|
||||
++II;
|
||||
}
|
||||
return II;
|
||||
}
|
||||
const_reverse_iterator rbegin() const {
|
||||
const_reverse_instr_iterator II = instr_rbegin();
|
||||
if (II != instr_rend()) {
|
||||
while (II->isInsideBundle())
|
||||
++II;
|
||||
}
|
||||
return II;
|
||||
}
|
||||
reverse_iterator rend () { return Insts.rend(); }
|
||||
const_reverse_iterator rend () const { return Insts.rend(); }
|
||||
iterator begin() { return instr_begin(); }
|
||||
const_iterator begin() const { return instr_begin(); }
|
||||
iterator end () { return instr_end(); }
|
||||
const_iterator end () const { return instr_end(); }
|
||||
reverse_iterator rbegin() { return instr_rbegin(); }
|
||||
const_reverse_iterator rbegin() const { return instr_rbegin(); }
|
||||
reverse_iterator rend () { return instr_rend(); }
|
||||
const_reverse_iterator rend () const { return instr_rend(); }
|
||||
|
||||
|
||||
// Machine-CFG iterators
|
||||
|
Loading…
x
Reference in New Issue
Block a user