<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 9pt;
font-family:新細明體
}
</style>
</head>
<body class='hmmessage'>
<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="font-size: !
 12pt;" 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</!
 font><br /><hr />用部落格分享照片、影音、趣味小工具和最愛清單,盡情秀出!
 你自己 — <a href='http://home.spaces.live.com/?showUnauth=1&lc=1028' target='_new'>Windows Live Spaces</a></body>
</html>