[LLVMdev] Python Backend

Eli Bendersky eliben at google.com
Tue Nov 20 15:56:41 PST 2012


> ----------------------------------------------------------------------------------
> 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



More information about the llvm-dev mailing list