LLVM Tutorial
llvm.org
llvm.org
At Taodyne, we use LLVM as the foundation for our 3D dynamic document description language. This makes it possible to do interesting things in real-time, see e.g. http://www.taodyne.com/shop/en/blog/58-live-coding-creating-.... LLVM is pretty powerful, and now relatively stable as far as even the C++ API is concerned. In earlier days, having the C++ API change underneath you in significant way at every release was a real pain.
That being said, I was not a real fan of their documentation in general, and the Kaleidoscope tutorial was no exception. But it looks like they are putting a lot of effort into this, and it looks much much better than it used to.
It's probably more of the latter :)
The one problem I have with HN is the basic/extreme bike-shedding situation we have here.
Articles on hiring, firing, culture, etc. (softer - more bs subjects) and the singularity, complex economics and quantum physics (softer - more bs subjects for laymen) seem to get a metric ton of crappy comments from people who aren't qualified to talk about said topics and HNers seem to be much too nice (or don't care) enough to point out the crap for what it is.
I try to avoid those types of posts nowadays.
https://github.com/castel/libcastel
According to my experience on this language, I would recommand you ragel and lemon over flex and bison. They are very, very easy to bundle into a C++ application, without messing too much with the global symbol namespace.
A nice example is the Castel lexer, which is actually a preprocessed C++ source file : https://github.com/castel/libcastel/blob/master/parse/source...
Also I like the restyling. LLVM landing page is so 90'.
Then write Assembly macros that translate those bytecode into real Assembly code.
This will give you a nice picture without much effort how code generation can be done.
Surely the performance won't be stellar, but is a nice experience.
On the other hand you can plug it directly into LLVM, but there you get more things to learn at the same time, which might slow you down.
Scheme without continuations is no different than any other simple Algol. (minus GC, numeric tower, macros, etc. of course)
I have always been interested in compiler design having not been put off it by doing a computer science degree, but, having not done the degree I've also never learned anything about it. This looks like it should help.
Although, I was very confused by the first couple of sentences - the author apologises for their global variables, and not knowing which part of the compiler they're talking about I don't know if they means they're going to implement kaleidoscope without any notion of scope, and just make everything global, or if they're just talking about the parser code. It's quite clear soon after that it's the latter, but it makes it difficult to read the introduction!
"This patch excludes the NEON support also reviewed due to an outbreak of batshit insanity in our legal department. That will be committed soon bringing the changes to precisely what has been approved."
http://comments.gmane.org/gmane.comp.compilers.llvm.cvs/1349...
I'm just wondering what that was about and how serious it was.
What strikes me is that:
- with PyPy everything is implemented natively, i.e without resorting to foreign abstractions: instead of def CodeGen, I'd write def eval (or whatever my native AST evaluation wants), and instead of g_llvm_builder.fadd(left, right), I'd just do the native left+right. This makes it conceptually less of a mind split, and writing stuff like the BF interpreter is just straightforward [0].
- with LLVM, the concepts are nicely abstracted, and the API reasonably pythonic. I know I'm using LLVM but I don't feel like I'm hitting some thin C wrapper. Those concepts are ported and reinvested into other languages with ease: now that I got them by reading the python tutorial, I'm confident I can find my way in another project on another, less known to me language. Also, due to this abstracted common ground, access to functions coming from outside, (possibly other languages) is made easy. With PyPy I'm stuck to what's made available to RPython land.
[0]: http://morepypy.blogspot.fr/2011/04/tutorial-writing-interpr...
https://github.com/llvmpy/llvmpy/blob/master/README_LLVM_CBU...