<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 24, 2015 at 1:15 PM, Hui Zhang <span dir="ltr"><<a href="mailto:wayne.huizhang@gmail.com" target="_blank">wayne.huizhang@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:georgia,serif;font-size:large">Hello, all<br><br></div><div style="font-family:georgia,serif;font-size:large"> I don't quite understand the llvm::use class, from the class ref, I read that:<br><p><i>"A <a href="http://llvm.org/docs/doxygen/html/classllvm_1_1Use.html" title="A Use represents the edge between a Value definition and its users." target="_blank">Use</a> represents the edge between a <a href="http://llvm.org/docs/doxygen/html/classllvm_1_1Value.html" title="LLVM Value Representation." target="_blank">Value</a> definition and its users.This is notionally a two-dimensional linked list"</i></p><p>I can image that it's like an edge between the operand<->User, but how to comprehend the "two-dimensional linked list" ?</p></div></div></blockquote><div><br></div><div>Dunno what that comment is getting at, other than it covers both the user and the use itself.</div><div> <br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:georgia,serif;font-size:large"><p>(*Instruction derives from User that derives from Value*)</p><p>And I found "use_iterator()" in Value, for example: a Value 'v',  if it's an operand of many Instructions 'i1,i2,i3...', then in my understanding, uses of v are just i1, i2, i3...</p></div></div></blockquote><div>no, they are the specific parts of i1, i2, i3 that refer to v.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:georgia,serif;font-size:large"><p> but what's the difference between use and user in this case ??</p></div></div></blockquote><div><br></div><div>Use points directly to the *place in the User* that the Value appears</div><div>User is the *thing holding the Use*.</div><div><br></div><div>So here, i1, i2, i3 are *Users* of Value v. If you use the user_iterator, that is what it will return</div><div><br></div><div>If i1, i2, i3 were looked at as just arrays of operands, like so:<br><br></div><div>i1 = [foo, v]</div><div>i2 = [v, foo]</div><div>i3 = [foo, v, bar]</div><div><br></div><div>Then the user iterator for v would give you i1, i2, and i3. Those are the containers that have the use in them.</div><div>The use iterator for v will give you something that points to &i1[1], &i2[0], &i3[1], because those are the actual pointers to the use in those containers.</div><div><br></div><div>Thus, if call setUse on a use, you are *actually changing that specific use to something*. <br>There is no setUser.</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:georgia,serif;font-size:large"><p>Besides, if the Value 'v' here is itself an Instruction, then what are its 'uses' and 'users' ?? </p></div></div></blockquote><div>See above</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:georgia,serif;font-size:large"><p>I feel that the result of an instruction can be an operand of another instruction, but it should not be regarded as the instruction itself right ??</p><p>Very confused...hope I can get some help to clarify my thoughts....</p><p>thanks<span class="HOEnZb"><font color="#888888"><br></font></span></p><span class="HOEnZb"><font color="#888888"><p><br></p><p><br></p></font></span></div><span class="HOEnZb"><font color="#888888"><br>-- <br><div>Best regards<br><br><br>Hui Zhang<br></div>
</font></span></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div></div>