If you want an immediate constant value, ConstantInt::get(APInt(32, 5, false)) will perhaps help you ?<br><br>Olivier.<br><br><div class="gmail_quote">2009/5/5 seventh moon <span dir="ltr"><<a href="mailto:suigintou_@hotmail.com">suigintou_@hotmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



<div>
<font style="font-size: 12pt;" size="3">I have a question about inserting instructions into the LLVM IR.  I can insert instructions, but my operands do not have the right type, so it fails an assertion at runtime.</font><font style="font-size: 12pt;" size="3"><br>
</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3">I am trying to insert an immediate load instructions, as a means of claiming a new register.</font><font style="font-size: 12pt;" size="3"><br>
</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3">Here is what I do:</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3">    Builder.SetInsertPoint(LLVMBB, I);</font><font style="font-size: 12pt;" size="3"><br>
</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3">// The following line looks to me like it would have a chance o!
 f loading either</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3">// address 5, or else immediate value 5. Unfortunately, it does neither. It compiles</font><font style="font-size: 12pt;" size="3"><br>
</font><font style="font-size: 12pt;" size="3">// but crashes at runtime, that the type of the operand is incompatible</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3">        Instruction *newI=Builder.CreateLoad(5,"");</font><font style="font-size: 12pt;" size="3"><br>
</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3">// I also tested this, just to do a little sanity check. It also compiles then</font><font style="font-size: 12pt;" size="3"><br>
</font><font style="font-size: 12pt;" size="3">// crashes, for the obvious reason that the operand is a register, but an address</font><font style="" size="3"><br></font><font style="font-size: 12pt;" size="3">// or an immediate value is expected.</font><font style="font-size: 12pt;" size="3"><br>
</font><font style="font-size: 12pt;" size="3">        //Instruction *newI=Builder.CreateLoad(I->getOperand(1),""); // also wrong</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3"><br>
</font><font style="font-size: 12pt;" size="3">So to say it simply, my question is, "How can I create a new Value*, which indicates</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3">an immediate value, such as immediate value 5?"</font><font style="font-size: 12pt;" size="3"><br>
</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3">Thank you for your assistance,</font><font style="font-size: 12pt;" size="3"><br></font><font style="font-size: 12pt;" size="3">Kao Chang<br>
<hr>用部落格分享照片、影音、趣味小工具和最愛清單,盡情秀出!
 你自己 — <a href="http://home.spaces.live.com/?showUnauth=1&lc=1028" target="_blank">Windows Live Spaces</a></font></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br>