*** empty log message ***

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3684 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Joel Stanley 2002-09-11 20:50:04 +00:00
parent 0374b8de2b
commit 01040b24e0

View File

@ -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>