0% found this document useful (0 votes)
25 views2 pages

Define X: (Left) X Use X: (Right) - X + 1 //output X

The document discusses variable liveness analysis and register allocation techniques. It defines variable liveness as a variable being live at a point in a program if it may be used at a later point before being redefined. It describes constructing a register interference graph based on the live ranges of variables and using graph coloring to assign variables to registers, with the goal of minimizing those assigned to memory. It outlines an algorithm that attempts to color this graph by repeatedly removing the highest degree node until the graph is empty or the algorithm gets stuck. Finally, it discusses performing both global and local liveness analysis to determine variable liveness throughout a program.

Uploaded by

Jeffboird
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Define X: (Left) X Use X: (Right) - X + 1 //output X

The document discusses variable liveness analysis and register allocation techniques. It defines variable liveness as a variable being live at a point in a program if it may be used at a later point before being redefined. It describes constructing a register interference graph based on the live ranges of variables and using graph coloring to assign variables to registers, with the goal of minimizing those assigned to memory. It outlines an algorithm that attempts to color this graph by repeatedly removing the highest degree node until the graph is empty or the algorithm gets stuck. Finally, it discusses performing both global and local liveness analysis to determine variable liveness throughout a program.

Uploaded by

Jeffboird
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Variable Liveness: a variable is live at a point in a program if it may be used at a later point before being

redefined.

Liveness:

Define x : (left) x = //input x

Use x: (right) _ = x + 1 //output x

Live Ranges of x - (has to be used, if next instruction does not use x, then that instruction at current
point is dead.

Register interference graph - Two live rangers interfere if they overlap (same section of code)

-Graph Coloring

K coloring – when you color graph, you cant assign same color(registers) to nodes that
have same edge (empty complete-may not cover anything)

Pay bigger prices nodes in memory than those not(in registers)

Easy ones last, hardest ones FIRST(n-coloring)

Hardest = degrees >= number of colors


Easiest = degrees <= number of colors

More neighbors = more colors used, may not leave any colors for last node

If node n < Registers (easiest nodes) – remove from graph and do last

When you remove nodes, hardest nodes become easy nodes. When graph empty you are done.

Nodes are last, you color them first(easy).

Algorithm works if you can keep removing nodes until empty and can color all nodes

If doesn’t work (doesn’t mean that you cant color nodes, just that algorithm failed—empty complete
problem) //got stuck at removing nodes

- Take highest degree node(throw it away(go to memory) – remove node and its edges)
- Remove nodes n < R. (if you get stuck remove 1 or 2 nodes until rest of nodes have n < R)

Liveness Analysis and Live Range Construction

1. Global Analysis – look at whole control program(boundary-1st and last statement(entry+exit)


2. Local Analysis - look at basic program blocks(each individual instruction code) (before and
after statement) BETWEEN THE GLOBAL ANALYSIS

Once you know global information go back one step to local blocks and compute everything

Local

DEFINE KILL AND GEN for every block


Build CFG – Interferece Grraph (overlapping) -> Color it

1. Semantic Rules know how to write semantic rules


2. Show stack, llinks,how to access variables

3 topics – 3 questions

You might also like