*** empty log message ***

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3065 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2002-07-24 22:08:53 +00:00
parent 7f4dd472e3
commit fe8041ae39
13 changed files with 41 additions and 42 deletions

View File

@ -11,11 +11,10 @@
#include "llvm/Support/InstIterator.h" #include "llvm/Support/InstIterator.h"
#include "llvm/Instruction.h" #include "llvm/Instruction.h"
#include <iterator> #include <Support/iterator>
class Constant; class Constant;
class constant_iterator class constant_iterator : public forward_iterator<const Constant, ptrdiff_t> {
: public std::forward_iterator<const Constant, ptrdiff_t> {
const_inst_iterator InstI; // Method instruction iterator const_inst_iterator InstI; // Method instruction iterator
unsigned OpIdx; // Operand index unsigned OpIdx; // Operand index

View File

@ -12,18 +12,20 @@
#include "llvm/Function.h" #include "llvm/Function.h"
#include "llvm/BasicBlock.h" #include "llvm/BasicBlock.h"
#include "llvm/InstrTypes.h" #include "llvm/InstrTypes.h"
#include <iterator> #include "Support/iterator"
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// BasicBlock pred_iterator definition // BasicBlock pred_iterator definition
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
template <class _Ptr, class _USE_iterator> // Predecessor Iterator template <class _Ptr, class _USE_iterator> // Predecessor Iterator
class PredIterator : public std::bidirectional_iterator<_Ptr, ptrdiff_t> { class PredIterator : public bidirectional_iterator<_Ptr, ptrdiff_t> {
typedef bidirectional_iterator<_Ptr, ptrdiff_t> super;
_Ptr *BB; _Ptr *BB;
_USE_iterator It; _USE_iterator It;
public: public:
typedef PredIterator<_Ptr,_USE_iterator> _Self; typedef PredIterator<_Ptr,_USE_iterator> _Self;
typedef typename super::pointer pointer;
inline void advancePastConstants() { inline void advancePastConstants() {
// TODO: This is bad // TODO: This is bad
@ -82,11 +84,13 @@ inline pred_const_iterator pred_end(const BasicBlock *BB) {
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
template <class _Term, class _BB> // Successor Iterator template <class _Term, class _BB> // Successor Iterator
class SuccIterator : public std::bidirectional_iterator<_BB, ptrdiff_t> { class SuccIterator : public bidirectional_iterator<_BB, ptrdiff_t> {
const _Term Term; const _Term Term;
unsigned idx; unsigned idx;
typedef bidirectional_iterator<_BB, ptrdiff_t> super;
public: public:
typedef SuccIterator<_Term, _BB> _Self; typedef SuccIterator<_Term, _BB> _Self;
typedef typename super::pointer pointer;
// TODO: This can be random access iterator, need operator+ and stuff tho // TODO: This can be random access iterator, need operator+ and stuff tho
inline SuccIterator(_Term T) : Term(T), idx(0) { // begin iterator inline SuccIterator(_Term T) : Term(T), idx(0) { // begin iterator

View File

@ -250,7 +250,7 @@ int SlotCalculator::insertValue(const Value *D) {
} }
int SlotCalculator::insertVal(const Value *D, bool dontIgnore = false) { int SlotCalculator::insertVal(const Value *D, bool dontIgnore) {
assert(D && "Can't insert a null value!"); assert(D && "Can't insert a null value!");
assert(getValSlot(D) == -1 && "Value is already in the table!"); assert(getValSlot(D) == -1 && "Value is already in the table!");

View File

@ -255,7 +255,7 @@ struct ValueMap {
map<ConstHashKey, ConstantClass *> Map; map<ConstHashKey, ConstantClass *> Map;
inline ConstantClass *get(const Type *Ty, ValType V) { inline ConstantClass *get(const Type *Ty, ValType V) {
map<ConstHashKey,ConstantClass *>::iterator I = typename map<ConstHashKey,ConstantClass *>::iterator I =
Map.find(ConstHashKey(Ty, V)); Map.find(ConstHashKey(Ty, V));
return (I != Map.end()) ? I->second : 0; return (I != Map.end()) ? I->second : 0;
} }
@ -265,7 +265,7 @@ struct ValueMap {
} }
inline void remove(ConstantClass *CP) { inline void remove(ConstantClass *CP) {
for (map<ConstHashKey,ConstantClass *>::iterator I = Map.begin(), for (typename map<ConstHashKey,ConstantClass *>::iterator I = Map.begin(),
E = Map.end(); I != E;++I) E = Map.end(); I != E;++I)
if (I->second == CP) { if (I->second == CP) {
Map.erase(I); Map.erase(I);

View File

@ -136,8 +136,8 @@ void Function::dropAllReferences() {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
GlobalVariable::GlobalVariable(const Type *Ty, bool constant, bool isIntern, GlobalVariable::GlobalVariable(const Type *Ty, bool constant, bool isIntern,
Constant *Initializer = 0, Constant *Initializer,
const std::string &Name = "") const std::string &Name)
: GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, isIntern, Name), : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, isIntern, Name),
isConstantGlobal(constant) { isConstantGlobal(constant) {
if (Initializer) Operands.push_back(Use((Value*)Initializer, this)); if (Initializer) Operands.push_back(Use((Value*)Initializer, this));

View File

@ -20,7 +20,7 @@ TerminatorInst::TerminatorInst(Instruction::TermOps iType)
} }
TerminatorInst::TerminatorInst(const Type *Ty, Instruction::TermOps iType, TerminatorInst::TerminatorInst(const Type *Ty, Instruction::TermOps iType,
const std::string &Name = "") const std::string &Name)
: Instruction(Ty, iType, Name) { : Instruction(Ty, iType, Name) {
} }

View File

@ -199,7 +199,7 @@ void PMDebug::PrintAnalysisSetInfo(unsigned Depth, const char *Msg,
} }
// dumpPassStructure - Implement the -debug-passes=Structure option // dumpPassStructure - Implement the -debug-passes=Structure option
void Pass::dumpPassStructure(unsigned Offset = 0) { void Pass::dumpPassStructure(unsigned Offset) {
std::cerr << std::string(Offset*2, ' ') << getPassName() << "\n"; std::cerr << std::string(Offset*2, ' ') << getPassName() << "\n";
} }

View File

@ -105,8 +105,8 @@ public:
PassManagerT(ParentClass *Par = 0) : Parent(Par), Batcher(0) {} PassManagerT(ParentClass *Par = 0) : Parent(Par), Batcher(0) {}
~PassManagerT() { ~PassManagerT() {
// Delete all of the contained passes... // Delete all of the contained passes...
for (std::vector<PassClass*>::iterator I = Passes.begin(), E = Passes.end(); for (typename std::vector<PassClass*>::iterator
I != E; ++I) I = Passes.begin(), E = Passes.end(); I != E; ++I)
delete *I; delete *I;
} }
@ -205,8 +205,8 @@ public:
virtual void dumpPassStructure(unsigned Offset = 0) { virtual void dumpPassStructure(unsigned Offset = 0) {
std::cerr << std::string(Offset*2, ' ') << Traits::getPMName() std::cerr << std::string(Offset*2, ' ') << Traits::getPMName()
<< " Pass Manager\n"; << " Pass Manager\n";
for (std::vector<PassClass*>::iterator I = Passes.begin(), E = Passes.end(); for (typename std::vector<PassClass*>::iterator
I != E; ++I) { I = Passes.begin(), E = Passes.end(); I != E; ++I) {
PassClass *P = *I; PassClass *P = *I;
P->dumpPassStructure(Offset+1); P->dumpPassStructure(Offset+1);

View File

@ -250,7 +250,7 @@ int SlotCalculator::insertValue(const Value *D) {
} }
int SlotCalculator::insertVal(const Value *D, bool dontIgnore = false) { int SlotCalculator::insertVal(const Value *D, bool dontIgnore) {
assert(D && "Can't insert a null value!"); assert(D && "Can't insert a null value!");
assert(getValSlot(D) == -1 && "Value is already in the table!"); assert(getValSlot(D) == -1 && "Value is already in the table!");

View File

@ -21,7 +21,8 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass,SymTabClass,SubClass>
// Remove all of the items from the old symtab.. // Remove all of the items from the old symtab..
if (SymTabObject && !List.empty()) { if (SymTabObject && !List.empty()) {
SymbolTable *SymTab = SymTabObject->getSymbolTable(); SymbolTable *SymTab = SymTabObject->getSymbolTable();
for (iplist<ValueSubClass>::iterator I = List.begin(); I != List.end(); ++I) for (typename iplist<ValueSubClass>::iterator I = List.begin();
I != List.end(); ++I)
if (I->hasName()) SymTab->remove(I); if (I->hasName()) SymTab->remove(I);
} }
@ -30,7 +31,8 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass,SymTabClass,SubClass>
// Add all of the items to the new symtab... // Add all of the items to the new symtab...
if (SymTabObject && !List.empty()) { if (SymTabObject && !List.empty()) {
SymbolTable *SymTab = SymTabObject->getSymbolTableSure(); SymbolTable *SymTab = SymTabObject->getSymbolTableSure();
for (iplist<ValueSubClass>::iterator I = List.begin(); I != List.end(); ++I) for (typename iplist<ValueSubClass>::iterator I = List.begin();
I != List.end(); ++I)
if (I->hasName()) SymTab->insert(I); if (I->hasName()) SymTab->insert(I);
} }
} }

View File

@ -431,7 +431,7 @@ public:
~TypeMap() { print("ON EXIT"); } ~TypeMap() { print("ON EXIT"); }
inline TypeClass *get(const ValType &V) { inline TypeClass *get(const ValType &V) {
map<ValType, PATypeHandle<TypeClass> >::iterator I = Map.find(V); typename map<ValType, PATypeHandle<TypeClass> >::iterator I = Map.find(V);
// TODO: FIXME: When Types are not CONST. // TODO: FIXME: When Types are not CONST.
return (I != Map.end()) ? (TypeClass*)I->second.get() : 0; return (I != Map.end()) ? (TypeClass*)I->second.get() : 0;
} }
@ -445,7 +445,7 @@ public:
// structurally equivalent to the specified type. // structurally equivalent to the specified type.
// //
inline const TypeClass *containsEquivalent(const TypeClass *Ty) { inline const TypeClass *containsEquivalent(const TypeClass *Ty) {
for (MapTy::iterator I = Map.begin(), E = Map.end(); I != E; ++I) for (typename MapTy::iterator I = Map.begin(), E = Map.end(); I != E; ++I)
if (I->second.get() != Ty && TypesEqual(Ty, I->second.get())) if (I->second.get() != Ty && TypesEqual(Ty, I->second.get()))
return (TypeClass*)I->second.get(); // FIXME TODO when types not const return (TypeClass*)I->second.get(); // FIXME TODO when types not const
return 0; return 0;
@ -462,7 +462,7 @@ public:
<< OldTy->getDescription() << " replacement == " << (void*)NewTy << OldTy->getDescription() << " replacement == " << (void*)NewTy
<< ", " << NewTy->getDescription() << endl; << ", " << NewTy->getDescription() << endl;
#endif #endif
for (MapTy::iterator I = Map.begin(), E = Map.end(); I != E; ++I) for (typename MapTy::iterator I = Map.begin(), E = Map.end(); I != E; ++I)
if (I->second == OldTy) { if (I->second == OldTy) {
// Check to see if the type just became concrete. If so, remove self // Check to see if the type just became concrete. If so, remove self
// from user list. // from user list.
@ -472,7 +472,7 @@ public:
} }
void remove(const ValType &OldVal) { void remove(const ValType &OldVal) {
MapTy::iterator I = Map.find(OldVal); typename MapTy::iterator I = Map.find(OldVal);
assert(I != Map.end() && "TypeMap::remove, element not found!"); assert(I != Map.end() && "TypeMap::remove, element not found!");
Map.erase(I); Map.erase(I);
} }

View File

@ -18,7 +18,7 @@ static inline const Type *checkType(const Type *Ty) {
return Ty; return Ty;
} }
Value::Value(const Type *ty, ValueTy vty, const std::string &name = "") Value::Value(const Type *ty, ValueTy vty, const std::string &name)
: Name(name), Ty(checkType(ty), this) { : Name(name), Ty(checkType(ty), this) {
VTy = vty; VTy = vty;
} }
@ -33,11 +33,9 @@ Value::~Value() {
// //
if (Uses.begin() != Uses.end()) { if (Uses.begin() != Uses.end()) {
std::cerr << "While deleting: " << Ty << "%" << Name << "\n"; std::cerr << "While deleting: " << Ty << "%" << Name << "\n";
for (use_const_iterator I = Uses.begin(); I != Uses.end(); ++I) { for (use_const_iterator I = Uses.begin(); I != Uses.end(); ++I)
std::cerr << "Use still stuck around after Def is destroyed:"; std::cerr << "Use still stuck around after Def is destroyed:"
(*I)->dump(); << **I << "\n";
std::cerr << "\n";
}
} }
#endif #endif
assert(Uses.begin() == Uses.end()); assert(Uses.begin() == Uses.end());
@ -56,12 +54,8 @@ void Value::replaceAllUsesWith(Value *D) {
Use->replaceUsesOfWith(this, D); Use->replaceUsesOfWith(this, D);
#ifndef NDEBUG // only in -g mode... #ifndef NDEBUG // only in -g mode...
if (Uses.size() == NumUses) { if (Uses.size() == NumUses)
std::cerr << "Use: "; std::cerr << "Use: " << *Use << "replace with: " << *D;
Use->dump();
std::cerr << "replace with: ";
D->dump();
}
#endif #endif
assert(Uses.size() != NumUses && "Didn't remove definition!"); assert(Uses.size() != NumUses && "Didn't remove definition!");
} }
@ -73,7 +67,7 @@ void Value::replaceAllUsesWith(Value *D) {
// change Ty to point to the right type. :) // change Ty to point to the right type. :)
// //
void Value::refineAbstractType(const DerivedType *OldTy, const Type *NewTy) { void Value::refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
assert(Ty.get() == OldTy &&"Can't refine anything but my type!"); assert(Ty.get() == OldTy && "Can't refine anything but my type!");
if (OldTy == NewTy && !OldTy->isAbstract()) if (OldTy == NewTy && !OldTy->isAbstract())
Ty.removeUserFromConcrete(); Ty.removeUserFromConcrete();
Ty = NewTy; Ty = NewTy;

View File

@ -14,7 +14,7 @@ static inline const Type *checkType(const Type *Ty) {
} }
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
const std::string &Name = "") const std::string &Name)
: Instruction(Ty, iTy, Name) { : Instruction(Ty, iTy, Name) {
assert(isa<PointerType>(Ty) && "Can't allocate a non pointer type!"); assert(isa<PointerType>(Ty) && "Can't allocate a non pointer type!");
@ -50,7 +50,7 @@ const Type *AllocationInst::getAllocatedType() const {
// //
const Type* MemAccessInst::getIndexedType(const Type *Ptr, const Type* MemAccessInst::getIndexedType(const Type *Ptr,
const std::vector<Value*> &Idx, const std::vector<Value*> &Idx,
bool AllowCompositeLeaf = false) { bool AllowCompositeLeaf) {
if (!isa<PointerType>(Ptr)) return 0; // Type isn't a pointer type! if (!isa<PointerType>(Ptr)) return 0; // Type isn't a pointer type!
// Handle the special case of the empty set index set... // Handle the special case of the empty set index set...
@ -76,7 +76,7 @@ const Type* MemAccessInst::getIndexedType(const Type *Ptr,
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
LoadInst::LoadInst(Value *Ptr, const std::vector<Value*> &Idx, LoadInst::LoadInst(Value *Ptr, const std::vector<Value*> &Idx,
const std::string &Name = "") const std::string &Name)
: MemAccessInst(checkType(getIndexedType(Ptr->getType(), Idx)), Load, Name) { : MemAccessInst(checkType(getIndexedType(Ptr->getType(), Idx)), Load, Name) {
assert(getIndexedType(Ptr->getType(), Idx) && "Load operands invalid!"); assert(getIndexedType(Ptr->getType(), Idx) && "Load operands invalid!");
Operands.reserve(1+Idx.size()); Operands.reserve(1+Idx.size());
@ -87,7 +87,7 @@ LoadInst::LoadInst(Value *Ptr, const std::vector<Value*> &Idx,
} }
LoadInst::LoadInst(Value *Ptr, const std::string &Name = "") LoadInst::LoadInst(Value *Ptr, const std::string &Name)
: MemAccessInst(cast<PointerType>(Ptr->getType())->getElementType(), : MemAccessInst(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Name) { Load, Name) {
Operands.reserve(1); Operands.reserve(1);
@ -125,7 +125,7 @@ StoreInst::StoreInst(Value *Val, Value *Ptr)
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx, GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
const std::string &Name = "") const std::string &Name)
: MemAccessInst(PointerType::get(checkType(getIndexedType(Ptr->getType(), : MemAccessInst(PointerType::get(checkType(getIndexedType(Ptr->getType(),
Idx, true))), Idx, true))),
GetElementPtr, Name) { GetElementPtr, Name) {