Intermediate Code Generation

  • This phase of the compiler generates the intermediate code.

  • As the name implies, the intermediate code is between high level and machine level language

  • The generated intermediate code is called three-address code and this includes a set of instructions resembling assembly language with 3 operands per instruction

  • Each of the operands acts like a register.

Properties of intermediate representation:

  • Easy to produce

  • Easy to translate to the target machine code

Summary of the functions of intermediate code generation:

  • Intermediate code is generated from semantic representation of the source code

  • Stores the computed values 

  • Maintain the order of precedence of the source language

  • Holds the correct number of operands for the instruction

  • Example- Intermediate code for a=b- c*50

t1 =  inttofloat(50)
t2 =  id3*t1
t3 =  id2 - t2
id1 =   t3