6.2. Compiler Phase and Pass Structure

The compiler, the assembler and the linker are three separate programs, but are normally run under the control of a small driver program, gcc. Given compile-time options, and a source file, gcc uses a target-dependent specification file to determine which passes are required. These are then run using UNIX pipes or temporary files to pass data between the separate programs. Many of the defaults can be overridden with compile-time options.

The default for the gcc command is to use the latest version of the native compiler. For the ERC32 Ada compiler a further driver program is supplied. This is called erc-coff-gcc and runs the compiler, assembler and linker targeted to the ERC32 Microprocessor rather than the native ones. Either driver can run an earlier version of the compiler, if installed.

The compiler has a language-dependent front end, which builds internal representation of the program being compiled, then calls the target-dependent code generator to generate assembly language. The ERC32 Ada compiler includes front end for ANSI C as well as Ada 95.

The Ada front-end comprises four phases, which communicate by means of a compact Abstract Syntax Tree (AST). The implementation details of the AST are hidden by several procedural interfaces that provide access to syntactic and semantic attributes. The layering of the system, and the various levels of abstraction, are the obvious benefits of writing in Ada, in what one might call "proper" Ada style.

The back end generates code for the ERC32 Microprocessor and includes phases to handle optimizations, register allocation and code generation. The code generator uses a pattern matching technique to ensure good use of the target computer's instruction set.