Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Code Generation is the last scenario of Compiler Design. Code Generation is the activity of generating assembly code/machine-readable code. Some significant properties of this activity are given as
Absolute quality code
Efficient Use of Resources
Quick Code
Example:
Let us take the three address statements a:= b+c.
It consists of the following sequence of codes.
MOV a, R0
ADD b, R0
The algorithm follows a queue of three address statements. The address statements are of form x: y op z simulates specific tasks.
The task description is given with the help of the following algorithm:
The initial step is to invoke a function getreg to capture the location L where the optimization of y op z is stored.
Manage the descriptive address of b to determine b'. If the value of b is present in memory and registers both, then the value of b' will be considered. If there is the absence of a value of b in L, then there is a need to generate the instruction MOV b', to copy a value of b in L.
A new instruction OP c' is to be generated. Updation of address descriptor of a takes place to depict that a is stored in L. If a is already present in L, then update the descriptor and remove a from all other descriptors.
After reaching the stage where b or c have no further uses, alter the register description. Now, the register will not store the values of b, and c.