Compilers - Principles Techniques and Tools by Alfred Aho - Monica Lam- Ravi Sethi- Jeffrey Ullman - Second Edition
1.2.4 Intermediate Code Generation
In the process of translating a source program into target code, a compiler may
construct one or more intermediate representations, which can have a variety
of forms. Syntax trees are a form of intermediate representation; they are
commonly used during syntax and semantic analysis.
After syntax and semantic analysis of the source program, many compil-
ers generate an explicit low-level or machine-like intermediate representation,
which we can think of as a program for an abstract machine. This intermedi-
ate representation should have two important properties: it should be easy to
produce and it should be easy to translate into the target machine.
In Chapter 6, we consider an intermediate form called three-address code,
which consists of a sequence of assembly-like instructions with three operands
per instruction. Each operand can act like a register. The output of the inter-
mediate code generator in Fig. 1.7 consists of the three-address code sequence
tl = inttofloat (60)
t2 = id3 * tl
t3 = id2 + t2
id1 = t3
There are several points worth noting about three-address instructions.
First, each three-address assignment instruction has at most one operator on the
No comments:
Post a Comment