Javatpoint Logo
Javatpoint Logo

Intermediate code

Intermediate code is used to translate the source code into the machine code. Intermediate code lies between the high-level language and the machine language.

Intermediate code

               Fig: Position of intermediate code generator

  • If the compiler directly translates source code into the machine code without generating intermediate code then a full native compiler is required for each new machine.
  • The intermediate code keeps the analysis portion same for all the compilers that's why it doesn't need a full compiler for every unique machine.
  • Intermediate code generator receives input from its predecessor phase and semantic analyzer phase. It takes input in the form of an annotated syntax tree.
  • Using the intermediate code, the second phase of the compiler synthesis phase is changed according to the target machine.

Intermediate representation

Intermediate code can be represented in two ways:

1. High Level intermediate code:

High level intermediate code can be represented as source code. To enhance performance of source code, we can easily apply code modification. But to optimize the target machine, it is less preferred.

2. Low Level intermediate code

Low level intermediate code is close to the target machine, which makes it suitable for register and memory allocation etc. it is used for machine-dependent optimizations.


Next TopicPostfix Notation




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA