[LLVMdev] How can I get the destination operand of an instruction?
John Criswell
criswell at illinois.edu
Tue May 8 19:52:31 PDT 2012
On 5/8/12 9:48 PM, Launcher wrote:
> I am able to access the source operands of an instruction using either
> getOperand() or op_iterator, However, I can't find any method available for
> destination operand. Someone suggests that instruction itself can represent
> the destination operand.
> http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-January/037518.html
In LLVM, the instruction *is* the same as it's result. Let us say that
instruction pointer I1 points to an add instruction and I2 points to a
subtract instruction. Then:
I2->setOperand (I1, 1);
will make instruction I1 the first operand of instruction I2 (note that
I didn't check the exact arguments of the setOperand() method, so they
may be off, but I think you get the idea).
-- John T.
>
> The getOperand() returns an unsigned value like 0x9063498, while I can't
> find any instruction's method that returns unsigned value. I have tried
> getValue(), but it actually returns the opcode of the instruction instead of
> a unique value of of an instruction instance.
>
> Anyone gives any suggestions about this?
>
>
>
More information about the llvm-dev
mailing list