comp.lang.ada
 help / color / mirror / Atom feed
From: vsnyder@vanpcjpl.nasa.gov (Van Snyder)
Subject: Re: How does GNAT (or GCC) compile ADA code?
Date: 1998/10/22
Date: 1998-10-22T00:00:00+00:00	[thread overview]
Message-ID: <70lttj$mrp@netline.jpl.nasa.gov> (raw)
In-Reply-To: 707h7o$cvl$1@nnrp1.dejanews.com

In article <707h7o$cvl$1@nnrp1.dejanews.com>, dennison@telepath.com writes:
> In article <asmang-1510981424440001@192.168.0.22>,
>   asmang@mail.wm.edu (Arun Mangalam) wrote:
> > I don't really know how GCC is the backend for GNAT. Does gcc translate
> > Ada code into c and then compile c into machine language, or is it from
> > Ada code directly to machine language code? I'm just curious, and since I
> > don't have gcc installed, I was wondering if someone can either explain
> > this or direct me to a place where I can find this out for myself. Thank
> > you for any help.
> 
> Most compilers don't translate source directly into machine code. Instead they
> first translate the source code into a very low-level (yes, even lower-level
> than C :-) ) intermediate form that is somewhat machine-independent. Most
> optimizations then get performed on that intermediate code. In the final step
> the "backend" of the compiler translates the intermediate form into the
> appropriate machine code for the target cpu.
> 
> All forms of gcc, including gnat, gnu fortran, gnu pascal, etc. do this. One
> of the nice things about this approach is that it makes porting easier. Only
> the back-end code generator needs to be changed to port the compiler to a new
> architecture. It also makes it easier to create new compilers, as multiple
> compilers can use the same back-end.
> 
> So here's what gnat does. It converts (translates, compiles, whatever term
> you prefer) Ada source code into the special intermediate form that the gcc
> backend understands. Then it has the gcc backend do optimizations and machine
> code generation.

Does the gcc backend understand that C and C++ pointers can point _anywhere_,
while Ada and Fortran 90 pointers are quite disciplined?  The important
consequence of this observation is that optimization becomes possible.  The
inability to optimize pointers is the primary reason that C and C++ programs
are generally slower than equivalent Fortran 90 programs.  To my knowledge,
there are no Fortran 90 compilers that use the gcc backend.

-- 
What fraction of Americans believe   |  Van Snyder
Wrestling is real and NASA is fake?  |  vsnyder@math.jpl.nasa.gov




  parent reply	other threads:[~1998-10-22  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-15  0:00 How does GNAT (or GCC) compile ADA code? Arun Mangalam
1998-10-16  0:00 ` dennison
1998-10-16  0:00   ` dewarr
1998-10-22  0:00   ` Van Snyder [this message]
1998-10-22  0:00     ` dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox