[llvm-commits] CVS: llvm/docs/ProgrammersManual.html

Alkis Evlogimenos alkis at cs.uiuc.edu
Wed May 26 20:01:01 PDT 2004


Changes in directory llvm/docs:

ProgrammersManual.html updated: 1.58 -> 1.59

---
Log message:

Add section on the newly added Instruction and subclasses constructor
variant.


---
Diffs of the changes:  (+17 -2)

Index: llvm/docs/ProgrammersManual.html
diff -u llvm/docs/ProgrammersManual.html:1.58 llvm/docs/ProgrammersManual.html:1.59
--- llvm/docs/ProgrammersManual.html:1.58	Wed May 26 11:52:55 2004
+++ llvm/docs/ProgrammersManual.html	Wed May 26 19:57:51 2004
@@ -808,7 +808,22 @@
     <tt>BasicBlock</tt>, and a newly-created instruction we wish to insert
     before <tt>*pi</tt>, we do the following: </p>
 
-      <pre>  BasicBlock *pb = ...;<br>  Instruction *pi = ...;<br>  Instruction *newInst = new Instruction(...);<br>  pb->getInstList().insert(pi, newInst); // inserts newInst before pi in pb<br></pre></li>
+      <pre>  BasicBlock *pb = ...;<br>  Instruction *pi = ...;<br>  Instruction *newInst = new Instruction(...);<br>  pb->getInstList().insert(pi, newInst); // inserts newInst before pi in pb<br></pre>
+
+    <p>Appending to the end of a <tt>BasicBlock</tt> is so common that
+    the <tt>Instruction</tt> class and <tt>Instruction</tt>-derived
+    classes provide constructors which take a pointer to a
+    <tt>BasicBlock</tt> to be appended to. For example code that
+    looked like: </p>
+
+      <pre>  BasicBlock *pb = ...;<br>  Instruction *newInst = new Instruction(...);<br>  pb->getInstList().push_back(newInst); // appends newInst to pb<br></pre>
+
+    <p>becomes: </p>
+
+      <pre>  BasicBlock *pb = ...;<br>  Instruction *newInst = new Instruction(..., pb);<br></pre>
+
+    <p>which is much cleaner, especially if you are creating
+    long instruction streams.</p></li>
 
   <li>Insertion into an implicit instruction list
 
@@ -2028,7 +2043,7 @@
   <a href="mailto:dhurjati at cs.uiuc.edu">Dinakar Dhurjati</a> and
   <a href="mailto:sabre at nondot.org">Chris Lattner</a><br>
   <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
-  Last modified: $Date: 2004/05/26 16:52:55 $
+  Last modified: $Date: 2004/05/27 00:57:51 $
 </address>
 
 </body>





More information about the llvm-commits mailing list