[LLVMdev] How to create arguments CallInst
John Criswell
criswell at illinois.edu
Thu Oct 6 09:54:25 PDT 2011
On 10/6/11 11:48 AM, Rafael Baldiati Parizi wrote:
> Hello,
> I need create a CallInst to this function
>
> define i32 @function(i32 %n, i8 %m){ ... }
>
> I now how get argument's type but I do not know how to create
> arguments that meet these types.
> For example, if the argument is long, accurate pass CallInst an
> integer argument, however, if a Char, Char must pass an argument.
> How to get the type of the argument of the function definition and
> create the same type to pass the Callinst???
If you want to pass a value to a function that doesn't match the type,
you will need to insert a cast instruction to cast the value to the
correct type. Which cast instruction you insert will depend on the
value's type and the type you want it to be.
SAFECode has a utility function castTo() that takes a Value * and a
desired Type * and inserts a cast instruction if Value * is not of the
desired type. It's designed to minimize the number of cast instructions
it inserts so that the resulting LLVM IR is more readable for debugging:
http://llvm.org/viewvc/llvm-project/safecode/trunk/include/safecode/Utility.h?view=markup
-- John T.
>
>
> --
> */Rafael Parizi/*
>
>
>
>
>
> _______________________________________________
> 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/20111006/539b5c90/attachment.html>
More information about the llvm-dev
mailing list