www.digitalmars.com         C & C++   DMDScript  

D.gnu - D compiler written in D

reply Stephan Wienczny <wienczny web.de> writes:
Hallo,

the GCC efford will improve D's usability. When I tryed into GCC 
development, I saw that it has a horrible documentation and design.
On the long run it might be a good idea to write an new open source 
compiler supporting D using D. I've been starting such a project, but 
I'd like to talk about some design issues with somebody else. maybe 
sombody would even joing my project.
What I'd like to do better than GCC:
1. As language indepent tree structure as possible.
2. Making it a real cross-compiler. If I want to use GCC as cross 
compiler, I've got to recompile GCC. Why do we have dynamic libraries?
3. Making it easier to write and integrate a language frontend.
4. Integrating a compile manager (like make) into the compiler driver to 
make source easily platform independent.

How I would design such a thing:

My compiler should be modular.

Compiler driver: Managing compile process.
Language frontend: Creating syntax tree.
Optimizer: Doing non platform specific optimisations.
Backend: System specific codegeneator doing system specific optimisation

The syntax-tree can be split into two parts.
The first one are deklarations (like classes) which indirectly result in 
code (eg. for construction etc.)
and implementations (eg. functions)
In my dreams the tree structure should be albe to represent the 
complete D syntax as it is a very advanced one. Being able to represent 
  D's syntax C++, C, maybe Java are not a great problem.

What do you think?

At the end a great praise to Walter for his work.
Feb 03 2004
next sibling parent reply "Walter" <walter digitalmars.com> writes:
The D front end code would be pretty easy to translate into D, as I tend to
write C++ code using 'D style' anyway. Creating a new optimizer and back end
is an enormous project, though. Wouldn't it be easier to clean up GCC?


"Stephan Wienczny" <wienczny web.de> wrote in message
news:bvosu7$rf2$1 digitaldaemon.com...
 Hallo,

 the GCC efford will improve D's usability. When I tryed into GCC
 development, I saw that it has a horrible documentation and design.
 On the long run it might be a good idea to write an new open source
 compiler supporting D using D. I've been starting such a project, but
 I'd like to talk about some design issues with somebody else. maybe
 sombody would even joing my project.
 What I'd like to do better than GCC:
 1. As language indepent tree structure as possible.
 2. Making it a real cross-compiler. If I want to use GCC as cross
 compiler, I've got to recompile GCC. Why do we have dynamic libraries?
 3. Making it easier to write and integrate a language frontend.
 4. Integrating a compile manager (like make) into the compiler driver to
 make source easily platform independent.

 How I would design such a thing:

 My compiler should be modular.

 Compiler driver: Managing compile process.
 Language frontend: Creating syntax tree.
 Optimizer: Doing non platform specific optimisations.
 Backend: System specific codegeneator doing system specific optimisation

 The syntax-tree can be split into two parts.
 The first one are deklarations (like classes) which indirectly result in
 code (eg. for construction etc.)
 and implementations (eg. functions)
 In my dreams the tree structure should be albe to represent the
 complete D syntax as it is a very advanced one. Being able to represent
   D's syntax C++, C, maybe Java are not a great problem.

 What do you think?

 At the end a great praise to Walter for his work.
Feb 03 2004
parent Stephan Wienczny <wienczny web.de> writes:
Walter wrote:
 The D front end code would be pretty easy to translate into D, as I tend to
 write C++ code using 'D style' anyway. Creating a new optimizer and back end
 is an enormous project, though. Wouldn't it be easier to clean up GCC?
I don't think that it is that easy to persuade the gcc developers to clean GCC as they are to busy implementing SSA. If you see how hard it is to integrate a new language frontend into GCC you will see that it has flaws. Flaws I'm trying to cover. I think its possible to "reuse" GCC code e.g. for the code generators. When translating to D they should be cleaned. P.s.: What do you think about SSA? Is it that big hit in optimization the GCC people are saying?
Feb 05 2004
prev sibling next sibling parent reply Marcel Meyer <meyerm fs.tum.de> writes:
Stephan Wienczny wrote:
 On the long run it might be a good idea to write an new open source
 compiler supporting D using D. I've been starting such a project,
oh man, everytime I think I have found a nice project which I could sell a professor as my "Diplomarbeit" someone else starts it a few days later... Is this annoying ;-) [hey, just to be sure - that was a joke *g*] Nonetheless, I would like the idea of a DCC - especially if all those conf and "make" thinks are somehow implemented. But do you think this is doable in a senseable time? I'm not yet very deep in compiler builds - so I'm quite naive. But everytime I think "what can be done" I just see sooo much work - just like making a really good GUI-toolkit (more like QT) for D - and then I just keep running away crying ;-). What's after a GUI-tk? A toolcollection - hmm, DING (DING is not GNU) ;-). And then a kernel? :-D However, count on me at least as a "break-my-machine-beta-tester". Marcel
Feb 06 2004
parent reply Stephan Wienczny <wienczny web.de> writes:
Marcel Meyer wrote:

 Stephan Wienczny wrote:
 
