<div dir="ltr">Many thanks for the detailed replies and advice. If I may attempt to summarize, my plans as I described them were rather heavy on the theory, and the foremost piece of advice, I think, is that theory typically settles itself into memory much better if it can be readily attached to prior experiences. Hence, it is better introduced more gradually in favour of first gaining familiarity with the IR by writing a front-end for it, using the ample documentation already available. This will provide knowledge of something very concrete (the IR) that will help grasp the implications of the more advanced concepts more easily once I start learning about them, as well as provide a basis to start digging more deeply (say, writing optimizations or even a back-end).<br><br>As for a concrete project, while most is still new to me, I did already dabble a little with Prolog implementations recently, having written a parser and bytecode interpreter for a small fragment using a stack-based machine (then still in Java, though I would now like to practice with C). There's several papers showing how abstract machines for Prolog can be used as intermediate languages for actual compilation down to machine code (e.g., GNU Prolog: Beyond compiling Prolog to C), and targeting the LLVM IR instead should then not be too hard once the latter is well understood.<br><br>Again, many thanks for the inspiring advice and success stories. Also, Mukul, I'm very happy to receive any sort of advice and would never feel offended by it. (So, to repeat myself once more, many thanks!)<br><br><br>Kind regards,<br><br>Arno<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 3, 2015 at 9:24 PM, Mukul Sabharwal <span dir="ltr"><<a href="mailto:mjsabby@gmail.com" target="_blank">mjsabby@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Good recommendations on the thread already, but let me add by saying<br>
you don't _need_ to learn C or C++ to use LLVM; of course<br>
contributions would require familiarity with C++. You can use a<br>
library that talks to LLVM in your favorite language, and if that's<br>
Java, this seems to be the most up-to-date project with bindings:<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_robovm_robovm_tree_master_llvm&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=tOJAsddafWO1whEsj5L0qD84ZyrUk9w6BUols8mjPvw&s=4sXorbWLMWj04hK7CQjNBMOcnsIYaw7QDZ1BI3oWLZY&e=" rel="noreferrer" target="_blank">https://github.com/robovm/robovm/tree/master/llvm</a><br>
<br>
Let me also critique your reading list if your goal is writing a first<br>
compiler. Understanding SSA, optimizations, etc. is 10x more lucid<br>
(and you appreciate it more) when you see some IR or assembly and the<br>
impact a certain optimization or concept can have on it. Let me be<br>
clear, your reading list is bang on for some topics, but I feel like<br>
you'll miss some "aha" moments if you've not actually written some<br>
code first-hand, or maybe gone through some simple code generation<br>
steps (even if it's reading code).<br>
<br>
In college, I took a course (and did well) on compiler optimizations<br>
(program analysis to be specific) and we went through pretty much all<br>
what is needed (theory) to build an optimizing compiler: cfg<br>
construction, dataflow frameworks, SSA form, fixed points, lattices<br>
and abstract interpretation, etc. but a few years hence without using<br>
any of that it's been somewhat of a re-learning this past year or so.<br>
The formal education there was absolutely critical for the concepts,<br>
but I didn't get something tangible at the end of it.<br>
<br>
If optimizations are really what you want to understand or implement,<br>
might I suggest starting with the one of the simplest ones: Constant<br>
folding. It's simple to implement yet there is a feeling of<br>
accomplishment.<br>
<br>
Finally, to be honest since learning is an individual experience my<br>
suggestions may not at all be helpful, but if you learn like I do ...<br>
by doing, they just might.<br>
<br>
P.S. - I have no idea about your level of cs understanding is, so<br>
please don't be offended if what I've suggested is too naive or simple<br>
for you.<br>
<div class="HOEnZb"><div class="h5"><br>
On Mon, Aug 3, 2015 at 10:07 AM, Renato Golin <<a href="mailto:renato.golin@linaro.org">renato.golin@linaro.org</a>> wrote:<br>
> On 3 August 2015 at 16:29, Arno Bastenhof <<a href="mailto:arnobastenhof@gmail.com">arnobastenhof@gmail.com</a>> wrote:<br>
>> Based on these<br>
>> readings, as a matter of exercise I can take what I learnt from LCC to write<br>
>> a small compiler in C targeting the LLVM IR for, say, a subset of Prolog.<br>
><br>
> Hi Arno,<br>
><br>
> This is not a monumental task. There are many tutorials in the LLVM<br>
> tree, and producing IR from a simple AST is actually simple and<br>
> straight-forward.<br>
><br>
> So many languages can target LLVM IR, that it's very hard that you'll<br>
> find something that cannot be represented in IR. At least something<br>
> that other implementations haven't found already, and worked around.<br>
><br>
> With your broad knowledge in CS, I wouldn't expect you to take more<br>
> than a month or two to get a front-end working with the JIT compiler<br>
> on a reasonable subset of Prolog. Of course, the deeper you go, the<br>
> more time it takes to progress the same 1%, but you can always stop<br>
> when productivity drops as fast as enjoyment. :)<br>
><br>
> But you won't need to understand the back-end at all, modulo some<br>
> quirks on your platform of choice. The hint is to write the same logic<br>
> in Prolog and C, compile the C with Clang and see what they do. If you<br>
> spot hackery, the least resistance path is to replicate the hackery.<br>
> Asking on the list is also a good way to understand why the hackery,<br>
> and maybe even give you an entry point into changing the middle/back<br>
> end to support a proper construct in IR for better codegen.<br>
><br>
> From there, I'd recommend you to try different targets. Get some<br>
> board, device, phone you have at your disposal (RaspberryPi2 is a<br>
> great inexpensive kit), and make it work. You'll take a lot less<br>
> effort than you're imagining...<br>
><br>
> cheers,<br>
> --renato<br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>