<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">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><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><br></div></div>
<br><br></div>
</div>