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

Joel Stanley jstanley at cs.uiuc.edu
Tue Sep 17 22:18:01 PDT 2002

Changes in directory llvm/www/docs:

ProgrammersManual.html updated: 1.27 -> 1.28

Log message:

Finished instruction replacement section, etc.  Need better example for replaceAllUsesWith().

Diffs of the changes:

Index: llvm/www/docs/ProgrammersManual.html
diff -u llvm/www/docs/ProgrammersManual.html:1.27 llvm/www/docs/ProgrammersManual.html:1.28
--- llvm/www/docs/ProgrammersManual.html:1.27	Tue Sep 17 21:21:57 2002
+++ llvm/www/docs/ProgrammersManual.html	Tue Sep 17 22:17:23 2002
@@ -669,8 +669,7 @@
 <li>Insertion into an implicit instruction list
-<tt>Instruction</tt> instances that are already in
+<p><tt>Instruction</tt> instances that are already in
 <tt>BasicBlock</tt>s are implicitly associated with an existing
 instruction list: the instruction list of the enclosing basic block.
 Thus, we could have accomplished the same thing as the above code
@@ -695,7 +694,7 @@
 which is much cleaner, especially if you're creating a lot of
 instructions and adding them to <tt>BasicBlock</tt>s.
+ </p>
@@ -718,17 +717,59 @@
 </ul><h4><a name="schanges_replacing"><hr size=0>Replacing an
     <tt>Instruction</tt> with another <tt>Value</tt></h4><ul>
-<!-- Value::replaceAllUsesWith
-     User::replaceUsesOfWith
-  Point out: include/llvm/Transforms/Utils/
-    especially BasicBlockUtils.h with:
-         ReplaceInstWithValue, ReplaceInstWithInst
+<p><i>Replacing individual instructions</i></p>
+Including "<a
+</a>" permits use of two very useful replace functions:
+<tt>ReplaceInstWithValue</tt> and <tt>ReplaceInstWithInst</tt>.  
+<p>This function replaces all uses (within a basic block) of a given
+instruction with a value, and then removes the original instruction.
+The following example illustrates the replacement of the result of a
+particular <tt>AllocaInst</tt> that allocates memory for a single
+integer with an null pointer to an integer.</p>
+AllocaInst* instToReplace = ...;
+ReplaceInstWithValue(*instToReplace->getParent(), instToReplace,
+                     Constant::getNullValue(PointerType::get(Type::IntTy)));
+<p>This function replaces a particular instruction with another
+instruction.  The following example illustrates the replacement of one
+<tt>AllocaInst</tt> with another.<p>
+AllocaInst* instToReplace = ...;
+ReplaceInstWithInst(*instToReplace->getParent(), instToReplace,
+                    new AllocaInst(Type::IntTy, 0, "ptrToReplacedInt");
+<p><i>Replacing multiple uses of <tt>User</tt>s and
+		    <tt>Value</tt>s</i></p>
+You can use <tt>Value::replaceAllUsesWith</tt> and
+<tt>User::replaceUsesOfWith</tt> to change more than one use at a
+time.  See the doxygen documentation for the <a
+href="/doxygen/classValue.html">Value Class</a> and <a
+href="/doxygen/classUser.html">User Class</a>, respectively, for more
+<!-- Value::replaceAllUsesWith User::replaceUsesOfWith Point out:
+include/llvm/Transforms/Utils/ especially BasicBlockUtils.h with:
+ReplaceInstWithValue, ReplaceInstWithInst
 <!-- *********************************************************************** -->
@@ -1575,6 +1616,6 @@
 <a href="mailto:sabre at nondot.org">Chris Lattner</a></address>
 <!-- Created: Tue Aug  6 15:00:33 CDT 2002 -->
 <!-- hhmts start -->
-Last modified: Tue Sep 17 17:41:54 CDT 2002
+Last modified: Tue Sep 17 22:16:24 CDT 2002
 <!-- hhmts end -->

More information about the llvm-commits mailing list