Yes, it is sort of scary that there seems to be no definite resource to
consult for information on especially advanced OOP things. I have
something like 20 compiler books on my shelves and yet none of them mention
a single word on how to implement multiple inheritance, exception handling,
or interfaces. It seems like they are all happy about presenting a subset
of Pascal, or Java, with an integer and boolean type, and then let the
reader figure out all the hard stuff by himself or herself. I know I
picked most of my knowledge up from doing lots of debug info converters
back when C++ was just coming to market - the early C-only debuggers didn't
understand C++ so the quick solution was to convert C++ debug info into
lowered C debug info
If you know of any compiler book that covers
advanced OOP topics, please feel free to let me know the title/ISBN of it.
Probably the best I know of as a learning resource would be this "C/C++ Low
Level Curriculum" series by Alex Darby on #AltDevBlog. The first post is <
http://www.altdevblogaday.com/2011/11/09/a-low-level-curriculum-for-c-and-c/>,
but there are a lot of them.
I was thinking of making a tutorial sometime down the road when I have
myself grasped sufficient about LLVM. For the time being, I think it makes
a lot of sense to first transform into C (a language known by most) and
then take it one level further by transforming into LLVM IR. I cannot
promise that I will make such a tutorial, but the outcome of this
sub-project should definitely make it much easier to make such a tutorial.
Personally, I think the lowering into C makes the difficult topics very
easy to understand: Once you've understood how to lower a C++ class into a
C structure with associated functions, almost all of the magic of the C++
class vanishes and you're set to go.
I envision LLVM as a sort of "compiler builders' power toolbox" and along
with that vision goes a lot of great documentation that makes you fly in no
time.
I wouldn't consider LLVM to be such a toolbox. LLVM's functionality covers
a lot, but it's mostly just the last leg of the compilation pipeline
(lowering to machine code, in object files, etc.; what is usually called
the "backend"). We have a handful of things that might be useful to a
frontend like SourceMgr, SMLoc, SMDiagnostic, et al, but those are really
very secondary and mostly incidental; maybe if someday clang's
SourceManager and diagnostics infrastructure are unified into LLVM core,
then we would be able to provide clients with that part, but it's still
mostly a "utility", and not really a huge amount of functionality.
To be honest, I personally feel that the learning curve is a bit steep.
From building using a non-Microsoft compiler (on Windows) over to making a
buildbot slave over to implementing an actual language using LLVM, I think
the path is rather difficult. It may just be me, or it may also be that
you LLVM gurus have breathed LLVM for so long that you no longer remember
that not everybody getting in touch with LLVM actually wants to code on
LLVM.
I'm pretty sure that the pain of building LLVM and all the related issues
remains a big annoyance even for seasoned LLVM developers.
I'll add a section on "How to Interface to the Operating System" to the
article. I'll focus on interfacing directly with the host operating system
as I personally dislike the C run-time library for a lot of reasons (ever
met a programmer who routinely checked errno? - I haven't, although I have
once or twice in my life seen Unix code that actually did bother to check
errno).
Perhaps it is better if I already now plan to release this article on my
own web site? I don't want to impose it on you guys, but I definitely want
to do it.
May a 1000 flowers bloom. Go for it.
I know there are more than 5.000 programming languages in the world and
if only half the developers were to adopt LLVM, things would surely look
much brighter with respect to the number of contributors of builders,
documentation, and actual code patches.
LLVM is a big dependency. Not all languages want or need that. For example,
just libLLVMX86CodeGen.a is like 8 times larger than the entirety of
LuaJIT. Also, although some recent work is helping to make LLVM better for
dynamic language compilation, LLVM is still far from being well suited for
general dynamic language compilation (and I don't think that's really a
goal for the project), except maybe for the last leg when lowering to
machine code.
-- Sean Silva