[LLVMdev] How to get a return type of a function with LLVM-C API

Syoyo Fujita syoyofujita at gmail.com
Fri May 23 08:36:28 PDT 2008


Hi Gordon and Matthjis,

I got the return type of the function in success with the way Gordon
explained.

RetTy = LLVMGetReturnType(LLVMGetElementType(LLVMTypeOf(F)))
Thanks a lot!

--
Syoyo


On Thu, May 22, 2008 at 11:33 PM, Gordon Henriksen <gordonhenriksen at mac.com>
> wrote:
> You're trying to apply an operation on a Type to a Value; that's no good,
> as you say. So you want the return type of the *type of the function*. But
> the function value itself is of type %function*, so you have to
> 'dereference' the type first:
>
> LLVMGetReturnType(LLVMGetElementType(LLVMTypeOf(F)))
>
> This may help to clarify:
> http://llvm.org/docs/ProgrammersManual.html#coreclasses
>





On Fri, May 23, 2008 at 12:02 AM, Matthijs Kooijman <matthijs at stdin.nl>
wrote:

> Hi Syoyo,
>
> > I am trying to get a return type of a function(from bitcode file) with
> > LLVM-C API, but there seems no appropriate API to do that.
> From my memory, this info is stored in the function type, so you could look
> at
> the function's type and get the info there.
>
> Looking the the API docs [1], I find that there is a simple method on
> Function
> called getReturnType(). You should thus be able to do:
>        Type* rt = F->getReturnType();
>
> Good luck,
>
> Matthijs
>
> [1]: http://llvm.org/doxygen/classllvm_1_1Function.html
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080524/e22d4ef9/attachment.html>


More information about the llvm-dev mailing list