I will take a look into NVPTX. I don't want to deconstruct C++ classes to generate Python code - I want to generate Python backend :) Its purpose is to be able to generate Python code from LLVM IR code (not C++ code! - C++ code is needed for me only to get a sample IR code). I want to write my custom compiler in the future and I want to be able to output Python code from it (of course not only Python code - I want to be able to output IR or bytecode also), so I though that writing Python Backend (as a function pass) is the best solution. Am I wrong? 2012/11/21 Eli Bendersky <eliben at google.com>> > > ---------------------------------------------------------------------------------- > > 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 uwtable align > 2 { > > %1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x > > i8]* @.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? > > Why do you need to deconstruct C++ classes to generate Python code > from LLVM IR? What will you gain from that? > > > 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. > > I hope you ran into http://llvm.org/docs/WritingAnLLVMBackend.html > > Eli >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121121/b6b2bda0/attachment.html>
And of course I will tak a look into http://llvm.org/docs/WritingAnLLVMBackend.html - I have somehow overlooked that document. 2012/11/21 Wojciech Daniło <wojtek.danilo.ml at gmail.com>> I will take a look into NVPTX. > > I don't want to deconstruct C++ classes to generate Python code - I want > to generate Python backend :) > Its purpose is to be able to generate Python code from LLVM IR code (not > C++ code! - C++ code is needed for me only to get a sample IR code). > > I want to write my custom compiler in the future and I want to be able to > output Python code from it (of course not only Python code - I want to be > able to output IR or bytecode also), so I though that writing Python > Backend (as a function pass) is the best solution. Am I wrong? > > 2012/11/21 Eli Bendersky <eliben at google.com> > >> > >> ---------------------------------------------------------------------------------- >> > 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 uwtable >> align 2 { >> > %1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 >> x >> > i8]* @.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? >> >> Why do you need to deconstruct C++ classes to generate Python code >> from LLVM IR? What will you gain from that? >> >> > 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. >> >> I hope you ran into http://llvm.org/docs/WritingAnLLVMBackend.html >> >> Eli >> > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121121/689d4a58/attachment.html>
On Tue, Nov 20, 2012 at 4:10 PM, Wojciech Daniło <wojtek.danilo.ml at gmail.com> wrote:> I will take a look into NVPTX. > > I don't want to deconstruct C++ classes to generate Python code - I want to > generate Python backend :) > Its purpose is to be able to generate Python code from LLVM IR code (not C++ > code! - C++ code is needed for me only to get a sample IR code). > > I want to write my custom compiler in the future and I want to be able to > output Python code from it (of course not only Python code - I want to be > able to output IR or bytecode also), so I though that writing Python Backend > (as a function pass) is the best solution. Am I wrong?What I was trying to say is that I don't see why you need Python classes in the generated code. LLVM IR is much lower than the concept of classes, so if you want to translate it to some executable form (such as Python) you don't need classes there. Functions to represent IR functions should be enough. Eli
You are of course right. I wanted to output "good looking" Python code though. (if its possible) I see that NVPTX backend is really big project. Is there any hello world "common codegen infrastructure"? 2012/11/21 Eli Bendersky <eliben at google.com>> On Tue, Nov 20, 2012 at 4:10 PM, Wojciech Daniło > <wojtek.danilo.ml at gmail.com> wrote: > > I will take a look into NVPTX. > > > > I don't want to deconstruct C++ classes to generate Python code - I want > to > > generate Python backend :) > > Its purpose is to be able to generate Python code from LLVM IR code (not > C++ > > code! - C++ code is needed for me only to get a sample IR code). > > > > I want to write my custom compiler in the future and I want to be able to > > output Python code from it (of course not only Python code - I want to be > > able to output IR or bytecode also), so I though that writing Python > Backend > > (as a function pass) is the best solution. Am I wrong? > > What I was trying to say is that I don't see why you need Python > classes in the generated code. LLVM IR is much lower than the concept > of classes, so if you want to translate it to some executable form > (such as Python) you don't need classes there. Functions to represent > IR functions should be enough. > > Eli >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121121/08a25ae2/attachment.html>