[LLVMdev] Operand, instruction

John Criswell criswell at cs.uiuc.edu
Wed Feb 11 12:44:21 PST 2009


Nipun Arora wrote:
> Hi,
>
> How can one extract the operand of an instruction in an LLVM pass?
> Like I can get the opcode bt I'd like to get the operands as well
>   
Use the getOperand() method of class Instruction (which I think is
inherited from Value or User or some other LLVM class).  It takes a
single parameter that is an index specifying which operand to return. 
The return value is a llvm::Value *, IIRC.

If you haven't used it yet, I'd recommend using the LLVM doxygen
documentation (http://llvm.org/doxygen/hierarchy.html).  I've found it
to be an invaluable resource for answering these sorts of questions.  In
this case, just look up the llvm::Instruction class and see if it has a
method that does what you want.  If it doesn't, check its parent class,
the grandparent class, etc. until you find the method you want.

-- John T.

> Thanks
> Nipun
>
>   




More information about the llvm-dev mailing list