Starting from:
$26.99

$20.99

TDT4205 Problem Set 6 Solution

1    Theory

 

1.1     12%

 

Create  control  flow graphs  for the following program  fragments:

 

1.  for ( a ; b ; c ) d ; e ;

 

2.  a ; while ( b ) {  d ; c ; }  e ;

 

3.  a ; do {  d ; c ; }  while ( b ); e ;

 

1.2     18%

 

Consider  the following program  fragment:

 

1.  a=1

 

2.  b=2

 

3.  c=3

 

4.  d=a+x

 

5.  e=b+c

 

6.  f=e

 

7.  g=f

 

8.  g=d+y

 

9.  a=b+c

 

Identify  the lines impacted  by the optimizations

 

1.  Copy propagation

 

2.  Common  subexpression  elimination

 

3.  Constant propagation

 

and rewrite them appropriately (start with the original program  for each case).

 

2    Programming (70%)

 

Complete the VSL compiler (from your own code, or starting from ps6 skeleton.tgz), by implementing the following constructs in generator.c:

 

1.  Local variables  (20%)

 

2.  Function calls (20%)

 

3.  Conditionals (IF  and relations) (15%)

 

4.  While loops (10%)

 

5.  Continue (null  statement) (5%)

More products