D + LLVM?
Tomas Lindquist Olsen
tomas at famolsen.dk
Thu May 31 08:20:55 PDT 2007
Stephen Waits wrote:
> Has anyone looked at marrying the D front end to LLVM?
I have been playing around with merging the DMD frontend and LLVM for about
a week now. It's not a really serious attempt, but it's going a lot better
than I had thought it would. I had not planned to announce anything, but
since this post has arrived I thought I'd let out the secret.
I'm not a compiler guru, in fact this is my first attempt ever with anything
compiler related. Also I'm just a hobbyist programmer and I'm doing this in
my spare time just for fun.
Maybe something useful will come out of it, maybe it will die in a week.
Right now I just don't know... That being said I'm not going to stop yet as
it's actually pretty fun so far :)
To give an idea of how far I am (which isn't very far) I have the following
working so far:
* integral and floating types (real is double)
* pointers to the working types (& and *)
* global variables
* structs (no methods)
* free functions (templated too)
* = - * / += -= *= /= operators
As you can see I've only implemented a tiny fraction of the specification so
far, but it would definitely be nice to have a comlpete LLVM-D
implementation. It's just a really nice feeling to run my test modules in
the JIT compiler :P
The main issue I've had so far is translating to the LLVM SSA form. As far
as I have seen DMD does not provide any information about whether a
variable needs storage or not. Before pointers I had some really nice code
output, but when I got to pointers it all collapsed and now I use alloca
for all variables and rely on the mem2reg optimization pass to figure out
where it's really needed and not...
More information about the D.gnu