Chapter-11(register allocation )

# Chapter-11(register allocation ) - Chapter 11 Register...

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

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

View Full Document

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 11 Register Allocation Chapter 11 Register Allocation • there are an infinite number of registers to hold temporary values and that MOVE instructions cost nothing. • The job of the register allocator: – assign the many temporaries to a small number of machine registers. – assign the source and destination of a MOVE to the same register so that the MOVE can be deleted. Chapter 11 Register Allocation • From an examination of the control and dataflow graph, we derive an interference graph . • Each node represents a temporary value; • each edge ( t 1, t 2) indicates a pair of temporaries that cannot be assigned to the same register. • The most common reason for an interference edge is that t 1 and t 2 are live at the same time. Chapter 11 Register Allocation • color the interference graph – use as few colors as possible – no pair of nodes connected by an edge may be assigned the same color. ( Graph coloring problems derive from the old mapmakers' rule that adjacent countries on a map should be colored with different colors. ) Chapter 11 Register Allocation • If our target machine has K registers, and we can K-color the graph (color the graph with K colors), then the coloring is a valid register assignment for the interference graph. • If there is no K-coloring, we will have to keep some of our variables and temporaries in memory instead of registers; this is called spilling . Chapter 11 Register Allocation 11.1 COLORING BY SIMPLIFICATION • Register allocation is an NP-complete problem (except in special cases, such as expression trees)( graph coloring is also NP-complete .) • there is a linear-time approximation algorithm that gives good results....
View Full Document

## This note was uploaded on 10/20/2011 for the course COMPUTER S 10586 taught by Professor Jilinwang during the Spring '09 term at Zhejiang University.

### Page1 / 25

Chapter-11(register allocation ) - Chapter 11 Register...

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

View Full Document
Ask a homework question - tutors are online