<div dir="ltr">True,<div><br></div><div>I was toying with the idea of having a separate step in the pipeline that plugs in after AST is turned into a Module[*] which generates frontend code.</div><div>But to do so, I would have to have forward declarations be actually emitted, hence my proposal. Otherwise I'd just be iterating over an empty set of instructions :)</div><div>My theory is that LLVM IR at that point is going to be way more straightforward (just basic types, structs and `declare @..`s) to deal with.</div><div>Could this approach make sense? <br></div><div><br></div><div>Cheers,</div><div><br></div><div>-yawnt</div><div><br></div><div>[*] a Clang plugin? Can they be run over Modules, that is LLVM IR, instead of AST?</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-11-30 10:59 GMT+00:00 Alex L <span dir="ltr"><<a href="mailto:arphaman@gmail.com" target="_blank">arphaman@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On 30 November 2016 at 09:12, Gianluca Stivan via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi everyone,<div><br></div><div>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].</div></div></blockquote><div><br></div></span><div>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.</div><div><br></div><div>Cheers,</div><div>Alex</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr"><div><br></div><div>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)</div><div><br></div><div>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? </div><div>I saw there's a `-femit-all-decls`, but it doesn't really emit all declarations.</div><div><br></div><div><div>Apologies if this is a dumb idea, kinda new to the whole Clang thing :)!</div></div><div><br></div><div>Cheers,</div><div><br></div><div>-yawnt</div><div><br></div><div>[1] <a href="http://stackoverflow.com/questions/24728901/clang-compiling-a-c-header-to-llvm-ir-bitcode" target="_blank">http://stackoverflow.com/quest<wbr>ions/24728901/clang-compiling-<wbr>a-c-header-to-llvm-ir-bitcode</a></div><div>[2] <a href="http://stackoverflow.com/questions/14032496/how-can-i-code-generate-unused-declarations-with-clang?noredirect=1&lq=1" target="_blank">http://stackoverflow.com/q<wbr>uestions/14032496/how-can-i-co<wbr>de-generate-unused-declaration<wbr>s-with-clang?noredirect=1&lq=1</a></div><div>[3] <a href="https://github.com/tjfontaine/node-ffi-generate" target="_blank">https://github.com/tjfonta<wbr>ine/node-ffi-generate</a></div></div>
<br></span>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div>