[LLVMdev] Printing Function Arguments

ivtm martinaide1 at yahoo.com
Sun Sep 27 20:41:43 PDT 2009


Hey Oscar,

I want to extract information from the instruction.

Think writing a simple interpreter.

I already have the CallInst instance (described above in the message).

Via ci->getOperand(1) say I can get the 'i32 8' parameter and I can get the
'i32' and '8' separately as Nick described.

But I need to extract the %0 from the CallInst instance somehow. I am not
sure what the exact method to call is.

I need that btw, for every instruction that writes, e.g. loads, adds, muls,
etc...There has got to be a generic method for that. 

I am looking at the existing LLVM passes to figure out how they extract
stuff, but since many are only computing the small relevant info that they
need, they do not always need to extract all the components of an
instruction. (I've looked at the interpreter too, but it is doing other
stuff).

Anyway..concretely, I need to extract the return register for an
instruction.



Óscar Fuentes wrote:
> 
> ivtm <martinaide1 at yahoo.com> writes:
> 
>> Another question, I need to get the "%0" below in the:
>>
>> %0 = tail call i32 (...)* @__FFF (i32 8) nounwind; <i32> [#uses=1]
>>
>> that is, the return register. 
> 
> What information do you want, exactly?
> 
> In your example, %0 is the CallInst. So if you have
> 
> CallInst *ci = CallInst::Create(...
> 
> then use `ci' whenever you want to use %0.
> 
>> I am wondering in general, where should I look in the llvm codebase for
>> parsing instructions ?
>>
>> I am looking at existing passes and also the header files like
>> Function.h,
>> etc to see what methods they have, but it takes a while to figure out the
>> basic methods...
> 
> This is a bit better than looking at header files:
> 
> http://llvm.org/doxygen/classes.html
> 
> -- 
> Óscar
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 
> 

-- 
View this message in context: http://www.nabble.com/Printing-Function-Arguments-tp25638981p25640242.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.





More information about the llvm-dev mailing list