[LLVMdev] Get a vector value.

Nick Lewycky nicholas at mxc.ca
Mon Nov 7 20:22:08 PST 2011


Yakov Malinkovich wrote:
>   Hello
> I have a pointer to llvm::Value *,I know its a pointer to some
> llvm::CompositeType (vector)
> Could you please tell me how can I get a value of specific index in the
> vector.
> Thank you.

Use the extractelement instruction, like so:

   Value *Elem = Builder.CreateExtractElement(MyVectorValue, ElementNumber);

See http://llvm.org/docs/LangRef.html#i_extractelement .

Nick



More information about the llvm-dev mailing list