[LLVMdev] A problem creating operands for a new IR instruction to the mailing list

seventh moon suigintou_ at hotmail.com
Tue May 5 07:00:12 PDT 2009


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.

I am trying to insert an immediate load instructions, as a means of claiming a new register.

Here is what I do:
    Builder.SetInsertPoint(LLVMBB, I);

// The following line looks to me like it would have a chance of loading either
// address 5, or else immediate value 5. Unfortunately, it does neither. It compiles
// but crashes at runtime, that the type of the operand is incompatible
        Instruction *newI=Builder.CreateLoad(5,"");

// I also tested this, just to do a little sanity check. It also compiles then
// crashes, for the obvious reason that the operand is a register, but an address
// or an immediate value is expected.
        //Instruction *newI=Builder.CreateLoad(I->getOperand(1),""); // also wrong

So to say it simply, my question is, "How can I create a new Value*, which indicates
an immediate value, such as immediate value 5?"

Thank you for your assistance,
Kao Chang
_________________________________________________________________
用部落格分享照片、影音、趣味小工具和最愛清單,盡情秀出你自己 — Windows Live Spaces
http://home.spaces.live.com/?showUnauth=1&lc=1028
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090505/1affa5a3/attachment.html>


More information about the llvm-dev mailing list