Hi!<div>I'm trying to write LLVM Python Backend (to generate Python code out of LLVM IR)</div><div>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:</div>
<div><br></div><div>----------------------------------------------------------------------------------</div>
<div>1)</div><div> 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:</div>

<div>(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)</div><div><a href="http://pastebin.com/dkbJWpgP" target="_blank">http://pastebin.com/dkbJWpgP</a></div>

<div>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.</div>

<div>If not, what is the best minimal example I can base onto writing my backend?</div><div><br></div><div>----------------------------------------------------------------------------------</div><div>2) </div><div>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. </div>

<div>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:</div>

<div><br></div><div>#include <stdio.h></div><div>#include <stdlib.h></div><div>class X{</div><div>public:</div><div>void f();</div><div>};</div><div>void X::f() { printf("inside f");}</div><div>int main() {  X x;  x.f();} </div>

<div><br></div><div>translates into:</div><div><br></div><div><pre>[...]

<span style="font-weight:bold;color:blue">define</span> <span style="font-style:oblique;color:green">void</span> @_ZN1X1fEv(%class.X* <span style="font-weight:bold;color:blue">nocapture</span> %this) <span style="font-weight:bold;color:blue">nounwind</span> uwtable <span style="font-weight:bold;color:blue">align</span> 2 {
  %1 = <span style="font-weight:bold;color:blue">tail</span> <span style="font-weight:bold;color:blue">call</span> <span style="font-style:oblique;color:green">i32</span> (<span style="font-style:oblique;color:green">i8</span>*, ...)* @printf(<span style="font-style:oblique;color:green">i8</span>* <span style="font-weight:bold;color:blue">getelementptr</span> inbounds ([9 x <span style="font-style:oblique;color:green">i8</span>]* @.str, <span style="font-style:oblique;color:green">i64</span> 0, <span style="font-style:oblique;color:green">i64</span> 0))
  <span style="font-weight:bold;color:blue">ret</span> <span style="font-style:oblique;color:green">void</span>
}</pre><pre><pre>[...]</pre><pre><br></pre><pre><span style="font-family:arial;white-space:normal">How can I access it inside of my function Pass to get know if it was class or not?</span></pre><pre><span style="font-family:arial;white-space:normal"><br>
</span></pre><pre><span style="font-family:arial;white-space:normal">----------------------------------------------------------------------------------</span></pre><pre><span style="font-family:arial;white-space:normal">3) </span></pre>
<pre><span style="font-family:arial;white-space:normal">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.</span></pre>
<pre><span style="font-family:arial;white-space:normal"><br></span></pre><pre><span style="font-family:arial;white-space:normal">Thank you :)</span></pre>
</pre></div>