[LLVMdev] Extraction of constant operands from the instruction

Prabhat Kumar Saraswat prabhat.saraswat at gmail.com
Mon Jan 14 08:18:09 PST 2008

Hi all,

 I am trying to extract the operands from an instruction, for that i am
iterating over the operand list as defined by the user class.

 for (User::op_iterator O = i->op_begin() ;O != i->op_end(); ++O)
Value *v = *O;
llvm::cout << v->getNameStr() ;

However, whenever there is a constant operand like a numerical value, it
does not displays any value at all, i checked using the hasName() method,
for the constant operands the hasName() returns 0.
Is there anyway I can display/extract these constant values from the
instruction ?

Another question:
For and example IR like below,

%tmp6 = load i32* @glob_var, align 4            ; <i32> [#uses=1]

How can i extract the name of the instruction i.e. %tmp6

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080114/1edcf234/attachment.html>

More information about the llvm-dev mailing list