diff options
author | Joel Stanley <jstanley@cs.uiuc.edu> | 2002-09-11 20:50:04 +0000 |
---|---|---|
committer | Joel Stanley <jstanley@cs.uiuc.edu> | 2002-09-11 20:50:04 +0000 |
commit | 01040b24e0b80e6fa4290887daed6fd796a51740 (patch) | |
tree | b95e1a4e219d91e02b854f51c2b30e4a6da05144 /docs/ProgrammersManual.html | |
parent | 0374b8de2b4a329793287439a9c79d372778230b (diff) | |
download | external_llvm-01040b24e0b80e6fa4290887daed6fd796a51740.zip external_llvm-01040b24e0b80e6fa4290887daed6fd796a51740.tar.gz external_llvm-01040b24e0b80e6fa4290887daed6fd796a51740.tar.bz2 |
*** empty log message ***
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/ProgrammersManual.html')
-rw-r--r-- | docs/ProgrammersManual.html | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index 2709b22..dbecb58 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 & 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->use_begin(), e = F->use_end(); i != e; ++i) { + if(Instruction* i = dyn_cast<Instruction>(*i)) { + cerr << "F is used in instruction:\n\t"; + cerr << *i << "\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->op_begin(), e = pi->op_end(); i != e; ++i) { + Value* v = i->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> |