Coupon Accepted Successfully!


Intermediate Code Generation

The front end analyses the source program and creates an intermediate code representation. The back end makes use of this code and generates target code. This enables to attach a back end for the new machine to an existing front end. This is a typical scenario in analysis-synthesis model.

Logical representation of a compiler front end

The compiler front end is organized as shown in the diagram which includes static checking, parsing and intermediate code generation. These are done sequentially.


Syntax Trees

Syntax trees are suited for static type of checking and they are high level of IR. They are natural hierarchical structure of the source program.

DAG (Directed Acyclic graph)
- It’s variant of syntax tree.

A DAG identifies the common sub expression of the given expression. A DAG has leaves corresponding to atomic operands and interior nodes corresponding to operators. DAG gives clues to compiler to generate efficient code to evaluate the expression.

Three address Code (TAC)

TAC is a statement containing at most 3 addresses or operands.

The general form is x:= y op z where op stands for operator. X is the result, y and z are the operands which may be variables, constants or temporaries. TAC is the linear representation of a binary syntax tree.

Three address code representation

The representation includes

– Quadruples: In this representation, for a given instruction includes op, arg1,arg2 and result.

 a = b * – c + b * – c




– Triples: This representation has only three fields for each instruction op,arg1 and arg2. The result of operation x= y op z will be represented by its position

– Indirect triples: This consists of pointers to triples rather than the set of triples.

– Static single-assignment form: SSA form is an intermediate representation that facilitates certain code optimizations.

Test Your Skills Now!
Take a Quiz now
Reviewer Name