COMPILER LAB CS6612_ data flow analysis in c program
COMPILER LAB CS6612_ data flow analysis in c program
About Me
mohan raj
Follow 14
Compiler lab
Ex. No: 7 B data flow
Date: analysis in c
7B. Implement Data flow analysis program
etc.)
AIM: Implementation
of Simple Code
To write a C program to implement Data Flow Analysis. Optimization
Techniques
(Constant
Folding.
INTRODUCTION:
Blog Archive
Data flow analysis is a technique for gathering information about the possible set of
value calculated at various points in a computer program. ▼ 2018 (14)
▼ January (14)
ALGORITHM:
11. Implementation of Simple Code
Optimization Tec...
Step-1: Start the Program Execution.
10. Implement the back end of the
Step-2: Read the total Numbers of Expression compiler which t...
Step-3: Read the Left and Right side of Each Expressions
9. Construction of DAG
Step-4: Display the Expressions with Line No
Step-5: Display the Data flow movement with Particular Expressions 8. Implement any one storage allocation
strategie...
Step-6: Stop the Program Execution.
data flow analysis in c program
7A. Implement control flow analysis
PROGRAM
6. Implement type checking
http://bmohanrajcse.blogspot.in/search/label/data%20flow%20analysis%20in%20c%20program 1/3
3/21/2018 COMPILER LAB CS6612: data flow analysis in c program
for (i = 0; i < n; i++)
{
printf("\tleft\t");
scanf("%s",op[i].l);
printf("\tright:\t");
scanf("%s", op[i].r);
}
printf("intermediate Code\n");
for (i = 0; i < n; i++)
{ printf("Line No=%d\n",lineno);
printf("\t\t\t%s=", op[i].l);
printf("%s\n", op[i].r);lineno++;
}
printf("***Data Flow Analysis for the Above Code ***\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
match=strstr(op[j].r,op[i].l);
if(match)
{
printf("\n %s is live at %s \n ", op[i].l,op[j].r);
}
}
}}
OUTPUT:
Enter no of values
4
left a
right: a+b
left b
right: a+c
left c
right: a+b
left d
right: b+c+d
Line No=1
a=a+b
Line No=2
b=a+c
Line No=3
c=a+b
Line No=4
d=b+c+d
***Data Flow Analysis for the Above Code ***
a is live at a+b
a is live at a+c
a is live at a+b
b is live at a+b
b is live at a+b
b is live at b+c+d
c is live at a+c
c is live at b+c+d
d is live at b+c+d
RESULT:
Thus the above program is compiled and executed successfully and output is verified.
http://bmohanrajcse.blogspot.in/search/label/data%20flow%20analysis%20in%20c%20program 2/3
3/21/2018 COMPILER LAB CS6612: data flow analysis in c program
Home Older Posts
Ex. No: 11 Date: 11. Implementation of Simple Code Optimization Techniques (Constant
Folding.,etc.) ...
counter
http://bmohanrajcse.blogspot.in/search/label/data%20flow%20analysis%20in%20c%20program 3/3