Hi Óscar,<br><br>But if I do "I1->getOperand(0)->getOperand(0)" I get " ‘class llvm::Value’ has no member named ‘getOperand’ ". getOperand() I think it's only defined for Instruction class. Do you know any equivalent method for Value?<br>
<br><div class="gmail_quote">On Fri, Jan 11, 2013 at 12:07 PM, Óscar Fuentes <span dir="ltr"><<a href="mailto:ofv@wanadoo.es" target="_blank">ofv@wanadoo.es</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">Alexandru Ionut Diaconescu <<a href="mailto:alexandruionutdiaconescu@gmail.com">alexandruionutdiaconescu@gmail.com</a>> writes:<br>
<br>
> But I have another problem: Do you know how can I iterate through a Value*?<br>
> For instance, I have :<br>
><br>
> Instruction *I1; // I take only I1 that are ICmp<br>
><br>
> errs()<<"\n "<<*I1->getOperand(0)<<" \n";<br>
> // %3 = load i32* %c, align 4<br>
><br>
> As expected. Now I want to get %c from the previous to use "%c" in<br>
> comparisons. I tried :<br>
><br>
> for (llvm::Value::use_iterator VI=(*I1->getOperand(0)).use_begin(),<br>
> VE=(*I1->getOperand(0)).use_end(); VI != VE ; ++VI)<br>
>   {<br>
><br>
>     errs()<<"\n "<<**VI<<" \n";<br>
>    // %cmp3 = icmp ne i32 %3, 0<br>
>   }<br>
><br>
> Not as expected.  It is printing the I1 instruction.<br>
><br>
> Do you know how I can get %c from the "load instruction"?<br>
<br>
</div>In this case, you get %c starting from I1 this way:<br>
<br>
I1->getOperand(0)->getOperand(0)<br>
<br>
because "%3 = load i32* %c, align 4" (or %3, for short) is the first<br>
operand of I1, and %c is the first operand of %3.<br>
<br>
Please note that some Instructions are Values too. This is the case for<br>
the Instruction `load'.<br>
<div class="HOEnZb"><div class="h5"><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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><font style="background-color:rgb(255,255,255);color:rgb(153,153,153)">Best regards,</font><br style="background-color:rgb(255,255,255);color:rgb(153,153,153)">
<font style="background-color:rgb(255,255,255);color:rgb(153,153,153)">Alexandru Ionut Diaconescu</font><br>