www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - LLVM

reply "Craig Black" <cblack ara.com> writes:
LLVM (http://llvm.org/) is a backend for compilers.  It is portable to many 
platforms, well documened, and actively developed.  It seems that they are 
making great progress with it.

A crazy idea.  Has anyone considered using LLVM with D's front end?  I know 
Walter has his own back end, but it's seems hard for one guy to maintain 
both a front and back end, and do a good job at both.  Even a programming 
god like Walter.  If we had the LLVM team actively developing and innovating 
the back end, then Walter could focus on innovating the front end and the D 
language.  Just a thought.

-Craig 
Nov 20 2006
next sibling parent reply Gregor Richards <Richards codu.org> writes:
Craig Black wrote:
 LLVM (http://llvm.org/) is a backend for compilers.  It is portable to many 
 platforms, well documened, and actively developed.  It seems that they are 
 making great progress with it.
 
 A crazy idea.  Has anyone considered using LLVM with D's front end?  I know 
 Walter has his own back end, but it's seems hard for one guy to maintain 
 both a front and back end, and do a good job at both.  Even a programming 
 god like Walter.  If we had the LLVM team actively developing and innovating 
 the back end, then Walter could focus on innovating the front end and the D 
 language.  Just a thought.
 
 -Craig 
 
 

I have tried it with LLVM's GCC and GDC. It didn't work out-of-the-box, but I don't think it would take a whole lot of hackery. - Gregor Richards
Nov 20 2006
parent reply "Craig Black" <cblack ara.com> writes:
 I have tried it with LLVM's GCC and GDC.  It didn't work out-of-the-box, 
 but I don't think it would take a whole lot of hackery.

  - Gregor Richards

How long ago did you try this? LLVM just released a new 1.9 version that they claim is way better. I'm not sure what you mean by out-of-the-box. But, like you say, I don't think it would be a massive effort. It seems that LLVM is pretty well thought out. -Craig
Nov 20 2006
parent reply Charlie <charlies nowhere.com> writes:
A third D compiler would be very cool, especially if its around when D 
goes 1.0.

Craig Black wrote:
 I have tried it with LLVM's GCC and GDC.  It didn't work out-of-the-box, 
 but I don't think it would take a whole lot of hackery.

  - Gregor Richards

How long ago did you try this? LLVM just released a new 1.9 version that they claim is way better. I'm not sure what you mean by out-of-the-box. But, like you say, I don't think it would be a massive effort. It seems that LLVM is pretty well thought out. -Craig

Nov 20 2006
next sibling parent reply Gregor Richards <Richards codu.org> writes:
Charlie wrote:
 A third D compiler would be very cool, especially if its around when D 
 goes 1.0.
 
 Craig Black wrote:
 
 I have tried it with LLVM's GCC and GDC.  It didn't work 
 out-of-the-box, but I don't think it would take a whole lot of hackery.

  - Gregor Richards

How long ago did you try this? LLVM just released a new 1.9 version that they claim is way better. I'm not sure what you mean by out-of-the-box. But, like you say, I don't think it would be a massive effort. It seems that LLVM is pretty well thought out. -Craig


LLVM uses GCC, so in all fairness it would hardly be a third D compiler, it would just be another face of GDC. - Gregor Richards
Nov 20 2006
parent reply Charlie <charlies nowhere.com> writes:
Hmm, I don't think it uses GCC as a backend.

 From the website: We find that LLVM is able to compile C++ into 
substantially better code than GCC .

It says it can use the GCC front-end for its LLVM backend, which I think 
is the opposite of GDC, which uses DMD front end to produce a tree 
usable by GCC backend.

I think DMD Frontend translated to LLVM backend would be completely 
independent of GCC, and the more compilers the better!

Charlie


Gregor Richards wrote:
 Charlie wrote:
 A third D compiler would be very cool, especially if its around when D 
 goes 1.0.

 Craig Black wrote:

 I have tried it with LLVM's GCC and GDC.  It didn't work 
 out-of-the-box, but I don't think it would take a whole lot of hackery.

  - Gregor Richards

How long ago did you try this? LLVM just released a new 1.9 version that they claim is way better. I'm not sure what you mean by out-of-the-box. But, like you say, I don't think it would be a massive effort. It seems that LLVM is pretty well thought out. -Craig


LLVM uses GCC, so in all fairness it would hardly be a third D compiler, it would just be another face of GDC. - Gregor Richards

Nov 20 2006
next sibling parent Wayne <wanderon comcast.net> writes:
Take a look at

http://llvm.org/pubs/2006-04-25-GelatoLLVMIntro.pdf

LLVM optionally uses GCC as a front end for C/C++ FORTRAN ADA and Java.
It looks like the existing DMD front end could be adapted to LLVM

Wayne

Charlie Wrote:
 Hmm, I don't think it uses GCC as a backend.
  From the website: We find that LLVM is able to compile C++ into
 substantially better code than GCC .
 It says it can use the GCC front-end for its LLVM backend, which I think
 is the opposite of GDC, which uses DMD front end to produce a tree
 usable by GCC backend.
 I think DMD Frontend translated to LLVM backend would be completely
 independent of GCC, and the more compilers the better!
 Charlie
 Gregor Richards wrote:
 Charlie wrote:
 A third D compiler would be very cool, especially if its around when D
 goes 1.0.

 Craig Black wrote:

 I have tried it with LLVM's GCC and GDC.  It didn't work
 out-of-the-box, but I don't think it would take a whole lot of hackery.

  - Gregor Richards

How long ago did you try this? LLVM just released a new 1.9 version that they claim is way better. I'm not sure what you mean by out-of-the-box. But, like you say, I don't think it would be a massive effort. It seems that LLVM is pretty well thought out. -Craig


LLVM uses GCC, so in all fairness it would hardly be a third D compiler, it would just be another face of GDC. - Gregor Richards


Nov 20 2006
prev sibling parent Gregor Richards <Richards codu.org> writes:
Charlie wrote:
 
 
 Gregor Richards wrote:
 
 Charlie wrote:

 A third D compiler would be very cool, especially if its around when 
 D goes 1.0.

 Craig Black wrote:

 I have tried it with LLVM's GCC and GDC.  It didn't work 
 out-of-the-box, but I don't think it would take a whole lot of 
 hackery.

  - Gregor Richards

How long ago did you try this? LLVM just released a new 1.9 version that they claim is way better. I'm not sure what you mean by out-of-the-box. But, like you say, I don't think it would be a massive effort. It seems that LLVM is pretty well thought out. -Craig


LLVM uses GCC, so in all fairness it would hardly be a third D compiler, it would just be another face of GDC. - Gregor Richards

Hmm, I don't think it uses GCC as a backend. From the website: We find that LLVM is able to compile C++ into substantially better code than GCC . It says it can use the GCC front-end for its LLVM backend, which I think is the opposite of GDC, which uses DMD front end to produce a tree usable by GCC backend. I think DMD Frontend translated to LLVM backend would be completely independent of GCC, and the more compilers the better! Charlie

)top-post don't please( Normal GCC (simplified): [C] code -> GIMPLE -> target ASM LLVM GCC (simplified): [C] code -> GIMPLE -> LLVM ASM Normal GDC (simplified); D code -> GIMPLE -> target ASM LLVM GDC (simplified): D code -> GIMPLE -> LLVM ASM The same component of GCC (namely, the IR, GIMPLE) is both a backend to GDC and a frontend to LLVM. - Gregor Richards
Nov 20 2006
prev sibling parent reply Wolfgang Draxinger <wdraxinger darkstargames.de> writes:
Charlie wrote:

 A third D compiler would be very cool, especially if its around
 when D goes 1.0.

I already mentioned my attempts on a D ABI for which I planned to fork GDC. I think, this is the perfect moment to get my LLVM based D compiler started. So in 3 words: I'm on it! Wolfgang Draxinger -- E-Mail address works, Jabber: hexarith jabber.org, ICQ: 134682867
Nov 20 2006
parent "Craig Black" <cblack ara.com> writes:
 I'm on it!

Excellent! I'm very curious about performance comparisons. Keep us posted! -Craig
Nov 20 2006
prev sibling next sibling parent jcc7 <technocrat7 gmail.com> writes:
== Quote from Craig Black (cblack ara.com)'s article
 LLVM (http://llvm.org/) is a backend for compilers.  It is portable to
 many platforms, well documened, and actively developed.  It seems that > they

 A crazy idea.  Has anyone considered using LLVM with D's front end?

Someone has looked into doing this a couple years ago. I don't know if he ran into a serious problem (or perhaps just lost interest in the idea), but I'm guessing he never finished his project: http://www.digitalmars.com/d/archives/D/gnu/762.html
Nov 20 2006
prev sibling next sibling parent reply "Lionello Lunesu" <lionello lunesu.remove.com> writes:
Great idea!
I just noticed however that their IR language has no "real" (long double) 
float representation?

L.
Nov 20 2006
parent reply "Craig Black" <cblack ara.com> writes:
"Lionello Lunesu" <lionello lunesu.remove.com> wrote in message 
news:ejt4m7$2o18$1 digitaldaemon.com...
 Great idea!
 I just noticed however that their IR language has no "real" (long double) 
 float representation?

 L.

Good point. Perhaps someone could suggest that they add one. -Craig
Nov 20 2006
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Craig Black wrote:

I just noticed however that their IR language has no "real" (long double) 
float representation?

Good point. Perhaps someone could suggest that they add one.

Just use the "double" type, that is what PowerPC does anyway... --anders
Nov 20 2006
parent reply "Craig Black" <cblack ara.com> writes:
64 bit doubles are sufficient for most applications, but not all.

-Craig 
Nov 20 2006
parent Walter Bright <newshound digitalmars.com> writes:
Craig Black wrote:
 64 bit doubles are sufficient for most applications, but not all.

If the underlying hardware does not support extended real types, then it is reasonable for a D compiler to treat them as doubles. If the hardware does support extended real, then for a D compiler to not support it, well, I'd call that not a proper D implementation.
Nov 20 2006
prev sibling next sibling parent Wolfgang Draxinger <wdraxinger darkstargames.de> writes:
Craig Black wrote:

 LLVM (http://llvm.org/) is a backend for compilers.  It is
 portable to many
 platforms, well documened, and actively developed.  It seems
 that they are making great progress with it.

Cool. A few weeks ago I wondered why there is not (well there is, but I wasn't aware of it) a comiler suite, where each step of the compilation process can be individually controlled. Now I know about LLVM. Thanks. Wolfgang Draxinger -- E-Mail address works, Jabber: hexarith jabber.org, ICQ: 134682867
Nov 20 2006
prev sibling next sibling parent "John Reimer" <terminal.node gmail.com> writes:
On Mon, 20 Nov 2006 10:56:53 -0800, Craig Black <cblack ara.com> wrote:

 LLVM (http://llvm.org/) is a backend for compilers.  It is portable to  
 many
 platforms, well documened, and actively developed.  It seems that they  
 are
 making great progress with it.

 A crazy idea.  Has anyone considered using LLVM with D's front end?  I  
 know
 Walter has his own back end, but it's seems hard for one guy to maintain
 both a front and back end, and do a good job at both.  Even a programming
 god like Walter.  If we had the LLVM team actively developing and  
 innovating
 the back end, then Walter could focus on innovating the front end and  
 the D
 language.  Just a thought.

 -Craig

I like this idea! I'm not sure how difficult it would be to include a D frontend with the default distribution (in the way that several gcc frontends seem to be included), but the licensing certainly appears to be quite accommodating. -JJR
Nov 20 2006
prev sibling parent reply Chad J <gamerChad _spamIsBad_gmail.com> writes:
Craig Black wrote:
 LLVM (http://llvm.org/) is a backend for compilers.  It is portable to many 
 platforms, well documened, and actively developed.  It seems that they are 
 making great progress with it.
 
 A crazy idea.  Has anyone considered using LLVM with D's front end?  I know 
 Walter has his own back end, but it's seems hard for one guy to maintain 
 both a front and back end, and do a good job at both.  Even a programming 
 god like Walter.  If we had the LLVM team actively developing and innovating 
 the back end, then Walter could focus on innovating the front end and the D 
 language.  Just a thought.
 
 -Craig 
 
 

Hmmm... looks like they are working on an ARM backend. This could be nice. If they get that ARM backend done by say, summer of next year, and the D front-end is plugged in, then I might be willing to take a crack at making ARM work on that one in addition to GDC. Then I could decide which one is nicer to work with and focus on that. Kind of a longshot though (they'd need wince support too). Admittedly the current arm-wince-pe GDC I put together has some uh ...annoyances... and I've no idea how to solve them. Now I wonder, is Walter really maintaining the backend much? I thought that part of dmd was pretty solid already and he is just focusing on the front-end and other D affairs. What would impress me is if the main development of D would occur on this LLVM compiler, or at least be readily portable to it within hours or a few days (this assumes LLVM is a good quality backend that Walter wouldn't mind switching to). The utility I am looking for there is having a bleeding-edge D compiler that is also very retargetable, and doesn't require big man-hours to be maintained as it seems gdc does. DMD is great on windows, but it is fairly useless on my pda since, well, it doesn't even generate code for that at all!
Nov 20 2006
parent reply "John Reimer" <terminal.node gmail.com> writes:
On Mon, 20 Nov 2006 13:41:28 -0800, Chad J  
<gamerChad _spamIsBad_gmail.com> wrote:

 Craig Black wrote:
 LLVM (http://llvm.org/) is a backend for compilers.  It is portable to  
 many platforms, well documened, and actively developed.  It seems that  
 they are making great progress with it.
  A crazy idea.  Has anyone considered using LLVM with D's front end?  I  
 know Walter has his own back end, but it's seems hard for one guy to  
 maintain both a front and back end, and do a good job at both.  Even a  
 programming god like Walter.  If we had the LLVM team actively  
 developing and innovating the back end, then Walter could focus on  
 innovating the front end and the D language.  Just a thought.
  -Craig

Hmmm... looks like they are working on an ARM backend. This could be nice. If they get that ARM backend done by say, summer of next year, and the D front-end is plugged in, then I might be willing to take a crack at making ARM work on that one in addition to GDC. Then I could decide which one is nicer to work with and focus on that. Kind of a longshot though (they'd need wince support too). Admittedly the current arm-wince-pe GDC I put together has some uh ...annoyances... and I've no idea how to solve them. Now I wonder, is Walter really maintaining the backend much? I thought that part of dmd was pretty solid already and he is just focusing on the front-end and other D affairs. What would impress me is if the main development of D would occur on this LLVM compiler, or at least be readily portable to it within hours or a few days (this assumes LLVM is a good quality backend that Walter wouldn't mind switching to). The utility I am looking for there is having a bleeding-edge D compiler that is also very retargetable, and doesn't require big man-hours to be maintained as it seems gdc does. DMD is great on windows, but it is fairly useless on my pda since, well, it doesn't even generate code for that at all!

I'm wondering if Walter will have the same source "tainting" issue with LLVM as he did for gcc. I wish not because it would be much better if the reference compiler development could continue on a completely open system. -JJR
Nov 20 2006
next sibling parent reply Gregor Richards <Richards codu.org> writes:
John Reimer wrote:
 On Mon, 20 Nov 2006 13:41:28 -0800, Chad J  
 <gamerChad _spamIsBad_gmail.com> wrote:
 
 Craig Black wrote:

 LLVM (http://llvm.org/) is a backend for compilers.  It is portable 
 to  many platforms, well documened, and actively developed.  It seems 
 that  they are making great progress with it.
  A crazy idea.  Has anyone considered using LLVM with D's front end?  
 I  know Walter has his own back end, but it's seems hard for one guy 
 to  maintain both a front and back end, and do a good job at both.  
 Even a  programming god like Walter.  If we had the LLVM team 
 actively  developing and innovating the back end, then Walter could 
 focus on  innovating the front end and the D language.  Just a thought.
  -Craig

Hmmm... looks like they are working on an ARM backend. This could be nice. If they get that ARM backend done by say, summer of next year, and the D front-end is plugged in, then I might be willing to take a crack at making ARM work on that one in addition to GDC. Then I could decide which one is nicer to work with and focus on that. Kind of a longshot though (they'd need wince support too). Admittedly the current arm-wince-pe GDC I put together has some uh ...annoyances... and I've no idea how to solve them. Now I wonder, is Walter really maintaining the backend much? I thought that part of dmd was pretty solid already and he is just focusing on the front-end and other D affairs. What would impress me is if the main development of D would occur on this LLVM compiler, or at least be readily portable to it within hours or a few days (this assumes LLVM is a good quality backend that Walter wouldn't mind switching to). The utility I am looking for there is having a bleeding-edge D compiler that is also very retargetable, and doesn't require big man-hours to be maintained as it seems gdc does. DMD is great on windows, but it is fairly useless on my pda since, well, it doesn't even generate code for that at all!

I'm wondering if Walter will have the same source "tainting" issue with LLVM as he did for gcc. I wish not because it would be much better if the reference compiler development could continue on a completely open system. -JJR

I have now posted this at least three times. LLVM's compiler is GCC. - Gregor Richards
Nov 20 2006
parent "John Reimer" <terminal.node gmail.com> writes:
On Mon, 20 Nov 2006 14:37:23 -0800, Gregor Richards <Richards codu.org>  
wrote:


 with  LLVM as he did for gcc.  I wish not because it would be much  
 better if the  reference compiler development could continue on a  
 completely open system.
  -JJR

I have now posted this at least three times. LLVM's compiler is GCC. - Gregor Richards

Yes, I've seen your posts. But it's unclear despite the nice little graph that you posted for us to consider. Quoting the site: "LLVM is also a collection of source code that implements the language and compilation strategy. The primary components of the LLVM infrastructure are a GCC-based C & C++ front-end, a link-time optimization framework with a growing set of global and interprocedural analyses and transformations, static back-ends for the X86, PowerPC, IA-64, Alpha and SPARC architectures, a back-end which emits portable C code, and a Just-In-Time compiler for X86 and PowerPC processors." My question is why do they say the the LLVM infrastructure uses the GCC-based /C & C++ front-end/? The backends are not GCC... I guess this is just depends how far back the backend is :)? (Oh wait... GIMPLE is a frontend for the virtual machine) You mentioned GIMPLE as being used for the IR (Intermediate Representation) which GDC uses to interface with the GCC backend. It's still a little unlcear to me, so have patience. 1) Is GIMPLE a problem for use here? (License-wise) 2) If GIMPLE is the IR, this means that GDC already has all that's necessary to attach to LLVM? 3) Whatever the case, including a GDC front end with LLVM may be easier than doing so with FSF. FSF seems to want complete ownership of the D frontend before they will accept it into the fold of gcc. Not sure how the LLVM group will act in this matter, but there licensing method seems quite different. -JJR
Nov 20 2006
prev sibling parent reply Walter Bright <newshound digitalmars.com> writes:
John Reimer wrote:
 I'm wondering if Walter will have the same source "tainting" issue with 
 LLVM as he did for gcc.

Yes, since it is copyrighted. However, I *can* read documentation about the compiler (one cannot copyright an idea, ideas are covered by patent law, not copyrights). Aside from working with the LLVM source, I am happy to help out in any way I can those who want to integrated the D front end with LLVM. One advantage LLVM has over gcc is that gcc is reluctant to include gdc as part of the default gcc distribution. If LLVM is willing to include D with their main distribution, that would be very good for D users.
Nov 20 2006
parent Paolo Invernizzi <arathorn NOSPAM_fastwebnet.it> writes:
I've played with LLVM and D, one yr ago, submitting patches to LLVM for 
VC7 compilation of the LLVM backend, just to try to do a backend for DMD 
frontend on Windows.

So, as seems that everybody is playing with the frontend, it's not time 
to have it in a svn repository on DigitalMars/somewhere?
We are all applying the same patches, merging subsequent Walter release, 
adding headers, and so on...

Can't we work on the same codebase? At least Walter and David Friedman!

Just my 2c....

---
Paolo Invernizzi


Walter Bright wrote:
 John Reimer wrote:
 I'm wondering if Walter will have the same source "tainting" issue 
 with LLVM as he did for gcc.

Yes, since it is copyrighted. However, I *can* read documentation about the compiler (one cannot copyright an idea, ideas are covered by patent law, not copyrights). Aside from working with the LLVM source, I am happy to help out in any way I can those who want to integrated the D front end with LLVM. One advantage LLVM has over gcc is that gcc is reluctant to include gdc as part of the default gcc distribution. If LLVM is willing to include D with their main distribution, that would be very good for D users.

Nov 21 2006