In general, the compilers that belong to the GNU compiler collection all follow the same architecture which is:
- a language specific front end The front end is responsible for the lexing, parsing, handling the symbol table etc. It may do some language specific optimisations (like inlining for example) and it will finally generate an intermediate representation in RTL (Register Transfer Language). RTL represents an idialized processor with an unlimited number of registers. A number of frontends first represent the program in tree form before actually generating the RTL code.
- a middle part The middle part of the compiler is common to all langauges and all processors. It does a number of optimizations on the RTL representation of the program and it will run the register allocator which tries to map the idialized registers representation to the regial registers or stack slots.
- a processor specific back end the backend transforts the RTL representation to the actual processor specific code and does a number of processor specific peephole optimizations.
While these are functionally 3 different parts, they are actually linked together into one executable. There are no specific programs for each part of the compilation.
Given the program goes through so many steps, you have no simple one to one mapping between initial language contructs and the code generated. Especially optimizations like inlining or certain aggressive optimizations in the middle end can make the produce code have little ressemblence with the original source code.
Marcel
----- Original Message ----- From: a2782@dis.ulpgc.es To: "Maurice Lombardi" Maurice.Lombardi@ujf-grenoble.fr Cc: gpc@gnu.de Sent: Wednesday, December 11, 2002 5:45 PM Subject: Re: Translation Scheme
Well, it's an option. I could write some simple programs in Pascal and see what assembly code is being generated.
But I think it should be a formal document with this step. I mean, when somebody implements a compiler, he/she must follow several steps: lex, parsing, generation of symbol table and object code generation. Well, I search for a scheme with the correspondencies between the structures being parsed and the code generated.
E.g.:
program: program id other body; --> initialize memory
body: begin instructions end ';' --> generate instructions 'enter', 'leave'
...
I'm not interested in sources of GPC, because GPC is designed as a front-end, and I search for the back-end...
Thanks for the patience!