CS 1622 – Homework 3
Due: Tuesday, April 14, 2015 at the start of class

Please submit a typewritten document. I’d prefer you draw your graphs on the computer, but if this is a challenge, you may hand draw them neatly on the paper by hand.

 

1.) Identify the basic blocks in the following sequence of IR code and construct the Control Flow Graph:

x := 0

c 0

L1:  x := x * 2

     a := x % 5

b a == 0

     iftrue b goto L2

     c := x + 1

     goto L3

L2:  c := x + x

L3:  b := x < 10

     iftrue b goto L1

     return c

 

2.) Perform liveness analysis on the variables in the above code statement by statement. Show each iteration of the algorithm in terms of live-in and live-out.

 

3.) Construct the interference graph and perform register allocation using K=3 registers. Show the order that simplify removes the nodes from the graph and then the resulting colors as it is rebuilt.