lecture-08

# lecture-08 - Global Register Allocation(Slides from Andrew...

This preview shows pages 1–13. Sign up to view the full content.

Global Register Allocation (Slides from Andrew Myers) Monday, October 17, 2011

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Main idea • Want to replace temporary variables with some fixed set of registers • First : need to know which variables are live after each instruction – Two simultaneously live variables cannot be allocated to the same register Monday, October 17, 2011
Register allocation • For every node n in CFG, we have out[n] – Set of temporaries live out of n • Two variables interfere if – both initially live (ie: function args), or – both appear in out[n] for any n • How to assign registers to variables? Monday, October 17, 2011

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Interference graph • Nodes of the graph = variables • Edges connect variables that interfere with one another • Nodes will be assigned a color corresponding to the register assigned to the variable • Two colors can’t be next to one another in the graph Monday, October 17, 2011
Interference graph Instructions Live vars b = a + 2 c = b * b b = c + 1 return b * a Monday, October 17, 2011

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Interference graph Instructions Live vars b = a + 2 c = b * b b = c + 1 b,a return b * a Monday, October 17, 2011
Interference graph Instructions Live vars b = a + 2 c = b * b a,c b = c + 1 b,a return b * a Monday, October 17, 2011

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Interference graph Instructions Live vars b = a + 2 b,a c = b * b a,c b = c + 1 b,a return b * a Monday, October 17, 2011
Interference graph Instructions Live vars a b = a + 2 b,a c = b * b a,c b = c + 1 b,a return b * a Monday, October 17, 2011

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Interference graph Instructions Live vars a b = a + 2 a,b c = b * b a,c b = c + 1 a,b return b * a a c b eax ebx color register Monday, October 17, 2011
Interference graph Instructions Live vars a b = a + 2 a,b c = b * b a,c b = c + 1 a,b return b * a a c b eax ebx color register Monday, October 17, 2011

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Graph coloring • Questions: – Can we efficiently find a coloring of the graph whenever possible? – Can we efficiently find the optimum coloring of
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/19/2012 for the course ECE 468 taught by Professor Test during the Fall '08 term at Purdue.

### Page1 / 48

lecture-08 - Global Register Allocation(Slides from Andrew...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online