Chapter 6 - ICG
Chapter 6 - ICG
Chapter 6 - ICG
Instructor: Mohammed O.
Email: [email protected]
Samara University
Chapter Six
This Chapter Covers:
Intermediate Code Generation
Three Address Code
Quadruples and Triples
Intermediate Code Generator: Intr
The front part of the compiler translates the source code programme into an
intermediate language representation, which after that is converted into a
machine code.
Phases of a compiler
Intermediate representations may be:
Assembly language like or
An abstract syntax tree
Types of Intermediate Representation
There are three types of intermediate representation:
a. Syntax Trees
b. Postfix notation
c. Three Address Code
Graphical Representations
A syntax tree depicts (shows) the natural hierarchical
structure of a source programme.
*
In the implementations of three-address code, a programmer-
defined name is replaced by a pointer to a symbol-table
entry for that name.
Implementations of three-Address
A three-address statement is an abstract form of
intermediate code.
In a compiler, these code (statements) can be implemented
as records with fields for the operator and the operands.
Three such representations are quadruples, triples, and
indirect triples.
Quadruples
A quadruple is a record structure with four fields, which
we call op, argl, arg2, and result.
The fields argl and arg2, for the arguments of op, are either
pointers to the symbol table or pointers into the triple structure
(for temporary values).