Sunday, April 24, 2016

Compiler Lab - Control and Data Flow Analysis Code and Theory PDF


Most of the variable and structure names are sensible ones. Except for a few, which are given below. And for size variable of an array, mostly I have used "size" as a suffix. And "no" means number. Just saying.
Name and meaning :
dno - definition number
bno - block number
defblockmap - mapping of definition number to their corresponding block numbers
definitionmap - mapping of variables to a number of defblockmap
globalno - total number of definitions in the program, also the size of the kill, gen, IN, OUT sets.
The theory for the exercise is also attached. I just understood it as a math problem and coded using the equations and logic. No idea about the exact theory. Alfre Aho book should help you in that.
Some confusions people face are about Kill, Gen, IN, OUT. These are sets. And the maximum number of elements they can contain is the total number of definitions in the program, which is globalno in my code. And since that is the maximum number, these sets are represented using bit vector representation. So, Kill is denoted by n bits, where n is the globalno value and each bit denotes a definition number of the program. And if a definition number is present in that set, then it's corresponding bit is set to 1 or else it is not present, it is set to 0. You should know this to do the Union and Subtract set operations properly on these bit vectors.

Code and Theory 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.