1*ec02198aSmrg@c Copyright (C) 2002-2020 Free Software Foundation, Inc.
210d565efSmrg@c This is part of the GCC manual.
310d565efSmrg@c For copying conditions, see the file gcc.texi.
410d565efSmrg
510d565efSmrg@node Languages
610d565efSmrg@chapter Language Front Ends in GCC
710d565efSmrg
810d565efSmrgThe interface to front ends for languages in GCC, and in particular
910d565efSmrgthe @code{tree} structure (@pxref{GENERIC}), was initially designed for
1010d565efSmrgC, and many aspects of it are still somewhat biased towards C and
1110d565efSmrgC-like languages.  It is, however, reasonably well suited to other
1210d565efSmrgprocedural languages, and front ends for many such languages have been
1310d565efSmrgwritten for GCC@.
1410d565efSmrg
1510d565efSmrgWriting a compiler as a front end for GCC, rather than compiling
1610d565efSmrgdirectly to assembler or generating C code which is then compiled by
1710d565efSmrgGCC, has several advantages:
1810d565efSmrg
1910d565efSmrg@itemize @bullet
2010d565efSmrg@item GCC front ends benefit from the support for many different
2110d565efSmrgtarget machines already present in GCC@.
2210d565efSmrg@item GCC front ends benefit from all the optimizations in GCC@.  Some
2310d565efSmrgof these, such as alias analysis, may work better when GCC is
2410d565efSmrgcompiling directly from source code then when it is compiling from
2510d565efSmrggenerated C code.
2610d565efSmrg@item Better debugging information is generated when compiling
2710d565efSmrgdirectly from source code than when going via intermediate generated C
2810d565efSmrgcode.
2910d565efSmrg@end itemize
3010d565efSmrg
3110d565efSmrgBecause of the advantages of writing a compiler as a GCC front end,
3210d565efSmrgGCC front ends have also been created for languages very different
3310d565efSmrgfrom those for which GCC was designed, such as the declarative
3410d565efSmrglogic/functional language Mercury.  For these reasons, it may also be
3510d565efSmrguseful to implement compilers created for specialized purposes (for
3610d565efSmrgexample, as part of a research project) as GCC front ends.
37