CODE GENERATOR

Intermediate Code Generator:

 

•It uses the structure produced by the semantic analyzer to create a stream of simple instructions called “Three Address Code” .

 

•It consists of a sequence of instructions with at most 3 operands

 

Properties of Three - Address Code :

 

1.Each 3-address instruction has at most one operator in addition to the assignment.

 

2.The compiler must generate a temporary name to hold the value computed by each instruction.

 

3.Some instructions have fewer than 3 operands.

 

Example for Intermediate Code Generator

Intermediate Code

 

 

Code Optimization :

•It attempts to improve intermediate code, so that the machine code will be executed fastly.

 

 

Example for Code Optimization :

Code Optimization

 

Next

 

 

 

Structure of a Compiler by M.Sharmila and R.Jayabharathi- Dept of IT