]>
Commit | Line | Data |
---|---|---|
7adcbafe | 1 | @c Copyright (C) 2002-2022 Free Software Foundation, Inc. |
0a553c7e JM |
2 | @c This is part of the GCC manual. |
3 | @c For copying conditions, see the file gcc.texi. | |
4 | ||
5 | @node Languages | |
6 | @chapter Language Front Ends in GCC | |
7 | ||
8 | The interface to front ends for languages in GCC, and in particular | |
929769f4 | 9 | the @code{tree} structure (@pxref{GENERIC}), was initially designed for |
0a553c7e JM |
10 | C, and many aspects of it are still somewhat biased towards C and |
11 | C-like languages. It is, however, reasonably well suited to other | |
12 | procedural languages, and front ends for many such languages have been | |
13 | written for GCC@. | |
14 | ||
15 | Writing a compiler as a front end for GCC, rather than compiling | |
16 | directly to assembler or generating C code which is then compiled by | |
17 | GCC, has several advantages: | |
18 | ||
19 | @itemize @bullet | |
20 | @item GCC front ends benefit from the support for many different | |
21 | target machines already present in GCC@. | |
22 | @item GCC front ends benefit from all the optimizations in GCC@. Some | |
23 | of these, such as alias analysis, may work better when GCC is | |
e93676fb | 24 | compiling directly from source code than when it is compiling from |
0a553c7e JM |
25 | generated C code. |
26 | @item Better debugging information is generated when compiling | |
27 | directly from source code than when going via intermediate generated C | |
28 | code. | |
29 | @end itemize | |
30 | ||
31 | Because of the advantages of writing a compiler as a GCC front end, | |
32 | GCC front ends have also been created for languages very different | |
33 | from those for which GCC was designed, such as the declarative | |
34 | logic/functional language Mercury. For these reasons, it may also be | |
35 | useful to implement compilers created for specialized purposes (for | |
36 | example, as part of a research project) as GCC front ends. |