A few days ago Craig Black made the suggestion in the D newsgroup,
that someone creates a D <http://www.digitalmars.com/d/index.html>
frontend for LLVM. Never having heard of LLVM in the past, I
immediately got captured by its design when I've read the
documentation. I was always scared by GCC - a great piece of
software, but horribly bad documented, and in it's own way not very
Welcome to LLVM
Since I'm currently working on a clean ABI draft for D I thought, that
implementing a D frontend for LLVM would also be a good test case for
my ABI drafts and so I agreed to implement that frontend.
Today I've built LLVM from source (however not the GCC frontend yet)
If you're making your own front end, you probably won't need it
and played a bit with the assembly language, and it brought up the
* How can I define parts of the ABI that cover calling conventions?
LLVM supports calling conventions, if that's what you mean. You can even
create your own, but you'd have to implement them in the code
* Which is the LLVM way of creating object files?
From what I've tried out yet, the llvm-ld will generate a executable.
llc produces target specific assembly; there is an option to output
object files, but this crashes on my system.
llvm-ld should generate an executable, but alas it is an unfinished
piece of work.
generally what we do is:
llc input.bc -o output.s
gcc output.s -o program
I've been meaning to finish the llvm-ld and llvmc tools for some time
now but other things have consistently gotten in the way. One of these
days they'll be working.
Note that you should be able to write a "D" configure file for llvmc
that sets up the various stages for compilation of D programs through
linking. Unfortunately, there isn't much good documentation on it and
the file format is not good. There's an open bug to clean this all up,
but it is not, as yet, implemented.
* Which is the best way to add support for new object file types. One
thing that a lot of people in the D community anticipate is the
possibility to compile modules into self contained objects, which can
be redistributed without additional header files, and be linked
either statically or dynamically into the final program. Kinda like
Pascal units. This of course requires to put additional information
into the created binary.
If you can create platform independent code from D, then you should be
able to just use the LLVM bytecode representation. Most of the tools put
this format out. Note that LLVM bytecode files are only as platform
independent as the language front end used to create them. The bytecode
files can be distributed and then targeted to any of the platforms that
LLVM supports. The bytecode format even retains which libraries it still
needs to link against so you should be able to turn the bytecode into an
executable fairly readily.
And I'd like to try, to let the thing to
create CLI binaries
Sounds interesting. How much like Microsoft CLR is it? You could
probably create a backend for CLI quite readily. See the "C" Backend
that turns LLVM IR into C99 code. You can see it here:
Writing a backend to support CLI output should be on the same order of
magnitude as that file. Its not particularly difficult due to the
regularity/simplicity of the LLVM IR.
And last but not least: Which parts of the documentation must I
definitely read in the first place to get started to hack LLVM (I'll
read all of course, but I'd like to focus right now).