Surprising that this topic has (as of now) 60 point and only two comments.
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.
HN is one of those great communities where people usually don't comment when they they aren't qualified to comment. It's either that, or they get down voted to heck and hell banned if they continuously post low quality material.
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.
Are there any books or resources that teach how you would go about using flex, bison and llvm together to create something more substantial. I would find this incredibly useful.
You can check my WIP language for an example. The following is the repository where every component (lexer, parser, compiler, running-time library) is in its own module.
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.
Making my first toy language is one of the most interesting advertures as a programmer. LLVM is quite complex and the documentation is far from stellar but it's usable for teaching how a compiler works.
Also I like the restyling. LLVM landing page is so 90'.
That's not what I meant. Maybe I was unclear. I mean that instead of the makey-uppy Kaleidoscope procedural langauge a makey-uppy mini scheme was used instead, that is to say KaleidoscopeScheme ...
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!
Well, the addition of LLVM support referenced in the Phoronix article had this bit:
"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."
Interesting, I'm read through the tutorial, and took the source, while tweaking it to conform to RPython, then feeding it into PyPy's translator.
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.
Your observations are pretty accurate. I'm fortunate enough to work with the maintainer of llvmpy and he's done some great work in making llvmpy pretty Pythonic. Should also check llvm-cbuilder the EDSL for building up higher level LLVM constructs:
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.