Use already existing classes for post order iterator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9629 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alkis Evlogimenos 2003-10-31 03:02:34 +00:00
parent c6ad94c6a1
commit 088eb45cf4
2 changed files with 22 additions and 34 deletions

View File

@ -23,7 +23,7 @@
#include "llvm/Constant.h" #include "llvm/Constant.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/SymbolTable.h" #include "llvm/SymbolTable.h"
#include "Support/DepthFirstIterator.h" #include "Support/PostOrderIterator.h"
#include "Support/STLExtras.h" #include "Support/STLExtras.h"
#include <algorithm> #include <algorithm>
@ -287,21 +287,14 @@ int SlotCalculator::insertValue(const Value *D, bool dontIgnore) {
SC_DEBUG(" Inserted type: " << TheTy->getDescription() << " slot=" << SC_DEBUG(" Inserted type: " << TheTy->getDescription() << " slot=" <<
ResultSlot << "\n"); ResultSlot << "\n");
// Loop over any contained types in the definition... in reverse depth // Loop over any contained types in the definition... in post
// first order. // order.
// //
std::vector<const Type*> DfsOrder; for (po_iterator<const Type*> I = po_begin(TheTy), E = po_end(TheTy);
for (df_iterator<const Type*> I = df_begin(TheTy), E = df_end(TheTy);
I != E; ++I) { I != E; ++I) {
if (*I != TheTy) { if (*I != TheTy) {
// If we haven't seen this sub type before, add it to our type table!
DfsOrder.push_back(*I);
}
}
for (std::vector<const Type*>::const_reverse_iterator
I = DfsOrder.rbegin(), E = DfsOrder.rend(); I != E; ++I) {
const Type *SubTy = *I; const Type *SubTy = *I;
// If we haven't seen this sub type before, add it to our type table!
if (getSlot(SubTy) == -1) { if (getSlot(SubTy) == -1) {
SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n"); SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n");
int Slot = doInsertValue(SubTy); int Slot = doInsertValue(SubTy);
@ -309,6 +302,7 @@ int SlotCalculator::insertValue(const Value *D, bool dontIgnore) {
" slot=" << Slot << "\n"); " slot=" << Slot << "\n");
} }
} }
}
return ResultSlot; return ResultSlot;
} }

View File

@ -23,7 +23,7 @@
#include "llvm/Constant.h" #include "llvm/Constant.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/SymbolTable.h" #include "llvm/SymbolTable.h"
#include "Support/DepthFirstIterator.h" #include "Support/PostOrderIterator.h"
#include "Support/STLExtras.h" #include "Support/STLExtras.h"
#include <algorithm> #include <algorithm>
@ -287,21 +287,14 @@ int SlotCalculator::insertValue(const Value *D, bool dontIgnore) {
SC_DEBUG(" Inserted type: " << TheTy->getDescription() << " slot=" << SC_DEBUG(" Inserted type: " << TheTy->getDescription() << " slot=" <<
ResultSlot << "\n"); ResultSlot << "\n");
// Loop over any contained types in the definition... in reverse depth // Loop over any contained types in the definition... in post
// first order. // order.
// //
std::vector<const Type*> DfsOrder; for (po_iterator<const Type*> I = po_begin(TheTy), E = po_end(TheTy);
for (df_iterator<const Type*> I = df_begin(TheTy), E = df_end(TheTy);
I != E; ++I) { I != E; ++I) {
if (*I != TheTy) { if (*I != TheTy) {
// If we haven't seen this sub type before, add it to our type table!
DfsOrder.push_back(*I);
}
}
for (std::vector<const Type*>::const_reverse_iterator
I = DfsOrder.rbegin(), E = DfsOrder.rend(); I != E; ++I) {
const Type *SubTy = *I; const Type *SubTy = *I;
// If we haven't seen this sub type before, add it to our type table!
if (getSlot(SubTy) == -1) { if (getSlot(SubTy) == -1) {
SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n"); SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n");
int Slot = doInsertValue(SubTy); int Slot = doInsertValue(SubTy);
@ -309,6 +302,7 @@ int SlotCalculator::insertValue(const Value *D, bool dontIgnore) {
" slot=" << Slot << "\n"); " slot=" << Slot << "\n");
} }
} }
}
return ResultSlot; return ResultSlot;
} }