if (isa<<a href="#Constant">Constant</a>>(V) || isa<<a href="#Argument">Argument</a>>(V) || isa<<a href="#GlobalValue">GlobalValue</a>>(V))
return true;
- <i>// Otherwise, it must be an instruction...</i>
+ // <i>Otherwise, it must be an instruction...</i>
return !L->contains(cast<<a href="#Instruction">Instruction</a>>(V)->getParent());
}
</pre>
<div class="doc_code">
<pre>
if (<a href="#AllocationInst">AllocationInst</a> *AI = dyn_cast<<a href="#AllocationInst">AllocationInst</a>>(Val)) {
- // ...
+ // <i>...</i>
}
</pre>
</div>
<div class="doc_code">
<pre>
$ opt < a.bc > /dev/null -mypass
-<no output>
+<i><no output></i>
$ opt < a.bc > /dev/null -mypass -debug
I am here!
</pre>
<div class="doc_code">
<pre>
$ opt < a.bc > /dev/null -mypass
-<no output>
+<i><no output></i>
$ opt < a.bc > /dev/null -mypass -debug
No debug type
'foo' debug type
<div class="doc_code">
<pre>
-++NumXForms; // I did stuff!
+++NumXForms; // <i>I did stuff!</i>
</pre>
</div>
<div class="doc_code">
<pre>
$ opt -stats -mypassname < program.bc > /dev/null
-... statistic output ...
+<i>... statistics output ...</i>
</pre>
</div>
<div class="doc_code">
<pre>
-// func is a pointer to a Function instance
-for (Function::iterator i = func->begin(), e = func->end(); i != e; ++i) {
- // print out the name of the basic block if it has one, and then the
- // number of instructions that it contains
+// <i>func is a pointer to a Function instance</i>
+for (Function::iterator i = func->begin(), e = func->end(); i != e; ++i)
+ // <i>Print out the name of the basic block if it has one, and then the</i>
+ // <i>number of instructions that it contains</i>
std::cerr << "Basic block (name=" << i->getName() << ") has "
<< i->size() << " instructions.\n";
-}
</pre>
</div>
<div class="doc_code">
<pre>
-// blk is a pointer to a BasicBlock instance
+// <i>blk is a pointer to a BasicBlock instance</i>
for (BasicBlock::iterator i = blk->begin(), e = blk->end(); i != e; ++i)
- // the next statement works since operator<<(ostream&,...)
- // is overloaded for Instruction&
+ // <i>The next statement works since operator<<(ostream&,...)</i>
+ // <i>is overloaded for Instruction&</i>
std::cerr << *i << "\n";
</pre>
</div>
<pre>
#include "<a href="/doxygen/InstIterator_8h-source.html">llvm/Support/InstIterator.h</a>"
-// Suppose F is a ptr to a function
+// <i>F is a ptr to a Function instance</i>
for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i)
std::cerr << *i << "\n";
</pre>
<div class="doc_code">
<pre>
-Instruction& inst = *i; // grab reference to instruction reference
-Instruction* pinst = &*i; // grab pointer to instruction reference
+Instruction& inst = *i; // <i>Grab reference to instruction reference</i>
+Instruction* pinst = &*i; // <i>Grab pointer to instruction reference</i>
const Instruction& inst = *j;
</pre>
</div>
<pre>
void printNextInstruction(Instruction* inst) {
BasicBlock::iterator it(inst);
- ++it; // after this line, it refers to the instruction after *inst.
+ ++it; // <i>After this line, it refers to the instruction after *inst</i>
if (it != inst->getParent()->end()) std::cerr << *it << "\n";
}
</pre>
for (BasicBlock::iterator i = b->begin(); ie = b->end(); i != ie; ++i) {
if (<a href="#CallInst">CallInst</a>* callInst = <a href="#isa">dyn_cast</a><<a
href="#CallInst">CallInst</a>>(&*i)) {
- // we know we've encountered a call instruction, so we
- // need to determine if it's a call to the
- // function pointed to by m_func or not.
+ // <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>
if (callInst->getCalledFunction() == targetFunc)
++callCounter;
}
}
}
-
+ }
private:
unsigned callCounter;
<pre>
Function* F = ...;
-for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i) {
+for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i)
if (Instruction *Inst = dyn_cast<Instruction>(*i)) {
std::cerr << "F is used in instruction:\n";
std::cerr << *Inst << "\n";
}
-}
</pre>
</div>
for (User::op_iterator i = pi->op_begin(), e = pi->op_end(); i != e; ++i) {
Value* v = *i;
- ...
+ // <i>...</i>
}
</pre>
</div>
Instruction *pi = ...;
Instruction *newInst = new Instruction(...);
-pb->getInstList().insert(pi, newInst); // inserts newInst before pi in pb
+pb->getInstList().insert(pi, newInst); // <i>Inserts newInst before pi in pb</i>
</pre>
</div>
BasicBlock *pb = ...;
Instruction *newInst = new Instruction(...);
-pb->getInstList().push_back(newInst); // appends newInst to pb
+pb->getInstList().push_back(newInst); // <i>Appends newInst to pb</i>
</pre>
</div>
<div class="doc_code">
<pre>
-//<i> Create the initial outer struct.</i>
+// <i>Create the initial outer struct</i>
<a href="#PATypeHolder">PATypeHolder</a> StructTy = OpaqueType::get();
std::vector<const Type*> Elts;
Elts.push_back(PointerType::get(StructTy));
Elts.push_back(Type::IntTy);
StructType *NewSTy = StructType::get(Elts);
-//<i> At this point, NewSTy = "{ opaque*, int }". Tell VMCore that</i>
-//<i> the struct and the opaque type are actually the same.</i>
+// <i>At this point, NewSTy = "{ opaque*, int }". Tell VMCore that</i>
+// <i>the struct and the opaque type are actually the same.</i>
cast<OpaqueType>(StructTy.get())-><a href="#refineAbstractTypeTo">refineAbstractTypeTo</a>(NewSTy);
// <i>NewSTy is potentially invalidated, but StructTy (a <a href="#PATypeHolder">PATypeHolder</a>) is</i>
-// <i>kept up-to-date.</i>
+// <i>kept up-to-date</i>
NewSTy = cast<StructType>(StructTy.get());
-// <i>Add a name for the type to the module symbol table (optional).</i>
+// <i>Add a name for the type to the module symbol table (optional)</i>
MyModule->addTypeName("mylist", NewSTy);
</pre>
</div>
<td align="left"><pre><tt>
for (SymbolTable::plane_const_iterator PI = ST.plane_begin(),
PE = ST.plane_end(); PI != PE; ++PI ) {
- PI->first // This is the Type* of the plane
- PI->second // This is the SymbolTable::ValueMap of name/Value pairs
+ PI->first // <i>This is the Type* of the plane</i>
+ PI->second // <i>This is the SymbolTable::ValueMap of name/Value pairs</i>
}
</tt></pre></td>
</tr>
<td align="left"><pre><tt>
for (SymbolTable::type_const_iterator TI = ST.type_begin(),
TE = ST.type_end(); TI != TE; ++TI ) {
- TI->first // This is the name of the type
- TI->second // This is the Type* value associated with the name
+ TI->first // <i>This is the name of the type</i>
+ TI->second // <i>This is the Type* value associated with the name</i>
}
</tt></pre></td>
</tr>
<td align="left"><pre><tt>
for (SymbolTable::value_const_iterator VI = ST.value_begin(SomeType),
VE = ST.value_end(SomeType); VI != VE; ++VI ) {
- VI->first // This is the name of the Value
- VI->second // This is the Value* value associated with the name
+ VI->first // <i>This is the name of the Value</i>
+ VI->second // <i>This is the Value* value associated with the name</i>
}
</tt></pre></td>
</tr>