summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJoel Stanley <jstanley@cs.uiuc.edu>2002-09-11 20:50:04 +0000
committerJoel Stanley <jstanley@cs.uiuc.edu>2002-09-11 20:50:04 +0000
commit01040b24e0b80e6fa4290887daed6fd796a51740 (patch)
treeb95e1a4e219d91e02b854f51c2b30e4a6da05144 /docs
parent0374b8de2b4a329793287439a9c79d372778230b (diff)
downloadllvm-01040b24e0b80e6fa4290887daed6fd796a51740.tar.gz
llvm-01040b24e0b80e6fa4290887daed6fd796a51740.tar.bz2
llvm-01040b24e0b80e6fa4290887daed6fd796a51740.tar.xz
*** empty log message ***
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r--docs/ProgrammersManual.html41
1 files changed, 40 insertions, 1 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html
index 2709b2298d..dbecb58235 100644
--- a/docs/ProgrammersManual.html
+++ b/docs/ProgrammersManual.html
@@ -543,6 +543,45 @@ class OurFunctionPass : public FunctionPass {
</ul><h4><a name="iterate_chains"><hr size=0>Iterating over def-use &amp;
use-def chains</h4><ul>
+Frequently, we might have an instance of the <a
+href="/doxygen/classValue.html">Value Class</a> and we want to
+determine which <tt>User</tt>s use the <tt>Value</tt>. The list of
+all <tt>User</tt>s of a particular <tt>Value</tt> is called a
+<i>def-use</i> chain. For example, let's say we have a
+<tt>Function*</tt> named <tt>F</tt> to a particular function
+<tt>foo</tt>. Finding all of the instructions that <i>use</i>
+<tt>foo</tt> is as simple as iterating over the <i>def-use</i> chain of
+<tt>F</tt>:
+
+<pre>
+Function* F = ...;
+
+for(Value::use_iterator i = F-&gt;use_begin(), e = F-&gt;use_end(); i != e; ++i) {
+ if(Instruction* i = dyn_cast&lt;Instruction&gt;(*i)) {
+ cerr &lt;&lt; "F is used in instruction:\n\t";
+ cerr &lt;&lt; *i &lt;&lt; "\n";
+ }
+}
+</pre>
+
+Alternately, it's common to have an instance of the <a
+href="/doxygen/classUser.html">User Class</a> and need to know what
+<tt>Value</tt>s are used by it. The list of all <tt>Value</tt>s used
+by a <tt>User</tt> is known as a <i>use-def</i> chain. Instances of
+class <tt>Instruction</tt> are common <tt>User</tt>s, so we might want
+to iterate over all of the values that a particular instruction uses
+(that is, the operands of the particular <tt>Instruction</tt>):
+
+<pre>
+Instruction* pi = ...;
+
+for(User::op_iterator i = pi-&gt;op_begin(), e = pi-&gt;op_end(); i != e; ++i) {
+ Value* v = i-&gt;get();
+ ...
+}
+</pre>
+
+
<!--
def-use chains ("finding all users of"): Value::use_begin/use_end
use-def chains ("finding all values used"): User::op_begin/op_end [op=operand]
@@ -1389,6 +1428,6 @@ pointer to the parent Function.
<a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
<!-- Created: Tue Aug 6 15:00:33 CDT 2002 -->
<!-- hhmts start -->
-Last modified: Tue Sep 10 10:19:56 CDT 2002
+Last modified: Wed Sep 11 15:48:49 CDT 2002
<!-- hhmts end -->
</font></body></html>