Next: The analysis phases
Up: Compilers
Previous: Definition
- The ANALYSIS part (Figure 2)
- breaks up the source program into
constituent pieces (words, phrases)
- and creates an
intermediate representation of the source program.
Informally, the compiler must understand the structure
and meaning of the source program.
Figure 2:
From a source line to an intermediate representation via
an expression tree.
In this example it is assumed that the variables x and y
are known to be of type real which explains
the conversion of 10 from int to real.
|
- The INTERMEDIATE REPRESENTATION (IR) is an abstract machine
language
- that can express the target-machine operations,
- without committing too much machine-specific detail.
- The IR should be easy
- to produce (from the source program) and
- to translate (to the target language).
- In our example (Figure 2)
the IR is a THREE-ADDRESS CODE:
- each instruction has at most 3 operands,
- each instruction has at most 1 operator in addition to the assignment.
Figure 3:
The interest of an intermediate representation.
|
On the right picture of Figure 3
the arrows going from programming languages to IR are called
COMPILER FRONT ENDS and those going from IR
to computer architectures are called COMPILER BACK ENDS.
- The SYNTHESIS part (Figure 4)
- performs code optimization,
- and constructs the desired target
program from the intermediate representation.
Figure 4:
From an intermediate representation to a sequence of target instructions.
|
Subsections
Next: The analysis phases
Up: Compilers
Previous: Definition
Marc Moreno Maza
2004-12-02