Author: lattner Date: Thu Jan 3 10:56:04 2008 New Revision: 45537 URL: http://llvm.org/viewvc/llvm-project?rev=45537&view=rev Log: add info on walking preds/succs of a block.
Modified: llvm/trunk/docs/ProgrammersManual.html Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=45537&r1=45536&r2=45537&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Thu Jan 3 10:56:04 2008 @@ -103,6 +103,8 @@ the same way</a> </li> <li><a href="#iterate_chains">Iterating over def-use & use-def chains</a> </li> + <li><a href="#iterate_preds">Iterating over predecessors & +successors of blocks</a></li> </ul> </li> <li><a href="#simplechanges">Making simple changes</a> @@ -1536,7 +1538,7 @@ <div class="doc_code"> <pre> -Instruction* pinst = &*i; +Instruction *pinst = &*i; </pre> </div> @@ -1544,7 +1546,7 @@ <div class="doc_code"> <pre> -Instruction* pinst = i; +Instruction *pinst = i; </pre> </div> @@ -1612,8 +1614,7 @@ href="#CallInst">CallInst</a>>(&*i)) { // <i>We know we've encountered a call instruction, so we</i> // <i>need to determine if it's a call to the</i> - // <i>function pointed to by m_func or not</i> - + // <i>function pointed to by m_func or not.</i> if (callInst->getCalledFunction() == targetFunc) ++callCounter; } @@ -1622,7 +1623,7 @@ } private: - unsigned callCounter; + unsigned callCounter; }; </pre> </div> @@ -1674,7 +1675,7 @@ <div class="doc_code"> <pre> -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 +1695,10 @@ <div class="doc_code"> <pre> -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; // <i>...</i> } </pre> @@ -1710,6 +1711,36 @@ </div> +<!--_______________________________________________________________________--> +<div class="doc_subsubsection"> + <a name="iterate_preds">Iterating over predecessors & +successors of blocks</a> +</div> + +<div class="doc_text"> + +<p>Iterating over the predecessors and successors of a block is quite easy +with the routines defined in <tt>"llvm/Support/CFG.h"</tt>. Just use code like +this to iterate over all predecessors of BB:</p> + +<div class="doc_code"> +<pre> +#include "llvm/Support/CFG.h" +BasicBlock *BB = ...; + +for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { + BasicBlock *Pred = *PI; + // <i>...</i> +} +</pre> +</div> + +<p>Similarly, to iterate over successors use +succ_iterator/succ_begin/succ_end.</p> + +</div> + + <!-- ======================================================================= --> <div class="doc_subsection"> <a name="simplechanges">Making simple changes</a> _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits