public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* A FrontEnd in C++?
@ 2002-08-17 15:45 khalid aggag
  2002-08-17 18:06 ` Michael S. Zick
                   ` (2 more replies)
  0 siblings, 3 replies; 59+ messages in thread
From: khalid aggag @ 2002-08-17 15:45 UTC (permalink / raw)
  To: gcc

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 510 bytes --]

I am currently developing a new Frontend for an educational language for 
GCC. I have the language's lexical analysis and parsing modules in C++. Is 
it possible to develop a frontend for gcc written completely in C++? How 
would I make up for the different function naming and calling conventions 
between C and C++? Thanx alot in advance.


Khalid Aggag


_________________________________________________________________
Join the worldÂ’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-18 14:36 khalid aggag
  2002-08-18 15:37 ` Michael S. Zick
  2002-08-18 22:48 ` Per Bothner
  0 siblings, 2 replies; 59+ messages in thread
From: khalid aggag @ 2002-08-18 14:36 UTC (permalink / raw)
  To: gcc

Writing a front end in C++ would make that process:

Stage0: any 'ol C compiler -> gcc<c, c++>
Stage1: gcc<c, c++> + new_frontend -> gcc<c, c++, New>
Stage2: gcc<c, c++, New> -> presumably_finished_compiler
Stage3: presumably_finished_compiler -> finished_compiler

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-19 16:18 Robert Dewar
  0 siblings, 0 replies; 59+ messages in thread
From: Robert Dewar @ 2002-08-19 16:18 UTC (permalink / raw)
  To: dnovillo, zack; +Cc: fjh, gcc, khalidaggag

<<> Based on the number of problems we have encountered with the Ada front
> end compared to the others, I think that as a matter of project policy
> writing front ends in any language other than C should be discouraged.
>>

I really don't see any major problems with Ada being written in Ada, we have
never had trouble building, and lots of people have built GNAT V5 from the
gcc sources successfully.

>>C is such a barbaric language for writing compilers

I have to agree with this. You really really need a language that supports
abstraction well for writing compilers.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-21 11:41 Robert Dewar
  2002-08-21 12:59 ` Geoff Keating
  0 siblings, 1 reply; 59+ messages in thread
From: Robert Dewar @ 2002-08-21 11:41 UTC (permalink / raw)
  To: gcc, zack

What zw discounts in his argument is the huge gain in writing a compiler in
a high level language with good abstraction facilities. There are also
other huge advantages of writing a compiler in its own language:

Avoiding a culture clash. For example, COBOL compilers should be written by
people who really know COBOL well. Such people are not likely to be happy
writing in C. I know of more than one COBOL compiler written in C by
C programmers who really disliked COBOL, and it shows!

Having one really complex test program that must function really well before
you can even get out of the starting gate is a real advantage.

You have more incentive to improve the compiler, since improvements help compile
speed as well as generally assisting users.

A compiler is one component in development systems now, and the quality of
integrated tool sets is critical. If you write a compiler in its own language
then your development team uses the tools that surround the compiler that support
this language, and they have an incentive to develop and improve these tools.

If you run into troubles with the compiler compiling your compiler, you do not
have to rely on external support to solve them. You are the maintainer from whom
you need your own help. Since you know the urgency of your own needs, you will
get excellent support.

As for problems with mixed languages, we have found that to be very little
trouble in practice on a wide range of machines, and many people have succeeded
in building modified compilers (it is in fact an assignment I have given to
many students: "make some interesting modification to GNAT" :-)

A lot of the growing pains in integrating Ada into the FSF structure come from
the fact that this is the first time it is done, so we have had to learn how
it should be done, and from people having the unrealistic expectation that 
you should be able to build from any old ancient version of GNAT used together
with some unrelated version of C.

I think once we have gone through a couple of release cycles with GNAT there,
the problems will mostly take care of themselves.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-21 11:53 Robert Dewar
  2002-08-21 12:03 ` Graham Stott
  2002-08-21 16:16 ` Zack Weinberg
  0 siblings, 2 replies; 59+ messages in thread
From: Robert Dewar @ 2002-08-21 11:53 UTC (permalink / raw)
  To: phil, zack; +Cc: gcc

> Now I don't feel so bad about giving up on getting Ada to work on my box.

In fact lots of people have succeeded. The critical factor is to get a reasonably
late distribution of GNAT, and use the Ada compiler you get to build the Ada part
and the C compiler that comes with it to build the C part, and it will work fine.
That's not just theory, that's what is reported back to us from lots of Ada folks.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-21 11:54 Robert Dewar
  0 siblings, 0 replies; 59+ messages in thread
From: Robert Dewar @ 2002-08-21 11:54 UTC (permalink / raw)
  To: matz, zack; +Cc: gcc

> No.  The intrinsic complexity burden I am talking about is exclusively
> a function of the number of different languages used in the source
> tree (ignoring runtime libraries).  It doesn't matter which bits are
> written in which languages.

Mixed languages are reality in large applications these days. We deal with people
writing large (much much larger than gcc) applications in mixed languages
typically Ada C C++ and one of the great strengths of gcc is that it handles
this situation very smoothly. 

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-21 16:19 Richard Kenner
  2002-08-22 14:17 ` Zack Weinberg
  0 siblings, 1 reply; 59+ messages in thread
From: Richard Kenner @ 2002-08-21 16:19 UTC (permalink / raw)
  To: zack; +Cc: gcc

    For the second time: GNATS PRs 6016, 6160, 6552, 6573, 6584, 6661,
    6669, 6696, 6767, 6816, 6851, 6852, 6853, 6872, 6879, 6931, 6942,
    7209, and 7337.

    Now I did just succeed in building the GCC 3.3 source tree with Ada
    enabled (incl make gnatlib_and_tools), using C and Ada compilers from
    GCC 3.2.  It is possible that some or all of these PRs have been
    fixed.

All of these were due to using a non-working version of GNAT as the bootstrap
source, as far as I know.  Nobody who has started from a working version
has had a problem.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: A FrontEnd in C++?
@ 2002-08-21 16:26 Billinghurst, David (CRTS)
  0 siblings, 0 replies; 59+ messages in thread
From: Billinghurst, David (CRTS) @ 2002-08-21 16:26 UTC (permalink / raw)
  To: Richard Kenner, zack; +Cc: gcc

This is not the case for PR 6942.

I built a working Ada compiler with 3.2, but the bootstrap now fails 
with 3.3.  I even identified the patch that broke it.

-----Original Message-----
From: Richard Kenner [ mailto:kenner@vlsi1.ultra.nyu.edu ]
Sent: Thursday, 22 August 2002 9:19 
To: zack@codesourcery.com
Cc: gcc@gcc.gnu.org
Subject: Re: A FrontEnd in C++?


    For the second time: GNATS PRs 6016, 6160, 6552, 6573, 6584, 6661,
    6669, 6696, 6767, 6816, 6851, 6852, 6853, 6872, 6879, 6931, 6942,
    7209, and 7337.

    Now I did just succeed in building the GCC 3.3 source tree with Ada
    enabled (incl make gnatlib_and_tools), using C and Ada compilers from
    GCC 3.2.  It is possible that some or all of these PRs have been
    fixed.

All of these were due to using a non-working version of GNAT as the bootstrap
source, as far as I know.  Nobody who has started from a working version
has had a problem.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-21 17:19 Robert Dewar
  0 siblings, 0 replies; 59+ messages in thread
From: Robert Dewar @ 2002-08-21 17:19 UTC (permalink / raw)
  To: dewar, zack; +Cc: gcc, phil

<<Now I did just succeed in building the GCC 3.3 source tree with Ada
enabled (incl make gnatlib_and_tools), using C and Ada compilers from
GCC 3.2.  It is possible that some or all of these PRs have been
fixed.  However, the impression one gets flipping through GNATS is
that they have all been ignored.
>>

Indeed I do not know of anyone who is looking at this particular set of
GNATS PRs. For us getting GNAT to work reliably with GCC 3 is far higher
priority, and we get mostly very positive input from people regarding the
build process, so that has not seemed a critical priority.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-21 17:19 Robert Dewar
  0 siblings, 0 replies; 59+ messages in thread
From: Robert Dewar @ 2002-08-21 17:19 UTC (permalink / raw)
  To: kenner, zack; +Cc: gcc

<<All of these were due to using a non-working version of GNAT as the bootstrap
source, as far as I know.  Nobody who has started from a working version
has had a problem.
>>

That's my impression also.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: A FrontEnd in C++?
@ 2002-08-21 18:00 Richard Kenner
  0 siblings, 0 replies; 59+ messages in thread
From: Richard Kenner @ 2002-08-21 18:00 UTC (permalink / raw)
  To: David.Billinghurst; +Cc: gcc

    This is not the case for PR 6942.

That PR clearly shouldn't have been in the list, since it has nothing
whatsoever to do with what language the compiler was written in.  It
is not a bug in Ada, but in language-independent CFG processing.  I
suspect the reason nobody has worked on it is that it's mis-characterized:
it has nothing to do with Ada except that that's what the test program
happens to be written in.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-22  1:54 Robert Dewar
  0 siblings, 0 replies; 59+ messages in thread
From: Robert Dewar @ 2002-08-22  1:54 UTC (permalink / raw)
  To: fjh, zack; +Cc: gcc

> historically, very little effort has been put into
> maintaining that compatibility (beyond what is needed to interface the
> language runtime to the system), so it is not a thing to be relied on.

While this statement is absolutely true about C, which has never had any
facilities for interfacing with other languages, it takes only one to tango
here, and other languages *do* concern themselves with multi-language
programming. For example in Ada a required feature is

   pragma Import (C, name-of-function-in-Ada, name-of-function-in-C);

and the compiler is *required* to make sure that the calling sequence is
C-compatible.

Actually in the case of GNAT, we don't even need to use pragma Import, since
the default calling convention is precisely compatible with C anyway.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-22 13:50 Chris Lattner
  0 siblings, 0 replies; 59+ messages in thread
From: Chris Lattner @ 2002-08-22 13:50 UTC (permalink / raw)
  To: gcc

> Go right ahead.  All you need is a new branch and some free time.  I
> would personally suggest following some of the design and implementation
> ideas from SUIF and/or Sage++.  They are kind of neat.

As long as we are plugging compiler infrastructures, I thought I might
mention my own project LLVM: http://llvm.cs.uiuc.edu/

It's also completely written in C++ (G++ 3.2), uses a GCC->LLVM frontend,
is SSA based, open-source, and has some interesting technology available
in it.  The LLVM instruction set is roughly equivalent to SIMPLE
( http://llvm.cs.uiuc.edu/docs/LangRef.html ).

A few of the nify things LLVM provides are the modular pass system:
http://llvm.cs.uiuc.edu/docs/WritingAnLLVMPass.html
strong infrastructure for interprocedural optimizations, linktime, and
runtime optimizations, etc.  The infrastructure is _very_ fast.

Additionally, because it uses C++ and the STL throughout, writing
transformations is quite simple.  For example, LICM and GCSE are each
just a couple hundred lines of code (which are mostly comments):

http://llvm/doxygen/LICM_8cpp-source.html
http://llvm/doxygen/GCSE_8cpp-source.html

If you have any questions about LLVM or would like to discuss compiler
architecture, I'd be more than happy to participate.

-Chris

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-22 14:53 Robert Dewar
  2002-08-22 20:37 ` Geoff Keating
  2002-08-22 21:36 ` Hans-Peter Nilsson
  0 siblings, 2 replies; 59+ messages in thread
From: Robert Dewar @ 2002-08-22 14:53 UTC (permalink / raw)
  To: gdr, zack; +Cc: gcc

> Under this constraint, I hope you'll agree with me that the thing to
> do is pick just one language, and write your compiler using the most
> minimal subset of that language that is practical, also avoiding as
> much of the runtime library as is practical.  Under this constraint,
> it is a desirable state of affairs that your step (2) above only
> exercises a small subset of the compiler you've written.  (Exercising
> the rest of the compiler is the function of the test suite.)


But the more common situation is that you can bootstrap the compiler using
some other compiler to do the first step. For example, GNAT was originally
bootstrapped using the Alsys compiler on the Sun, and Realia COBOL was
originally bootstrapped using IBM F Compiler on a 370/148.

In the case where you are doing a completely new language, there are other
approaches. For example, this last semester in my graduate compiler class
I had people write a compiler for an Algol-68 subset in Algol-68 generating
assembler code for MMIX, and to fully complete the assignment, students
had to do a full bootstrap with identity check.

About half the class successfully completed the entire bootstrap. Of this
group (about 15 people), half had used C-Front, a translator that translates
into C to get the initial bootstrap compiler, and half first wrote in hevaily
macroized C which could then be easily converted to Algol-68 by a mixture
of manual and automatic processing. Both approaches seem to be quite workable.

As another example, Alsys wrote their first Ada compiler in Ada, and used a very
crude and inefficient translator into PL/1 to get the bootstrap done.

> Now.  Based on historical evidence, I argue that that's not a thought
> experiment at all.  It is instead a slight exaggeration of the
> situation we are in, developing GCC.  We have a five-year track record
> of having to work around bugs in the C runtime and the bootstrap
> compiler.  I see no reason to expect this situation ever to change.
> Restricting ourselves to a safe subset of C and C only is a sensible
> way to insulate ourselves from these problems as best we can.

Actually it seems to me that the situation with the GCC C compiler is much
harder than usual as a result of the self inflicted additional hard requirement
that it be compilable on all C compilers. I must say that in the case of GNAT
we have had very little trouble in maintaining the bootstrap, and the same
was true in Realia COBOL.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-23  3:08 Robert Dewar
  0 siblings, 0 replies; 59+ messages in thread
From: Robert Dewar @ 2002-08-23  3:08 UTC (permalink / raw)
  To: dewar, hp; +Cc: gcc

>>With no bugs exposed in the GCC MMIX port?  Strange.  1/2 :-)

Sorry, you misread what I said, this assignment had nothing whatsoever
to do with the GCC MMIX port. The students wrote complete compilers that
parsed Algol-68 source, semantically analyzed the resulting trees, and 
then generated optimized (more or less, some optimized more than others :-)
assembly language for MMIX.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: A FrontEnd in C++?
@ 2002-08-24  6:54 Robert Dewar
  0 siblings, 0 replies; 59+ messages in thread
From: Robert Dewar @ 2002-08-24  6:54 UTC (permalink / raw)
  To: dewar, geoffk; +Cc: gcc

>>You do admit, though, that ACT is not the typical case for GNAT?

Well there are lots of people who have not only completed the build
and cross port (the easy part), but have also ported the entire toolset
and run time library (I am talking about people outside ACT here).

Several GNAT ports were done entirely outside ACT's sphere.

^ permalink raw reply	[flat|nested] 59+ messages in thread

end of thread, other threads:[~2002-08-24  6:54 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-17 15:45 A FrontEnd in C++? khalid aggag
2002-08-17 18:06 ` Michael S. Zick
2002-08-19  0:46 ` Fergus Henderson
2002-08-19  1:02   ` Zack Weinberg
2002-08-19  2:18     ` Gabriel Dos Reis
2002-08-19  2:42       ` Michael S. Zick
2002-08-21 10:40       ` Zack Weinberg
2002-08-21 10:59         ` Michael Matz
2002-08-21 11:18           ` Zack Weinberg
2002-08-21 11:25             ` Daniel Berlin
2002-08-21 11:35               ` Michael Matz
2002-08-21 11:50                 ` Daniel Berlin
2002-08-22 13:03                   ` Pop Sébastian
2002-08-22 13:11                     ` Diego Novillo
2002-08-22 13:19                       ` Pop Sébastian
2002-08-22 20:19                     ` Daniel Berlin
2002-08-22 12:47                 ` Gabriel Dos Reis
2002-08-21 11:10         ` Phil Edwards
2002-08-21 11:43         ` Ross Smith
2002-08-21 12:24           ` Zack Weinberg
2002-08-22 12:47             ` Gabriel Dos Reis
2002-08-21 21:51         ` Fergus Henderson
2002-08-22 12:47         ` Gabriel Dos Reis
2002-08-22 14:16           ` Zack Weinberg
2002-08-22 15:41             ` Gabriel Dos Reis
2002-08-23  2:20             ` Fergus Henderson
2002-08-23 13:19               ` Toon Moene
2002-08-24  2:25               ` Kai Henningsen
2002-08-19  6:55     ` Alexandre Oliva
2002-08-19  8:50       ` Michael S. Zick
2002-08-19  7:20     ` Diego Novillo
2002-08-19 12:20     ` Mike Stump
2002-08-20  2:19     ` Florian Weimer
2002-08-19 10:51   ` Matt Austern
2002-08-20 11:18 ` Kelley Cook
2002-08-20 11:38   ` Kevin Handy
2002-08-18 14:36 khalid aggag
2002-08-18 15:37 ` Michael S. Zick
2002-08-18 22:48 ` Per Bothner
2002-08-19 16:18 Robert Dewar
2002-08-21 11:41 Robert Dewar
2002-08-21 12:59 ` Geoff Keating
2002-08-21 11:53 Robert Dewar
2002-08-21 12:03 ` Graham Stott
2002-08-21 16:16 ` Zack Weinberg
2002-08-21 11:54 Robert Dewar
2002-08-21 16:19 Richard Kenner
2002-08-22 14:17 ` Zack Weinberg
2002-08-21 16:26 Billinghurst, David (CRTS)
2002-08-21 17:19 Robert Dewar
2002-08-21 17:19 Robert Dewar
2002-08-21 18:00 Richard Kenner
2002-08-22  1:54 Robert Dewar
2002-08-22 13:50 Chris Lattner
2002-08-22 14:53 Robert Dewar
2002-08-22 20:37 ` Geoff Keating
2002-08-22 21:36 ` Hans-Peter Nilsson
2002-08-23  3:08 Robert Dewar
2002-08-24  6:54 Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).