[LLVMdev] Instruction for print

John Criswell criswell at illinois.edu
Wed Feb 8 10:04:33 PST 2012


On 2/8/12 11:55 AM, tarun agrawal wrote:
> Hi,
>
> I am trying to insert a instruction for printf or cout. My aim is to 
> print a integer and a string value using that instruction, which are 
> already there in the code.
> but I am not able to understand how to do it. Any help would be great 
> help.

You want to insert a call instruction that calls the printf function.  
You'll need to insert a Function for printf (with no body) if no printf 
function exists within the LLVM module you're transforming.

So, the code will look something like:

Function * F = M.getOrInsertFunction ("printf", ...);
CallInst::Create (F, ...);

Be sure to look at the doxygen docs for exact method names and which 
parameters go where; I've skipped over such details above.

-- John T.

>
>
>
> Thanks and Regards,
> Tarun Agrawal
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120208/fdb11ab1/attachment.html>


More information about the llvm-dev mailing list