Hi, I have a version of the old CBackend which is working with the current trunk. I am in the progress of rewriting it into a new version but that project is not going as fast as I would hope as I have been distracted by other tasks with higher priority lately. Anyway, for those interested, I can provide patches, optionally separated into several parts (core, testing, misc). I am afraid that the main patch is larger than the LLVM mailing lists allows me to send over the list directly Cheers, Roel On 21/11/12 00:46, Wojciech Daniło wrote:> Hi! > I'm trying to write LLVM Python Backend (to generate Python code out of > LLVM IR) > I'm still learning LLVM and for now it is very hard to me to even create > simple taksk. I want you to ask 3 questions: > > ---------------------------------------------------------------------------------- > 1) > I want to base on some existing code to learn how it was build. I > wanted to base on CBackend (which is no longer available from LLVM 3.0 > up) and of course it does not compile with LLVM 3.2 - giving a lot of > errors: > (the code is taken from source of LLVM 3.0 and put into > $LLVMSRC/projects/<copy of sample project>/lib/Target/CBackend - I hope > this is good method to do it) > http://pastebin.com/dkbJWpgP > Does anybody have this example working under LLVM3.2? I have found on > some old mailing lists that CBackend was never working as it should but > it was working for some simple examples - I'm looking for somethingl ike > that in LLVM 3.2. > If not, what is the best minimal example I can base onto writing my backend? > > ---------------------------------------------------------------------------------- > 2) > Maybe this question I will answer myself by analising some examples > you'll provide as answer to the first question, but maybe it will worth > asking it now. > So I want to know when to generate a class in Python. So far I know, > that in LLVM there are no classes, only functions, but when using the > online LLVM generator I can see, that when generating IR from C++ code, > the "class" keyword is stored inside of name (or something like name) of > function: > > #include <stdio.h> > #include <stdlib.h> > class X{ > public: > void f(); > }; > void X::f() { printf("inside f");} > int main() { X x; x.f();} > > translates into: > > [...] > > define void @_ZN1X1fEv(%class.X*nocapture %this)nounwind uwtablealign 2 { > %1 =tail call i32 (i8*, ...)* @printf(i8*getelementptr inbounds ([9 xi8]* @.str,i64 0,i64 0)) > ret void > } > > [...] > > > How can I access it inside of my function Pass to get know if it was class or not? > > > > ---------------------------------------------------------------------------------- > > 3) > > > Is there any manual that will help me discover all these advanced LLVM features needed to write such backend? I have read LLVM Kaleidoscope tutorials, some LLVM tutorials from IBM and lot of articles, but I still feel that I have not knowledge enough. > > > > Thank you :) > >
I'm very interested in this patch. Could you, Roel, upload it somewhere or maybe put your code to github or something simmilar? Additional - you're fixing it - could you please provide a little more information - what should I read to get more informations about writing not hardware but software backend in LLVM? (Of course the code analysis is one way, but maybe there is other also). 2012/11/21 Roel Jordans <r.jordans at tue.nl>> Hi, > > I have a version of the old CBackend which is working with the current > trunk. > > I am in the progress of rewriting it into a new version but that project > is not going as fast as I would hope as I have been distracted by other > tasks with higher priority lately. > > Anyway, for those interested, I can provide patches, optionally > separated into several parts (core, testing, misc). > > I am afraid that the main patch is larger than the LLVM mailing lists > allows me to send over the list directly > > Cheers, > Roel > > On 21/11/12 00:46, Wojciech Daniło wrote: > >> Hi! >> I'm trying to write LLVM Python Backend (to generate Python code out of >> LLVM IR) >> I'm still learning LLVM and for now it is very hard to me to even create >> simple taksk. I want you to ask 3 questions: >> >> ------------------------------**------------------------------** >> ---------------------- >> 1) >> I want to base on some existing code to learn how it was build. I >> wanted to base on CBackend (which is no longer available from LLVM 3.0 >> up) and of course it does not compile with LLVM 3.2 - giving a lot of >> errors: >> (the code is taken from source of LLVM 3.0 and put into >> $LLVMSRC/projects/<copy of sample project>/lib/Target/CBackend - I hope >> this is good method to do it) >> http://pastebin.com/dkbJWpgP >> Does anybody have this example working under LLVM3.2? I have found on >> some old mailing lists that CBackend was never working as it should but >> it was working for some simple examples - I'm looking for somethingl ike >> that in LLVM 3.2. >> If not, what is the best minimal example I can base onto writing my >> backend? >> >> ------------------------------**------------------------------** >> ---------------------- >> 2) >> Maybe this question I will answer myself by analising some examples >> you'll provide as answer to the first question, but maybe it will worth >> asking it now. >> So I want to know when to generate a class in Python. So far I know, >> that in LLVM there are no classes, only functions, but when using the >> online LLVM generator I can see, that when generating IR from C++ code, >> the "class" keyword is stored inside of name (or something like name) of >> function: >> >> #include <stdio.h> >> #include <stdlib.h> >> class X{ >> public: >> void f(); >> }; >> void X::f() { printf("inside f");} >> int main() { X x; x.f();} >> >> translates into: >> >> [...] >> >> define void @_ZN1X1fEv(%class.X*nocapture %this)nounwind uwtablealign >> 2 { >> %1 =tail call i32 (i8*, ...)* @printf(i8*getelementptr inbounds >> ([9 xi8]* @.str,i64 0,i64 0)) >> ret void >> } >> >> [...] >> >> >> How can I access it inside of my function Pass to get know if it was >> class or not? >> >> >> >> ------------------------------**------------------------------** >> ---------------------- >> >> 3) >> >> >> Is there any manual that will help me discover all these advanced LLVM >> features needed to write such backend? I have read LLVM Kaleidoscope >> tutorials, some LLVM tutorials from IBM and lot of articles, but I still >> feel that I have not knowledge enough. >> >> >> >> Thank you :) >> >> >> > > ______________________________**_________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121121/3dc4eaa7/attachment.html>
I've sent my earlier ideas to the list. That post should give a good idea on the things I am considering: http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-August/052858.html For a patch set, check the following message: http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-November/056089.html Cheers, Roel On 21/11/12 15:25, Wojciech Daniło wrote:> I'm very interested in this patch. Could you, Roel, upload it somewhere > or maybe put your code to github or something simmilar? > > Additional - you're fixing it - could you please provide a little more > information - what should I read to get more informations about writing > not hardware but software backend in LLVM? (Of course the code analysis > is one way, but maybe there is other also). > > > 2012/11/21 Roel Jordans <r.jordans at tue.nl <mailto:r.jordans at tue.nl>> > > Hi, > > I have a version of the old CBackend which is working with the current > trunk. > > I am in the progress of rewriting it into a new version but that project > is not going as fast as I would hope as I have been distracted by other > tasks with higher priority lately. > > Anyway, for those interested, I can provide patches, optionally > separated into several parts (core, testing, misc). > > I am afraid that the main patch is larger than the LLVM mailing lists > allows me to send over the list directly > > Cheers, > Roel > > On 21/11/12 00:46, Wojciech Daniło wrote: > > Hi! > I'm trying to write LLVM Python Backend (to generate Python code > out of > LLVM IR) > I'm still learning LLVM and for now it is very hard to me to > even create > simple taksk. I want you to ask 3 questions: > > ------------------------------__------------------------------__---------------------- > 1) > I want to base on some existing code to learn how it was build. I > wanted to base on CBackend (which is no longer available from > LLVM 3.0 > up) and of course it does not compile with LLVM 3.2 - giving a > lot of > errors: > (the code is taken from source of LLVM 3.0 and put into > $LLVMSRC/projects/<copy of sample project>/lib/Target/CBackend - > I hope > this is good method to do it) > http://pastebin.com/dkbJWpgP > Does anybody have this example working under LLVM3.2? I have > found on > some old mailing lists that CBackend was never working as it > should but > it was working for some simple examples - I'm looking for > somethingl ike > that in LLVM 3.2. > If not, what is the best minimal example I can base onto writing > my backend? > > ------------------------------__------------------------------__---------------------- > 2) > Maybe this question I will answer myself by analising some examples > you'll provide as answer to the first question, but maybe it > will worth > asking it now. > So I want to know when to generate a class in Python. So far I know, > that in LLVM there are no classes, only functions, but when > using the > online LLVM generator I can see, that when generating IR from > C++ code, > the "class" keyword is stored inside of name (or something like > name) of > function: > > #include <stdio.h> > #include <stdlib.h> > class X{ > public: > void f(); > }; > void X::f() { printf("inside f");} > int main() { X x; x.f();} > > translates into: > > [...] > > define void @_ZN1X1fEv(%class.X*nocapture %this)nounwind > uwtablealign 2 { > %1 =tail call i32 (i8*, ...)* @printf(i8*getelementptr > inbounds ([9 xi8]* @.str,i64 0,i64 0)) > ret void > } > > [...] > > > How can I access it inside of my function Pass to get know if it > was class or not? > > > > ------------------------------__------------------------------__---------------------- > > 3) > > > Is there any manual that will help me discover all these > advanced LLVM features needed to write such backend? I have read > LLVM Kaleidoscope tutorials, some LLVM tutorials from IBM and > lot of articles, but I still feel that I have not knowledge enough. > > > > Thank you :) > > > > > _________________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/__mailman/listinfo/llvmdev > <http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev> > >