[LLVMdev] Generating C code using LLVM

James Courtier-Dutton james.dutton at gmail.com
Fri May 15 03:43:08 PDT 2015


On 14 May 2015 at 20:44, Aditya Avinash <adityaavinash1 at gmail.com> wrote:
> Hi,
> I am trying to use LLVM to generate C (partly, Intel AVX) code to test some
> abstractions. Apparently, most of the documentation is related to generating
> LLVM-IR. Are there any tools to do this? (I have generated AST from these
> abstractions. I want to generate C code from it).
> Thank you! :)
>
> PS: If this is a wrong mailinglist, help me with the right one.
>

If you have your code at the AST level, you might as well use CLANG to
work at the AST level and create C code as output.
CLANG is closely linked to LLVM.
There seems very little point in lowering the AST to LLVM-IR then
output to C. You will loose useful structural information.
E.g. By using something like this with CLANG would be better:
http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang

Also, if you can create AST in a format CLANG understands, it can then
automatically lower it to LLVM-IR, and you will have your completed
compiler for your own language.

The mailing list for CLANG is
mailto: cfe-dev at cs.uiuc.edu

Kind Regards

James



More information about the llvm-dev mailing list