<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 10/6/11 12:40 PM, Rafael Baldiati Parizi wrote:
    <blockquote
cite="mid:CALhe0+EYfFhpYNCwx4dAX_S49Y1gshNJURWWpBHirs420EWwiw@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <div>virtual std::vector<Value *>
        getESetArgumentosFunc(Function *F){</div>
      <div><span class="Apple-tab-span" style="white-space:pre"> </span>std::vector<Value
        *> varg_list;</div>
      <div><span class="Apple-tab-span" style="white-space:pre"> </span>varg_list.clear();</div>
      <div><span class="Apple-tab-span" style="white-space:pre"> </span>for(Function::arg_iterator
        arg_iti = F->getArgumentList().begin(), arg_ite =
        F->getArgumentList().end(); arg_iti != arg_ite; ++arg_iti){</div>
      <div>
        <span class="Apple-tab-span" style="white-space:pre"> </span>Value
        *para =
        ConstantInt::get(IntegerType::get(getGlobalContext(),32), 0);</div>
      <div><span class="Apple-tab-span" style="white-space:pre"> </span><b>Value
          *val2 = cast<</b> arg_iti->getType()<b>>(para);      
                                                   
          <--------------------------</b></div>
      <div><span class="Apple-tab-span" style="white-space:pre"> </span>para->setName("test");<span
          class="Apple-tab-span" style="white-space:pre"> </span></div>
      <div><span class="Apple-tab-span" style="white-space:pre"> </span>varg_list.push_back(para);</div>
      <div><span class="Apple-tab-span" style="white-space:pre"> </span>} </div>
      <div><span class="Apple-tab-span" style="white-space:pre"> </span>return
        varg_list;</div>
      <div>}</div>
      <div><br>
      </div>
      <div>How can I make this cast??<br>
      </div>
    </blockquote>
    <br>
    I think you misunderstood me.  You need to *insert* an LLVM cast
    instruction.  For example, you might insert the following code:<br>
    <br>
    Value *para =
    ConstantInt::get(IntegerType::get(getGlobalContext(),32), 0);<br>
    Value * Val2 = CastInst::CreateZExtOrBitCast (para,
    arg_iti->getType(), "test", InsertPt)<br>
    <br>
    ... where InsertPt is an Instruction * specifying where to insert
    the cast instruction.<br>
    <br>
    Having said that, if all you're doing is inserting zero values of
    the appropriate type, it might be easier to use:<br>
    <br>
    Value * Val2 = Constant::getNullValue (arg_iti->getType());<br>
    <br>
    -- John T.<br>
    <br>
    <blockquote
cite="mid:CALhe0+EYfFhpYNCwx4dAX_S49Y1gshNJURWWpBHirs420EWwiw@mail.gmail.com"
      type="cite">
      <div><br>
      </div>
      <br>
      <div class="gmail_quote">2011/10/6 John Criswell <span dir="ltr"><<a
            moz-do-not-send="true" href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span><br>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex;">
          <div bgcolor="#FFFFFF" text="#000000">
            <div>
              <div class="h5"> On 10/6/11 11:48 AM, Rafael Baldiati
                Parizi wrote:
                <blockquote type="cite"> <font face="arial, sans-serif">Hello,<br>
                  </font>
                  <div>
                    <div>
                      <div>
                        <div><font face="arial, sans-serif">I need
                            create a CallInst to this function</font></div>
                        <div><font face="arial, sans-serif"><br>
                          </font></div>
                        <div><font face="arial, sans-serif">define i32
                            @function(i32 %n, i8 %m){ ... }</font></div>
                        <div><br>
                        </div>
                        <div>I now how get argument's type but <span
                            style="color:rgb(34, 34,
                            34);font-family:arial,
                            sans-serif;font-size:13px">I do not know how
                            to create arguments that meet these types.</span></div>
                        <div><span style="color:rgb(34, 34,
                            34);font-family:arial,
                            sans-serif;font-size:13px">For example, if
                            the argument is long, accurate pass CallInst
                            an integer argument, however, if a Char,
                            Char must pass an argument.</span></div>
                        <div><span style="color:rgb(34, 34,
                            34);font-family:arial,
                            sans-serif;font-size:13px">How to get the
                            type of the argument of the function
                            definition and create the same type to pass
                            the Callinst???</span></div>
                      </div>
                    </div>
                  </div>
                </blockquote>
                <br>
              </div>
            </div>
            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.<br>
            <br>
            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:<br>
            <br>
            <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/safecode/trunk/include/safecode/Utility.h?view=markup"
              target="_blank">http://llvm.org/viewvc/llvm-project/safecode/trunk/include/safecode/Utility.h?view=markup</a><br>
            <br>
            -- John T.<br>
            <br>
            <blockquote type="cite">
              <div>
                <div>
                  <div>
                    <div><span style="color:rgb(34, 34,
                        34);font-family:arial,
                        sans-serif;font-size:13px"><br>
                      </span></div>
                    <div><br>
                    </div>
                    -- <br>
                    <font size="2"><b><i>Rafael Parizi</i></b></font><br>
                    <br>
                    <br>
                    <br>
                  </div>
                </div>
              </div>
              <br>
              <fieldset></fieldset>
              <br>
              <pre>_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a moz-do-not-send="true" href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
            </blockquote>
            <br>
          </div>
        </blockquote>
      </div>
      <br>
      <br clear="all">
      <div><br>
      </div>
      -- <br>
      <font size="2"><b><i>Rafael Parizi</i></b></font><br>
      <br>
      <br>
      <br>
    </blockquote>
    <br>
  </body>
</html>