[cfe-dev] Flag for generating LLVM IR from forward declarations

Alex L via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 30 02:59:45 PST 2016


On 30 November 2016 at 09:12, Gianluca Stivan via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi everyone,
>
> I was playing around with the LLVM toolchain and it occurred to me that,
> should I decide to target LLVM IR, it would be neat to have Clang generate
> declarations from C header files for easier FFI. Someone seems to have had
> my same idea [1] [2]. This is kind of the opposite of what other projects
> have gone for, where they use libclang to parse header files to achieve the
> same result [3].
>

Sounds like an interesting idea. I how one question though, if you're
generating only the C function declarations in LLVM IR, how will your
frontend that targets LLVM IR call these declarations? Maybe I'm
misunderstanding something, but I don't see how can you generate the calls
to these functions without getting clang involved.

Cheers,
Alex


>
> Now, forward declaration generation is doable by patching
> CodeGenModule.cpp (I kinda have a PoC working locally, except it generates
> *all* the forward declarations, instead of just the ones from the header
> files I care about)
>
> Is this something that you guys would be interested in merging into Clang
> through a flag? Or what would the proper way to do this be?
> I saw there's a `-femit-all-decls`, but it doesn't really emit all
> declarations.
>
> Apologies if this is a dumb idea, kinda new to the whole Clang thing :)!
>
> Cheers,
>
> -yawnt
>
> [1] http://stackoverflow.com/questions/24728901/clang-
> compiling-a-c-header-to-llvm-ir-bitcode
> [2] http://stackoverflow.com/questions/14032496/how-can-i-
> code-generate-unused-declarations-with-clang?noredirect=1&lq=1
> [3] https://github.com/tjfontaine/node-ffi-generate
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161130/0cd5f77e/attachment.html>


More information about the cfe-dev mailing list