[LLVMdev] How to create arguments CallInst

Rafael Baldiati Parizi parizi.computacao at gmail.com
Thu Oct 6 10:40:47 PDT 2011


virtual std::vector<Value *> getESetArgumentosFunc(Function *F){
std::vector<Value *> varg_list;
varg_list.clear();
for(Function::arg_iterator arg_iti = F->getArgumentList().begin(), arg_ite =
F->getArgumentList().end(); arg_iti != arg_ite; ++arg_iti){
Value *para = ConstantInt::get(IntegerType::get(getGlobalContext(),32), 0);
*Value *val2 = cast<* arg_iti->getType()*>(para);
                      <--------------------------*
para->setName("test");
varg_list.push_back(para);
}
return varg_list;
}

How can I make this cast??


2011/10/6 John Criswell <criswell at illinois.edu>

>  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 listLLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>


-- 
*Rafael Parizi*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111006/62474465/attachment.html>


More information about the llvm-dev mailing list