<div dir="ltr">Hi Pooya,<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">1) What's the right way to add a class or an instance of it to a module? I could only find ways to add structs to modules and I'm not sure how to deal with classes. Any good references to check? Or any good article/projects/code samples to look into?</blockquote><div><br></div><div>LLVM IR is a low level representation - it doesn't have any built-in representation of classes beyond the structs that you've seen. Your frontend has to map those concepts onto LLVM IR.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">2) Is there a way to declare that certain parts of a structure won’t change during execution?</blockquote><div> </div><div>This is also a problem for the frontend.</div><div><br></div><div>You could take a look at how clang maps these concepts from C++ to LLVM IR by writing some simple C++ examples and then running:</div><div><br></div><div><font face="monospace, monospace">clang++ -emit-llvm -S -o foo.ll foo.cpp</font></div><div><br></div><div>If your input language is C/C++ you may want to use clang to build the IR that you want to JIT. There is an example of that in the clang/examples/clang-interpreter directory.</div><div><br></div><div>Finally, if your ultimate goal is to experiment with optimizations in the JIT you may find the new tutorial series that I'm working on helpful: "Building A JIT in LLVM" at <a href="http://llvm.org/docs/tutorial/">http://llvm.org/docs/tutorial/</a> . These tutorials are very new, and only the first chapter has a complete write-up, but all of the code is complete, and the code for Chapter 2, "Adding Optimizations", may be relevant to you. </div><div><br></div><div>Cheers,</div><div>Lang.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 2, 2016 at 4:36 PM, Pooya SaadatPanah via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I'm a grad student working on a C++11 project and I have no compiler background. I apologize for asking basic questions here. </div><div><br></div><div>Currently I'm looking for ways to optimize my code and as a starting point I wanted to experiment with loop unrolling and further I might consider function in-lining . I have been introduced to JIT compiler of LLVM and the possible application of it in my project.</div><div><br></div><div>Currently I know the basics about creating a module and getting a JIT compiler. I followed this:</div><div><a href="https://llvm.org/svn/llvm-project/llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp" target="_blank">https://llvm.org/svn/llvm-project/llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp</a><br></div><div><br></div><div>I have two questions:</div><div><br></div><div><div>1) What's the right way to add a class or an instance of it to a module? I could only find ways to add structs to modules and I'm not sure how to deal with classes. Any good references to check? Or any good article/projects/code samples to look into?</div></div><div><br></div><div>2) Is there a way to declare that certain parts of a structure won’t change during execution? For instance, let’s say that I have a class 'foo' and foo.x is 7 and doesn’t change over the life of the code, but foo.y does. There is a function in class foo and the function uses foo.x as the condition in the loop, thus I’d like to tell LLVM that foo.x is always 7, so that it can unroll the loop "for(int i = 0;i < foo.x;i++)". But I’m a little confused about how LLVM uses constants – they appear to be tied to global variables only, and only an entire global variable, so I don’t see how to make one component of it a constant. </div><div><br></div><div>Thank you,<br clear="all"><div><br></div><div>-P.S.P</div><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><br></div></div>
<br><br></font></span></div>
</div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>