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. -- Regards, *Aditya Atluri,* *USA.* -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150514/fa40ff8b/attachment.html>
>From what input? Usually Clang is the tool for "rewriting C" (making sourceto source conversions), but it's not clear if that's what you are trying to achieve, so some more information would be useful. Afaict, LLVM won't generate C source code tho'. --- Mats 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. > > -- > Regards, > > *Aditya Atluri,* > > *USA.* > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150514/64b65fad/attachment.html>
Hi, Thanks for the response. On Thu, May 14, 2015 at 5:06 PM, mats petersson <mats at planetcatfish.com> wrote:> From what input? Usually Clang is the tool for "rewriting C" (making > source to source conversions), but it's not clear if that's what you are > trying to achieve, so some more information would be useful. >I have successfully generated AST from my "hypothetical language" which can be translated to C. I want to use LLVM instead of building my own compiler. Rewriting "C" may work (I may have to try). I don't want to generate IR as it is hard to read whether the C output is exactly what I meant to write.> > Afaict, LLVM won't generate C source code tho'. >Oh. No chance? Thank you! :)> > --- > Mats > > 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. >> >> -- >> Regards, >> >> *Aditya Atluri,* >> >> *USA.* >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> >-- Regards, *Aditya Atluri,* *USA.* -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150514/eb598fb5/attachment.html>
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
I got the impression that the AST was more like the AST of Kaleidoscope than the AST of Clang - reading between the lines in the posts above. But yes, Clang has much better tools for generating C code out of AST than LLVM-IR will ever have. For example differnet types of loops [even when they are "strange forms"] will be retained in their original form - so loops using for(;;) as a forever loop will not turn into a while(true) or a goto loop. In LLVM-IR, this sort of construction would become lost, since the IR for any "endless loop" is identical. -- Mats On 15 May 2015 at 11:43, James Courtier-Dutton <james.dutton at gmail.com> wrote:> 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 > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150515/7bdd6ca5/attachment.html>
On Fri, May 15, 2015 at 6:43 AM, James Courtier-Dutton < james.dutton at gmail.com> wrote:> 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. >Cool.> There seems very little point in lowering the AST to LLVM-IR then > output to C. You will loose useful structural information. >I am trying to do AST->C. It's one way. You won't hit stages you already passed.> 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. >Thank you! :)> > The mailing list for CLANG is > mailto: cfe-dev at cs.uiuc.edu > > Kind Regards > > James >-- Regards, *Aditya Atluri,* *USA.* -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150515/35e0d4a8/attachment.html>