On the long run it might be a good idea to write an new open source
compiler supporting D using D. I've been starting such a project,
oh man, everytime I think I have found a nice project which I could sell a professor as my "Diplomarbeit" someone else starts it a few days later... Is this annoying ;-) [hey, just to be sure - that was a joke *g*]
*g*
 Nonetheless, I would like the idea of a DCC - especially if all those conf
 and "make" thinks are somehow implemented. But do you think this is doable
 in a senseable time? I'm not yet very deep in compiler builds - so I'm
 quite naive. But everytime I think "what can be done" I just see sooo much
 work - just like making a really good GUI-toolkit (more like QT) for D -
 and then I just keep running away crying ;-).
The first thing I thought when starting the project was: "There is a lot of work", but I think I overestimated it. The hardest thing is the backend. Do you know some ASM-Guru that could help? Maybe you want to join in if you have some time.
 
 What's after a GUI-tk? A toolcollection - hmm, DING (DING is not GNU) ;-).
 And then a kernel? :-D
Who told you my agenda? I'm planning a new OS that is as easy to use as windows and open source.
 However, count on me at least as a "break-my-machine-beta-tester".
 
[* Nett, das jemand dabei ist, mit dem man auch Deutsch sprechen kannn *]
 Marcel
Feb 06 2004
parent reply Marcel Meyer <meyerm fs.tum.de> writes:
Stephan Wienczny wrote:

 Marcel Meyer wrote:
 
 Stephan Wienczny wrote:
 
On the long run it might be a good idea to write an new open source
compiler supporting D using D. I've been starting such a project,
Nonetheless, I would like the idea of a DCC - especially if all those conf and "make" thinks are somehow implemented. But do you think this is doable in a senseable time? I'm not yet very deep in compiler builds - so I'm quite naive. But everytime I think "what can be done" I just see sooo much work - just like making a really good GUI-toolkit (more like QT) for D - and then I just keep running away crying ;-).
The first thing I thought when starting the project was: "There is a lot of work", but I think I overestimated it. The hardest thing is the backend. Do you know some ASM-Guru that could help?
Hmm, if you don't reinvent the wheel but search for a nice existing "backend"-language, you could reuse their ports. I heard the Universität Karlsruhe created some great stuff in during the last year.
 Maybe you want to join in if you have some time.
Time? Time? Ah, that stuff I had before going to university... ;-)
 [* Nett, das jemand dabei ist, mit dem man auch Deutsch sprechen kannn *]
och, ich bin mir sicher sollte das mit dem DCC wirklich was werden, werden noch viele deutschsprachige Studis hinzustossen.
Feb 06 2004
next sibling parent reply Stephan Wienczny <wienczny web.de> writes:
Marcel Meyer wrote:
 Hmm, if you don't reinvent the wheel but search for a nice existing
 "backend"-language, you could reuse their ports. I heard the Universität
 Karlsruhe created some great stuff in during the last year.
Do you still know how it was called? Have they published something? Stephan
Feb 07 2004
parent reply Marcel Meyer <meyerm fs.tum.de> writes:
Stephan Wienczny wrote:

 Marcel Meyer wrote:
 Hmm, if you don't reinvent the wheel but search for a nice existing
 "backend"-language, you could reuse their ports. I heard the Universität
 Karlsruhe created some great stuff in during the last year.
Do you still know how it was called? Have they published something?
Phew... I already searched for it. But I can't recall. Well, but that was just an example. There are others. How deep is your experience in building compilers? Did you already write some? Despite of some lectures in "formale Sprachen" and a (very) few projects in MI-assembler I don't have any clue what you really need for a compiler. I will start learning for my "Diplomhauptprüfung" the next semester - we'll see what happens ;-). But for now I really can't give you any tips - I guess you're far more qualilfied if you dare to start such a project :-D Is the principle of GCC, source-frontend-intermediate-_language-backend-asm, unique to it? I've never seen any other compiler working like that.
Feb 07 2004
parent Stephan Wienczny <wienczny web.de> writes:
Marcel Meyer wrote:
 Stephan Wienczny wrote:
 
 
Marcel Meyer wrote:

