(b) Color your graph using as few colors as you can. Call the computers registers R1, R2, etc. Describe the assignment of variables to registers implied by your coloring. How many registers do you need? (c) Suppose that a variable is assigned a value more than once, as in the code snippet below: t = r + S u = t * 3 t = m k v = t + u ... How might you cope with this complication?

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter4: Processor Technology And Architecture
Section: Chapter Questions
Problem 2PE: If a microprocessor has a cycle time of 0.5 nanoseconds, what’s the processor clock rate? If the...
icon
Related questions
Question
(b) Color your graph using as few colors as you can. Call the computers registers
R1, R2, etc. Describe the assignment of variables to registers implied by your
coloring. How many registers do you need?
(c) Suppose that a variable is assigned a value more than once, as in the code
snippet below:
t =
r + s
u = t * 3
t =
m
k
V = t + u
How might you cope with this complication?
Transcribed Image Text:(b) Color your graph using as few colors as you can. Call the computers registers R1, R2, etc. Describe the assignment of variables to registers implied by your coloring. How many registers do you need? (c) Suppose that a variable is assigned a value more than once, as in the code snippet below: t = r + s u = t * 3 t = m k V = t + u How might you cope with this complication?
4. A portion of a computer program consists of a sequence of calculations where the
results are stored in variables, like this (with inputs a, b and outputs d, g, h):
Step Calculation
1
C = a + b
d = a * C
e = c + 3
4
f = C
e
g = a + f
6 h = f + 1
A computer can perform such calculations most quickly if the value of each variable is
stored in a register, a chunk of very fast memory inside the microprocessor. Compilers
face the problem of assigning each variable in a program to a register. Computers
usually have few registers, however, so they must be used wisely and reused often.
This is called the register allocation problem.
In the example above, variables a and b must be assigned different registers, because
they hold distinct input values. Furthermore, c and d must be assigned different
registers; if they used the same one, then the value of c would be overwritten in the
second step and wed get the wrong answer in the third step. On the other hand,
variables b and d may use the same register; after the first step, we no longer need b
and can overwrite the register that holds its value. Also, f and h may use the same
register; once f+1 is evaluated in the last step, the register holding the value of f
can be overwritten.
(a) Recast the register allocation problem as a question about graph coloring. What
do the vertices correspond to? Under what conditions should there be an edge
between two vertices? Construct the graph corresponding to the example above.
Transcribed Image Text:4. A portion of a computer program consists of a sequence of calculations where the results are stored in variables, like this (with inputs a, b and outputs d, g, h): Step Calculation 1 C = a + b d = a * C e = c + 3 4 f = C e g = a + f 6 h = f + 1 A computer can perform such calculations most quickly if the value of each variable is stored in a register, a chunk of very fast memory inside the microprocessor. Compilers face the problem of assigning each variable in a program to a register. Computers usually have few registers, however, so they must be used wisely and reused often. This is called the register allocation problem. In the example above, variables a and b must be assigned different registers, because they hold distinct input values. Furthermore, c and d must be assigned different registers; if they used the same one, then the value of c would be overwritten in the second step and wed get the wrong answer in the third step. On the other hand, variables b and d may use the same register; after the first step, we no longer need b and can overwrite the register that holds its value. Also, f and h may use the same register; once f+1 is evaluated in the last step, the register holding the value of f can be overwritten. (a) Recast the register allocation problem as a question about graph coloring. What do the vertices correspond to? Under what conditions should there be an edge between two vertices? Construct the graph corresponding to the example above.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage