<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Dear Ammar,<br>
<br>
It is not clear what you are asking. %a and %b in your code below
are not constants; there is no way, at compile time, to determine
what numeric values they will hold at run-time.<br>
<br>
Are you asking how to write an LLVM pass that will add code to
summ() to print out its result?<br>
<br>
Regards,<br>
<br>
John Criswell <br>
<br>
On 4/24/16 2:27 AM, Ammar Naqvi via llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:CABqf+JXX9Aai79+nmQhByta1ZydqbHHx7g-V-o4xkAdG4ZHvAQ@mail.gmail.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
<div dir="ltr">Hello Everyone,<br>
<br>
I need some help in retrieving the numeric value of an
instruction operand from LLVM IR.
<div><br>
</div>
<div>this is what the IR looks like for a simple add function
that adds two i32 integers</div>
<div>
<div><br>
</div>
<div>define i32 @summ(i32 %a, i32 %b) #0 {</div>
<div>entry:</div>
<div> %add = add nsw i32 %b, %a</div>
<div> ret i32 %add</div>
<div>}</div>
</div>
<div><br>
</div>
<div>i would like to know the integer value of %a and %b.<br>
<br>
I've tried </div>
<div><br>
</div>
<div>-i->getOpcodeName() which gives me the string add</div>
<div><br>
</div>
<div>-i->getOperand(0) which gives me the string i32 %b<br>
</div>
<div><br>
</div>
-i->getOperand(0)->getName() which gives me the string a
<div><br>
</div>
<div>what method exists to get the actual integer value of the
operands?</div>
<div>for example we called summ(1,2), how to retrieve the values
1 and 2 held in the operands?<br>
<br>
Any help and guidance is greatly appreciated! :)<br>
<br>
Best,<br>
Ammar</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell">http://www.cs.rochester.edu/u/criswell</a></pre>
</body>
</html>