mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 17:31:33 +00:00
Fixes for BB iterators, additional methods added for DCE pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
753bfecb77
commit
bbcfc51f3b
@ -148,7 +148,16 @@ public:
|
|||||||
typedef bidirectional_iterator_tag iterator_category;
|
typedef bidirectional_iterator_tag iterator_category;
|
||||||
typedef _Ptr pointer;
|
typedef _Ptr pointer;
|
||||||
|
|
||||||
inline PredIterator(_Ptr BB) : ThisBB(BB), It(BB->use_begin()) {}
|
inline void advancePastConstPool() {
|
||||||
|
// Loop to ignore constant pool references
|
||||||
|
while (It != ThisBB->use_end() &&
|
||||||
|
((*It)->getValueType() != Value::InstructionVal))
|
||||||
|
++It;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline PredIterator(_Ptr BB) : ThisBB(BB), It(BB->use_begin()) {
|
||||||
|
advancePastConstPool();
|
||||||
|
}
|
||||||
inline PredIterator(_Ptr BB, bool) : ThisBB(BB), It(BB->use_end()) {}
|
inline PredIterator(_Ptr BB, bool) : ThisBB(BB), It(BB->use_end()) {}
|
||||||
|
|
||||||
inline bool operator==(const _Self& x) const { return It == x.It; }
|
inline bool operator==(const _Self& x) const { return It == x.It; }
|
||||||
@ -161,13 +170,7 @@ public:
|
|||||||
inline pointer *operator->() const { return &(operator*()); }
|
inline pointer *operator->() const { return &(operator*()); }
|
||||||
|
|
||||||
inline _Self& operator++() { // Preincrement
|
inline _Self& operator++() { // Preincrement
|
||||||
do { // Loop to ignore constant pool references
|
++It; advancePastConstPool();
|
||||||
++It;
|
|
||||||
} while (It != ThisBB->use_end() &&
|
|
||||||
((*It)->getValueType() != Value::ConstantVal));
|
|
||||||
|
|
||||||
// DOES THIS WORK???
|
|
||||||
//((*It)->getValueType() != Value::BasicBlockVal));
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
typedef list<User*>::iterator use_iterator;
|
typedef list<User*>::iterator use_iterator;
|
||||||
typedef list<User*>::const_iterator use_const_iterator;
|
typedef list<User*>::const_iterator use_const_iterator;
|
||||||
|
|
||||||
inline bool use_size() const { return Uses.size(); }
|
inline unsigned use_size() const { return Uses.size(); }
|
||||||
inline bool use_empty() const { return Uses.empty(); }
|
inline bool use_empty() const { return Uses.empty(); }
|
||||||
inline use_iterator use_begin() { return Uses.begin(); }
|
inline use_iterator use_begin() { return Uses.begin(); }
|
||||||
inline use_const_iterator use_begin() const { return Uses.begin(); }
|
inline use_const_iterator use_begin() const { return Uses.begin(); }
|
||||||
|
@ -65,10 +65,9 @@ public:
|
|||||||
inline const_iterator end() const { return ValueList.end(); }
|
inline const_iterator end() const { return ValueList.end(); }
|
||||||
|
|
||||||
void delete_all() { // Delete all removes and deletes all elements
|
void delete_all() { // Delete all removes and deletes all elements
|
||||||
// TODO: REMOVE FROM END OF VECTOR!!!
|
while (!empty()) {
|
||||||
while (begin() != end()) {
|
iterator it = end();
|
||||||
iterator I = begin();
|
delete remove(--it); // Delete all instructions...
|
||||||
delete remove(I); // Delete all instructions...
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +75,9 @@ public:
|
|||||||
// specified by the iterator, and leaves the iterator pointing to the element
|
// specified by the iterator, and leaves the iterator pointing to the element
|
||||||
// that used to follow the element deleted.
|
// that used to follow the element deleted.
|
||||||
//
|
//
|
||||||
ValueSubclass *remove(iterator &DI); // Defined in ValueHolderImpl.h
|
ValueSubclass *remove(iterator &DI); // Defined in ValueHolderImpl.h
|
||||||
void remove(ValueSubclass *D); // Defined in ValueHolderImpl.h
|
ValueSubclass *remove(const iterator &DI); // Defined in ValueHolderImpl.h
|
||||||
|
void remove(ValueSubclass *D); // Defined in ValueHolderImpl.h
|
||||||
|
|
||||||
inline void push_front(ValueSubclass *Inst); // Defined in ValueHolderImpl.h
|
inline void push_front(ValueSubclass *Inst); // Defined in ValueHolderImpl.h
|
||||||
inline void push_back(ValueSubclass *Inst); // Defined in ValueHolderImpl.h
|
inline void push_back(ValueSubclass *Inst); // Defined in ValueHolderImpl.h
|
||||||
|
@ -50,7 +50,12 @@ public:
|
|||||||
virtual bool setOperand(unsigned i, Value *Val);
|
virtual bool setOperand(unsigned i, Value *Val);
|
||||||
virtual string getOpcode() const { return "phi"; }
|
virtual string getOpcode() const { return "phi"; }
|
||||||
|
|
||||||
|
// addIncoming - Add an incoming value to the end of the PHI list
|
||||||
void addIncoming(Value *D);
|
void addIncoming(Value *D);
|
||||||
|
|
||||||
|
// removeIncomingValue - Remove an incoming value. This is useful if a
|
||||||
|
// predecessor basic block is deleted. The value removed is returned.
|
||||||
|
Value *removeIncomingValue(unsigned idx);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ void ValueHolder<ValueSubclass,ItemParentType>::remove(ValueSubclass *D) {
|
|||||||
remove(I);
|
remove(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValueHolder::remove(iterator &) this removes the element at the location specified
|
// ValueHolder::remove(iterator &) this removes the element at the location
|
||||||
// by the iterator, and leaves the iterator pointing to the element that used to follow
|
// specified by the iterator, and leaves the iterator pointing to the element
|
||||||
// the element deleted.
|
// that used to follow the element deleted.
|
||||||
//
|
//
|
||||||
template<class ValueSubclass, class ItemParentType>
|
template<class ValueSubclass, class ItemParentType>
|
||||||
ValueSubclass *ValueHolder<ValueSubclass,ItemParentType>::remove(iterator &DI) {
|
ValueSubclass *ValueHolder<ValueSubclass,ItemParentType>::remove(iterator &DI) {
|
||||||
@ -59,6 +59,24 @@ ValueSubclass *ValueHolder<ValueSubclass,ItemParentType>::remove(iterator &DI) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class ValueSubclass, class ItemParentType>
|
||||||
|
ValueSubclass *ValueHolder<ValueSubclass,ItemParentType>
|
||||||
|
::remove(const iterator &DI) {
|
||||||
|
assert(DI != ValueList.end() &&
|
||||||
|
"Trying to remove the end of the def list!!!");
|
||||||
|
|
||||||
|
ValueSubclass *i = *DI;
|
||||||
|
ValueList.erase(DI);
|
||||||
|
|
||||||
|
i->setParent(0); // I don't own you anymore... byebye...
|
||||||
|
|
||||||
|
// You don't get to be in the symbol table anymore... byebye
|
||||||
|
if (i->hasName() && Parent)
|
||||||
|
Parent->getSymbolTable()->remove(i);
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
template<class ValueSubclass, class ItemParentType>
|
template<class ValueSubclass, class ItemParentType>
|
||||||
void ValueHolder<ValueSubclass,ItemParentType>::push_front(ValueSubclass *Inst) {
|
void ValueHolder<ValueSubclass,ItemParentType>::push_front(ValueSubclass *Inst) {
|
||||||
assert(Inst->getParent() == 0 && "Value already has parent!");
|
assert(Inst->getParent() == 0 && "Value already has parent!");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user