Hmm, if you don't reinvent the wheel but search for a nice existing
"backend"-language, you could reuse their ports. I heard the Universität
Karlsruhe created some great stuff in during the last year.
Do you still know how it was called? Have they published something?
Phew... I already searched for it. But I can't recall. Well, but that was just an example. There are others.
I something called Flex. Thats a project they are working on. There has not been any documentation how it works ;-( I want one of the best intermediate languages currently available. What do you think, is it possible generate a syntax tree that a backend can easily convert into asm? Do you really need to have a seperate backend language? I don't think Walter's compiler generates some intermediate language.
 
 How deep is your experience in building compilers? Did you already write
 some? Despite of some lectures in "formale Sprachen" and a (very) few
 projects in MI-assembler I don't have any clue what you really need for a
 compiler. I will start learning for my "Diplomhauptprüfung" the next
 semester - we'll see what happens ;-).
This will be my first one.... I'm quite good at designing software to be flexible and portable. The compiler will _not_ be designed to just compile D. It will be able to compile D, but that is not its only purpose. To be successful we will need C and C++. Maybe Java, Object Pascal. These are the languages I would design my abstract syntax tree for. My current planes for a syntax tree are: 1. As many basic types as possible, defined using templates. Everything being a class in the syntaxtree. Handled by the backend. 2. Different class allocation with and without GC. 3. SSA like expression design.
 But for now I really can't give you any tips - I guess you're far more
 qualilfied if you dare to start such a project :-D
I started the project not because I'm more qualified, I started it because I wanted to have such a compiler and nobody else is writing it for me ;) We'll see what happens.
 
 Is the principle of GCC, source-frontend-intermediate-_language-backend-asm,
 unique to it? I've never seen any other compiler working like that.
GCC uses source - syntax tree - RegisterTypeLanguage - symbol the next step will be source - syntax tree - saa representation - RTL - symbol I don't think this will be too fast. Stephan
Feb 07 2004
prev sibling next sibling parent Ilya Minkov <minkov cs.tum.edu> writes:
Marcel Meyer wrote:
 Hmm, if you don't reinvent the wheel but search for a nice existing
 "backend"-language, you could reuse their ports. I heard the Universit=E4=
t
 Karlsruhe created some great stuff in during the last year.
I have searched the net up and down on intermediate representations,=20 compiler back-ends, cross-platform low-level language compilers and so=20 on. So far, nothing is as portable as C as an intermediate, with GCC=20 being the second best. The great adbantage if GCC is that's a *real*=20 compiler backend with debug information and other services and not just=20 C. :) One interesting option is TenDRA (www.ten15.org) which uses its binary=20 intermediate representation. There are commercial and free back-ends,=20 but i think i heard somewhere the free x86 back-end was... weak! Looking = at c-- and others doesn't make me particularly optimistic either. I would definately not want to start a new back-end. It would be=20 imaginable to create a correct back-end, and maybe even some optimising=20 back-end, but it still would be no match to current senior ones. They=20 (GCC, DMC, OW) have optimisers with patterns developed in hard work=20 during a decade or more. There is an interesting read from the autor of=20 LCC-Win32 - which generates by orders of magnitude better code than=20 original LCC, but doesn't match the other compilers. And it was 10 years = of work...
[* Nett, das jemand dabei ist, mit dem man auch Deutsch sprechen kannn =
*]
=20
 och, ich bin mir sicher sollte das mit dem DCC wirklich was werden, wer=
den
 noch viele deutschsprachige Studis hinzustossen.
Wie ich zum Beispiel? -eye/midiclub
Feb 07 2004
prev sibling parent Friedrich Dominicus <frido q-software-solutions.com> writes:
Marcel Meyer wrote:
 Stephan Wienczny wrote:
 
 
Marcel Meyer wrote:


Stephan Wienczny wrote:


On the long run it might be a good idea to write an new open source
compiler supporting D using D. I've been starting such a project,
Nonetheless, I would like the idea of a DCC - especially if all those conf and "make" thinks are somehow implemented. But do you think this is doable in a senseable time? I'm not yet very deep in compiler builds - so I'm quite naive. But everytime I think "what can be done" I just see sooo much work - just like making a really good GUI-toolkit (more like QT) for D - and then I just keep running away crying ;-).
The first thing I thought when starting the project was: "There is a lot of work", but I think I overestimated it. The hardest thing is the backend. Do you know some ASM-Guru that could help?
How about HLA from Randall Hyde? I am sure Jacob Navia could be told to be an ASM-Guru too. And I assume he has enough experience with Compiler development. But I'm sure you look after unsolicited co-workers.... And I disagree that you think you overestimated, you underestimated... Regards Friedrich
Feb 09 2004
prev sibling parent reply "Ben Hinkle" <bhinkle4 juno.com> writes:
Googling for "GCC rewrite" turns up an interesting thread on the gcc mailing
list
http://gcc.gnu.org/ml/gcc/2001-02/msg01037.html

Basically everyone knows GCC is a mess but it is hard to write a replacement
from scratch. Would be nice to see, though.

If you want to be flexible enough to use the native cc compilers you could
try to port the DMD front-end source to spit out C code or something. I
think Ilya was looking into this approach.

-Ben
Feb 06 2004
parent Stephan Wienczny <wienczny web.de> writes:
Ben Hinkle wrote:
 Googling for "GCC rewrite" turns up an interesting thread on the gcc mailing
 list
 http://gcc.gnu.org/ml/gcc/2001-02/msg01037.html
 
 Basically everyone knows GCC is a mess but it is hard to write a replacement
 from scratch. Would be nice to see, though.
 
 If you want to be flexible enough to use the native cc compilers you could
 try to port the DMD front-end source to spit out C code or something. I
 think Ilya was looking into this approach.
 
 -Ben
 
 
They know it for years now. 2001... Have a look at what they say: http://gcc.gnu.org/ml/gcc/2001-02/msg01042.html GC, strongly typed... D? Stephan
Feb 06 2004