X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FProgrammersManual.html;h=716d364ed5699a2c73ca2c84ca93dbf3aee094be;hb=93c534623c4691d255ea6c870347482ff8752313;hp=792dbf0e529ea08c2f2a6c4a20b88a4b909784ac;hpb=c28476f1d9b04d44082727f82d0e7bca6a67a14c;p=oota-llvm.git diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index 792dbf0e529..716d364ed56 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -103,6 +103,8 @@ complex example the same way
std::set<Instruction*> worklist; -worklist.insert(inst_begin(F), inst_end(F)); +// or better yet, SmallPtrSet<Instruction*, 64> worklist; + +for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) + worklist.insert(&*I);
-Instruction* pinst = &*i; +Instruction *pinst = &*i;
-Instruction* pinst = i; +Instruction *pinst = i;
-Function* F = ...; +Function *F = ...; for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i) if (Instruction *Inst = dyn_cast<Instruction>(*i)) { @@ -1694,10 +1698,10 @@ the particular Instruction):+ + + +-Instruction* pi = ...; +Instruction *pi = ...; for (User::op_iterator i = pi->op_begin(), e = pi->op_end(); i != e; ++i) { - Value* v = *i; + Value *v = *i; // ... }@@ -1710,6 +1714,36 @@ for (User::op_iterator i = pi->op_begin(), e = pi->op_end(); i != e; ++i)+ ++ +Iterating over the predecessors and successors of a block is quite easy +with the routines defined in "llvm/Support/CFG.h". Just use code like +this to iterate over all predecessors of BB:
+ +++ ++#include "llvm/Support/CFG.h" +BasicBlock *BB = ...; + +for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { + BasicBlock *Pred = *PI; + // ... +} ++Similarly, to iterate over successors use +succ_iterator/succ_begin/succ_end.
+ +Making simple changes @@ -1742,7 +1776,7 @@ parameters. For example, an AllocaInst only requires a@@ -1770,7 +1804,7 @@ used as some kind of index by some other code. To accomplish this, I place an-AllocaInst* ai = new AllocaInst(Type::IntTy); +AllocaInst* ai = new AllocaInst(Type::Int32Ty);@@ -1883,9 +1917,7 @@ erase function to remove your instruction. For example:-AllocaInst* pa = new AllocaInst(Type::IntTy, 0, "indexLoc"); +AllocaInst* pa = new AllocaInst(Type::Int32Ty, 0, "indexLoc");@@ -1922,7 +1954,7 @@ AllocaInst* instToReplace = ...; BasicBlock::iterator ii(instToReplace); ReplaceInstWithValue(instToReplace->getParent()->getInstList(), ii, - Constant::getNullValue(PointerType::get(Type::IntTy))); + Constant::getNullValue(PointerType::get(Type::Int32Ty)));Instruction *I = .. ; -BasicBlock *BB = I->getParent(); - -BB->getInstList().erase(I); +I->eraseFromParent();