llvm.org GIT mirror llvm / fe8041a
*** empty log message *** git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3065 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 18 years ago
13 changed file(s) with 41 addition(s) and 42 deletion(s). Raw diff Collapse all Expand all
1010
1111 #include "llvm/Support/InstIterator.h"
1212 #include "llvm/Instruction.h"
13 #include <iterator>
13 #include <Support/iterator>
1414 class Constant;
1515
16 class constant_iterator
17 : public std::forward_iterator {
16 class constant_iterator : public forward_iterator {
1817 const_inst_iterator InstI; // Method instruction iterator
1918 unsigned OpIdx; // Operand index
2019
1111 #include "llvm/Function.h"
1212 #include "llvm/BasicBlock.h"
1313 #include "llvm/InstrTypes.h"
14 #include
14 #include "Support/iterator"
1515
1616 //===--------------------------------------------------------------------===//
1717 // BasicBlock pred_iterator definition
1818 //===--------------------------------------------------------------------===//
1919
2020 template // Predecessor Iterator
21 class PredIterator : public std::bidirectional_iterator<_Ptr, ptrdiff_t> {
21 class PredIterator : public bidirectional_iterator<_Ptr, ptrdiff_t> {
22 typedef bidirectional_iterator<_Ptr, ptrdiff_t> super;
2223 _Ptr *BB;
2324 _USE_iterator It;
2425 public:
2526 typedef PredIterator<_Ptr,_USE_iterator> _Self;
27 typedef typename super::pointer pointer;
2628
2729 inline void advancePastConstants() {
2830 // TODO: This is bad
8183 //===--------------------------------------------------------------------===//
8284
8385 template // Successor Iterator
84 class SuccIterator : public std::bidirectional_iterator<_BB, ptrdiff_t> {
86 class SuccIterator : public bidirectional_iterator<_BB, ptrdiff_t> {
8587 const _Term Term;
8688 unsigned idx;
89 typedef bidirectional_iterator<_BB, ptrdiff_t> super;
8790 public:
8891 typedef SuccIterator<_Term, _BB> _Self;
92 typedef typename super::pointer pointer;
8993 // TODO: This can be random access iterator, need operator+ and stuff tho
9094
9195 inline SuccIterator(_Term T) : Term(T), idx(0) { // begin iterator
249249 }
250250
251251
252 int SlotCalculator::insertVal(const Value *D, bool dontIgnore = false) {
252 int SlotCalculator::insertVal(const Value *D, bool dontIgnore) {
253253 assert(D && "Can't insert a null value!");
254254 assert(getValSlot(D) == -1 && "Value is already in the table!");
255255
254254 map Map;
255255
256256 inline ConstantClass *get(const Type *Ty, ValType V) {
257 map::iterator I =
257 typename map::iterator I =
258258 Map.find(ConstHashKey(Ty, V));
259259 return (I != Map.end()) ? I->second : 0;
260260 }
264264 }
265265
266266 inline void remove(ConstantClass *CP) {
267 for (map::iterator I = Map.begin(),
267 for (typename map::iterator I = Map.begin(),
268268 E = Map.end(); I != E;++I)
269269 if (I->second == CP) {
270270 Map.erase(I);
135135 //===----------------------------------------------------------------------===//
136136
137137 GlobalVariable::GlobalVariable(const Type *Ty, bool constant, bool isIntern,
138 Constant *Initializer = 0,
139 const std::string &Name = "")
138 Constant *Initializer,
139 const std::string &Name)
140140 : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, isIntern, Name),
141141 isConstantGlobal(constant) {
142142 if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
1919 }
2020
2121 TerminatorInst::TerminatorInst(const Type *Ty, Instruction::TermOps iType,
22 const std::string &Name = "")
22 const std::string &Name)
2323 : Instruction(Ty, iType, Name) {
2424 }
2525
198198 }
199199
200200 // dumpPassStructure - Implement the -debug-passes=Structure option
201 void Pass::dumpPassStructure(unsigned Offset = 0) {
201 void Pass::dumpPassStructure(unsigned Offset) {
202202 std::cerr << std::string(Offset*2, ' ') << getPassName() << "\n";
203203 }
204204
104104 PassManagerT(ParentClass *Par = 0) : Parent(Par), Batcher(0) {}
105105 ~PassManagerT() {
106106 // Delete all of the contained passes...
107 for (std::vector::iterator I = Passes.begin(), E = Passes.end();
108 I != E; ++I)
107 for (typename std::vector::iterator
108 I = Passes.begin(), E = Passes.end(); I != E; ++I)
109109 delete *I;
110110 }
111111
204204 virtual void dumpPassStructure(unsigned Offset = 0) {
205205 std::cerr << std::string(Offset*2, ' ') << Traits::getPMName()
206206 << " Pass Manager\n";
207 for (std::vector::iterator I = Passes.begin(), E = Passes.end();
208 I != E; ++I) {
207 for (typename std::vector::iterator
208 I = Passes.begin(), E = Passes.end(); I != E; ++I) {
209209 PassClass *P = *I;
210210 P->dumpPassStructure(Offset+1);
211211
249249 }
250250
251251
252 int SlotCalculator::insertVal(const Value *D, bool dontIgnore = false) {
252 int SlotCalculator::insertVal(const Value *D, bool dontIgnore) {
253253 assert(D && "Can't insert a null value!");
254254 assert(getValSlot(D) == -1 && "Value is already in the table!");
255255
2020 // Remove all of the items from the old symtab..
2121 if (SymTabObject && !List.empty()) {
2222 SymbolTable *SymTab = SymTabObject->getSymbolTable();
23 for (iplist::iterator I = List.begin(); I != List.end(); ++I)
23 for (typename iplist::iterator I = List.begin();
24 I != List.end(); ++I)
2425 if (I->hasName()) SymTab->remove(I);
2526 }
2627
2930 // Add all of the items to the new symtab...
3031 if (SymTabObject && !List.empty()) {
3132 SymbolTable *SymTab = SymTabObject->getSymbolTableSure();
32 for (iplist::iterator I = List.begin(); I != List.end(); ++I)
33 for (typename iplist::iterator I = List.begin();
34 I != List.end(); ++I)
3335 if (I->hasName()) SymTab->insert(I);
3436 }
3537 }
430430 ~TypeMap() { print("ON EXIT"); }
431431
432432 inline TypeClass *get(const ValType &V) {
433 map >::iterator I = Map.find(V);
433 typename map >::iterator I = Map.find(V);
434434 // TODO: FIXME: When Types are not CONST.
435435 return (I != Map.end()) ? (TypeClass*)I->second.get() : 0;
436436 }
444444 // structurally equivalent to the specified type.
445445 //
446446 inline const TypeClass *containsEquivalent(const TypeClass *Ty) {
447 for (MapTy::iterator I = Map.begin(), E = Map.end(); I != E; ++I)
447 for (typename MapTy::iterator I = Map.begin(), E = Map.end(); I != E; ++I)
448448 if (I->second.get() != Ty && TypesEqual(Ty, I->second.get()))
449449 return (TypeClass*)I->second.get(); // FIXME TODO when types not const
450450 return 0;
461461 << OldTy->getDescription() << " replacement == " << (void*)NewTy
462462 << ", " << NewTy->getDescription() << endl;
463463 #endif
464 for (MapTy::iterator I = Map.begin(), E = Map.end(); I != E; ++I)
464 for (typename MapTy::iterator I = Map.begin(), E = Map.end(); I != E; ++I)
465465 if (I->second == OldTy) {
466466 // Check to see if the type just became concrete. If so, remove self
467467 // from user list.
471471 }
472472
473473 void remove(const ValType &OldVal) {
474 MapTy::iterator I = Map.find(OldVal);
474 typename MapTy::iterator I = Map.find(OldVal);
475475 assert(I != Map.end() && "TypeMap::remove, element not found!");
476476 Map.erase(I);
477477 }
1717 return Ty;
1818 }
1919
20 Value::Value(const Type *ty, ValueTy vty, const std::string &name = "")
20 Value::Value(const Type *ty, ValueTy vty, const std::string &name)
2121 : Name(name), Ty(checkType(ty), this) {
2222 VTy = vty;
2323 }
3232 //
3333 if (Uses.begin() != Uses.end()) {
3434 std::cerr << "While deleting: " << Ty << "%" << Name << "\n";
35 for (use_const_iterator I = Uses.begin(); I != Uses.end(); ++I) {
36 std::cerr << "Use still stuck around after Def is destroyed:";
37 (*I)->dump();
38 std::cerr << "\n";
39 }
35 for (use_const_iterator I = Uses.begin(); I != Uses.end(); ++I)
36 std::cerr << "Use still stuck around after Def is destroyed:"
37 << **I << "\n";
4038 }
4139 #endif
4240 assert(Uses.begin() == Uses.end());
5553 Use->replaceUsesOfWith(this, D);
5654
5755 #ifndef NDEBUG // only in -g mode...
58 if (Uses.size() == NumUses) {
59 std::cerr << "Use: ";
60 Use->dump();
61 std::cerr << "replace with: ";
62 D->dump();
63 }
56 if (Uses.size() == NumUses)
57 std::cerr << "Use: " << *Use << "replace with: " << *D;
6458 #endif
6559 assert(Uses.size() != NumUses && "Didn't remove definition!");
6660 }
7266 // change Ty to point to the right type. :)
7367 //
7468 void Value::refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
75 assert(Ty.get() == OldTy &&"Can't refine anything but my type!");
69 assert(Ty.get() == OldTy && "Can't refine anything but my type!");
7670 if (OldTy == NewTy && !OldTy->isAbstract())
7771 Ty.removeUserFromConcrete();
7872 Ty = NewTy;
1313 }
1414
1515 AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
16 const std::string &Name = "")
16 const std::string &Name)
1717 : Instruction(Ty, iTy, Name) {
1818 assert(isa(Ty) && "Can't allocate a non pointer type!");
1919
4949 //
5050 const Type* MemAccessInst::getIndexedType(const Type *Ptr,
5151 const std::vector &Idx,
52 bool AllowCompositeLeaf = false) {
52 bool AllowCompositeLeaf) {
5353 if (!isa(Ptr)) return 0; // Type isn't a pointer type!
5454
5555 // Handle the special case of the empty set index set...
7575 //===----------------------------------------------------------------------===//
7676
7777 LoadInst::LoadInst(Value *Ptr, const std::vector &Idx,
78 const std::string &Name = "")
78 const std::string &Name)
7979 : MemAccessInst(checkType(getIndexedType(Ptr->getType(), Idx)), Load, Name) {
8080 assert(getIndexedType(Ptr->getType(), Idx) && "Load operands invalid!");
8181 Operands.reserve(1+Idx.size());
8686
8787 }
8888
89 LoadInst::LoadInst(Value *Ptr, const std::string &Name = "")
89 LoadInst::LoadInst(Value *Ptr, const std::string &Name)
9090 : MemAccessInst(cast(Ptr->getType())->getElementType(),
9191 Load, Name) {
9292 Operands.reserve(1);
124124 //===----------------------------------------------------------------------===//
125125
126126 GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector &Idx,
127 const std::string &Name = "")
127 const std::string &Name)
128128 : MemAccessInst(PointerType::get(checkType(getIndexedType(Ptr->getType(),
129129 Idx, true))),
130130 GetElementPtr, Name) {