[LLVMdev] Instruction for print
criswell at illinois.edu
Wed Feb 8 10:04:33 PST 2012
On 2/8/12 11:55 AM, tarun agrawal wrote:
> 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
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev