Announcements. Programming Project 4 due Saturday, August 18 at 11:30AM

Similar documents
Register Allocation. How to assign variables to finitely many registers? What to do when it can t be done? How to do so efficiently?

A Simple Code Generator. Code generation Algorithm. Register and Address Descriptors. Example 3/31/2008. Code Generation

CSE 373: More on graphs; DFS and BFS. Michael Lee Wednesday, Feb 14, 2018

(2) If we multiplied a row of B by λ, then the value is also multiplied by λ(here lambda could be 0). namely

Register Allocation. Register Allocation. Principle Phases. Principle Phases. Example: Build. Spills 11/14/2012

CSE 373: AVL trees. Warmup: Warmup. Interlude: Exploring the balance invariant. AVL Trees: Invariants. AVL tree invariants review

Paths. Connectivity. Euler and Hamilton Paths. Planar graphs.

CS553 Lecture Register Allocation 1

COMP108 Algorithmic Foundations

CSE 373. Graphs 1: Concepts, Depth/Breadth-First Search reading: Weiss Ch. 9. slides created by Marty Stepp

b. How many ternary words of length 23 with eight 0 s, nine 1 s and six 2 s?

12/3/12. Outline. Part 10. Graphs. Circuits. Euler paths/circuits. Euler s bridge problem (Bridges of Konigsberg Problem)

5/9/13. Part 10. Graphs. Outline. Circuits. Introduction Terminology Implementing Graphs

Why the Junction Tree Algorithm? The Junction Tree Algorithm. Clique Potential Representation. Overview. Chris Williams 1.

CSC Design and Analysis of Algorithms. Example: Change-Making Problem

Planar Upward Drawings

Outline. Computer Science 331. Computation of Min-Cost Spanning Trees. Costs of Spanning Trees in Weighted Graphs

Integration Continued. Integration by Parts Solving Definite Integrals: Area Under a Curve Improper Integrals

Exam 1 Solution. CS 542 Advanced Data Structures and Algorithms 2/14/2013

Announcements. Not graphs. These are Graphs. Applications of Graphs. Graph Definitions. Graphs & Graph Algorithms. A6 released today: Risk

Outline. 1 Introduction. 2 Min-Cost Spanning Trees. 4 Example

Cycles and Simple Cycles. Paths and Simple Paths. Trees. Problem: There is No Completely Standard Terminology!

, each of which is a tree, and whose roots r 1. , respectively, are children of r. Data Structures & File Management

# 1 ' 10 ' 100. Decimal point = 4 hundred. = 6 tens (or sixty) = 5 ones (or five) = 2 tenths. = 7 hundredths.

CS 461, Lecture 17. Today s Outline. Example Run

Problem solving by search

An undirected graph G = (V, E) V a set of vertices E a set of unordered edges (v,w) where v, w in V

1 Introduction to Modulo 7 Arithmetic

Graph Isomorphism. Graphs - II. Cayley s Formula. Planar Graphs. Outline. Is K 5 planar? The number of labeled trees on n nodes is n n-2

COMPLEXITY OF COUNTING PLANAR TILINGS BY TWO BARS

Module graph.py. 1 Introduction. 2 Graph basics. 3 Module graph.py. 3.1 Objects. CS 231 Naomi Nishimura

(a) v 1. v a. v i. v s. (b)

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

CS 241 Analysis of Algorithms

S i m p l i f y i n g A l g e b r a SIMPLIFYING ALGEBRA.

Multipoint Alternate Marking method for passive and hybrid performance monitoring

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

Solutions for HW11. Exercise 34. (a) Use the recurrence relation t(g) = t(g e) + t(g/e) to count the number of spanning trees of v 1

ECE COMBINATIONAL BUILDING BLOCKS - INVEST 13 DECODERS AND ENCODERS

Constructive Geometric Constraint Solving

Outline. Circuits. Euler paths/circuits 4/25/12. Part 10. Graphs. Euler s bridge problem (Bridges of Konigsberg Problem)

Announcements. These are Graphs. This is not a Graph. Graph Definitions. Applications of Graphs. Graphs & Graph Algorithms

DUET WITH DIAMONDS COLOR SHIFTING BRACELET By Leslie Rogalski

Graphs. Graphs. Graphs: Basic Terminology. Directed Graphs. Dr Papalaskari 1

12. Traffic engineering

Algorithmic and NP-Completeness Aspects of a Total Lict Domination Number of a Graph

Math 61 : Discrete Structures Final Exam Instructor: Ciprian Manolescu. You have 180 minutes.

Section 3: Antiderivatives of Formulas

Graphs. CSC 1300 Discrete Structures Villanova University. Villanova CSC Dr Papalaskari

Using the Printable Sticker Function. Using the Edit Screen. Computer. Tablet. ScanNCutCanvas

CS September 2018

EE1000 Project 4 Digital Volt Meter

XML and Databases. Outline. Recall: Top-Down Evaluation of Simple Paths. Recall: Top-Down Evaluation of Simple Paths. Sebastian Maneth NICTA and UNSW

Seven-Segment Display Driver

CS553 Lecture Register Allocation I 3

NP-Completeness. CS3230 (Algorithm) Traveling Salesperson Problem. What s the Big Deal? Given a Problem. What s the Big Deal? What s the Big Deal?

Designing A Concrete Arch Bridge

CS61B Lecture #33. Administrivia: Autograder will run this evening. Today s Readings: Graph Structures: DSIJ, Chapter 12

More Foundations. Undirected Graphs. Degree. A Theorem. Graphs, Products, & Relations

Garnir Polynomial and their Properties

Present state Next state Q + M N

Fundamental Algorithms for System Modeling, Analysis, and Optimization

The University of Sydney MATH2969/2069. Graph Theory Tutorial 5 (Week 12) Solutions 2008

Last time: introduced our first computational model the DFA.

0.1. Exercise 1: the distances between four points in a graph

Weighted graphs -- reminder. Data Structures LECTURE 15. Shortest paths algorithms. Example: weighted graph. Two basic properties of shortest paths

Formal Concept Analysis

RAM Model. I/O Model. Real Machine Example: Nehalem : Algorithms in the Real World 4/9/13

CSCI Compiler Design

Jonathan Turner Exam 2-10/28/03

Improving Union. Implementation. Union-by-size Code. Union-by-Size Find Analysis. Path Compression! Improving Find find(e)

5/7/13. Part 10. Graphs. Theorem Theorem Graphs Describing Precedence. Outline. Theorem 10-1: The Handshaking Theorem

16.unified Introduction to Computers and Programming. SOLUTIONS to Examination 4/30/04 9:05am - 10:00am

4.1 Interval Scheduling. Chapter 4. Greedy Algorithms. Interval Scheduling: Greedy Algorithms. Interval Scheduling. Interval scheduling.

CS200: Graphs. Graphs. Directed Graphs. Graphs/Networks Around Us. What can this represent? Sometimes we want to represent directionality:

Greedy Algorithms, Activity Selection, Minimum Spanning Trees Scribes: Logan Short (2015), Virginia Date: May 18, 2016

Ch 1.2: Solutions of Some Differential Equations

UNCORRECTED SAMPLE PAGES 4-1. Naming fractions KEY IDEAS. 1 Each shape represents ONE whole. a i ii. b i ii

INTEGRALS. Chapter 7. d dx. 7.1 Overview Let d dx F (x) = f (x). Then, we write f ( x)

Instructions for Section 1

Weighted Graphs. Weighted graphs may be either directed or undirected.

d e c b a d c b a d e c b a a c a d c c e b

Expert System. Knowledge-Based Systems. Page 1. Development of KB Systems. Knowledge base. Expert system = Structured computer program

a b c cat CAT A B C Aa Bb Cc cat cat Lesson 1 (Part 1) Verbal lesson: Capital Letters Make The Same Sound Lesson 1 (Part 1) continued...

Chapter 9. Graphs. 9.1 Graphs

Similarity Search. The Binary Branch Distance. Nikolaus Augsten.

Aquauno Video 6 Plus Page 1

Section 10.4 Connectivity (up to paths and isomorphism, not including)

5/1/2018. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees

What do you know? Listen and find. Listen and circle. Listen and chant. Listen and say. Lesson 1. sheep. horse

SAMPLE PAGES. Primary. Primary Maths Basics Series THE SUBTRACTION BOOK. A progression of subtraction skills. written by Jillian Cockings

Organization. Dominators. Control-flow graphs 8/30/2010. Dominators, control-dependence. Dominator relation of CFGs

Nefertiti. Echoes of. Regal components evoke visions of the past MULTIPLE STITCHES. designed by Helena Tang-Lim

Graph Contraction and Connectivity

QUESTIONS BEGIN HERE!

The Plan. Honey, I Shrunk the Data. Why Compress. Data Compression Concepts. Braille Example. Braille. x y xˆ

Lecture 20: Minimum Spanning Trees (CLRS 23)

Floating Point Number System -(1.3)

Floating Point Number System -(1.3)

Decimals DECIMALS.

Transcription:

Rgistr Allotion

Announmnts Progrmming Projt 4 u Stury, August 18 t 11:30AM OH ll this wk. Ask qustions vi mil! Ask qustions vi Pizz! No lt sumissions.

Pls vlut this ours on Axss. Your k rlly mks irn.

Whr W Ar Sour Co Lxil Anlysis Syntx Anlysis Smnti Anlysis IR Gnrtion IR Optimiztion Co Gnrtion Optimiztion Mhin Co

Whr W Ar Sour Co Lxil Anlysis Syntx Anlysis Smnti Anlysis IR Gnrtion IR Optimiztion Co Gnrtion Optimiztion Mhin Co Fn-TAC-sti!

Whr W Ar Sour Co Lxil Anlysis Syntx Anlysis Smnti Anlysis IR Gnrtion IR Optimiztion Co Gnrtion Optimiztion Mhin Co

Co Gnrtion t Gln At this point, w hv optimiz IR o tht ns to onvrt into th trgt lngug (.g. ssmly, mhin o). Gol o this stg: Choos th pproprit mhin instrutions or h IR instrution. Divvy up init mhin rsours (rgistrs, hs, t.) Implmnt low-lvl tils o th runtim nvironmnt. Mhin-spii optimiztions r otn on hr, though som r trt s prt o inl optimiztion phs.

Ovrviw Rgistr Allotion (Toy) How to ssign vrils to initly mny rgistrs? Wht to o whn it n't on? How to o so iinty? Grg Colltion (Mony) How to tt rliml mmory? How to rlim mmory iintly?

Mmory Tros Thr is n normous tro twn sp n siz in mmory. SRAM is st ut vry xpnsiv: Cn kp up with prossor sps in th GHz. As o 2007, ost is $10/MB Goo luk uying 1TB o th stu! Hr isks r hp ut vry slow: As o 2012, you n uy 2TB hr riv or out $100 As o 2012, goo isk sk tims r msur in ms (out two to our million tims slowr thn prossor yl!)

Th Mmory Hirrhy I: Try to gt th st o ll worls y using multipl typs o mmory.

Th Mmory Hirrhy I: Try to gt th st o ll worls y using multipl typs o mmory. Rgistrs L1 Ch L2 Ch Min Mmory Hr Disk Ntwork

Th Mmory Hirrhy I: Try to gt th st o ll worls y using multipl typs o mmory. Rgistrs L1 Ch L2 Ch Min Mmory Hr Disk Ntwork 256B - 8KB 16KB 64KB 1MB - 4MB 4GB 256GB 500GB+ HUGE

Th Mmory Hirrhy I: Try to gt th st o ll worls y using multipl typs o mmory. Rgistrs L1 Ch L2 Ch Min Mmory Hr Disk Ntwork 256B - 8KB 16KB 64KB 1MB - 4MB 4GB 256GB 500GB+ HUGE 0.25 1ns 1ns 5ns 5ns 25ns 25ns 100ns 3 10ms 10 2000ms

Th Chllngs o Co Gnrtion Almost ll progrmming lngugs xpos ors viw o th mmory hirrhy: All vrils liv in mmory. Disk n ntwork xpliitly hnl sprtly. (Intrsting xption: Stnor's Squoi progrmming lngug) Chllngs in o gnrtion: Position ojts in wy tht tks mximum vntg o th mmory hirrhy. Do so without hints rom th progrmmr.

Rgistrs Most mhins hv st o rgistrs, it mmory lotions tht n ss quikly, n hv omputtions prorm on thm, n xist in smll quntity. Using rgistrs intlligntly is ritil stp in ny ompilr. A goo rgistr llotor n gnrt o orrs o mgnitu ttr thn rgistr llotor.

Rgistr Allotion In TAC, thr r n unlimit numr o vrils. On physil mhin thr r smll numr o rgistrs: x86 hs our gnrl-purpos rgistrs n numr o spiliz rgistrs. MIPS hs twnty-our gnrl-purpos rgistrs n ight spil-purpos rgistrs. Rgistr llotion is th pross o ssigning vrils to rgistrs n mnging t trnsr in n out o rgistrs.

Chllngs in Rgistr Allotion Rgistrs r sr. Otn sustntilly mor IR vrils thn rgistrs. N to in wy to rus rgistrs whnvr possil. Rgistrs r omplit. x86: Eh rgistr m o svrl smllr rgistrs; n't us rgistr n its onstitunt rgistrs t th sm tim. x86: Crtin instrutions must stor thir rsults in spii rgistrs; n't stor vlus thr i you wnt to us thos instrutions. MIPS: Som rgistrs rsrv or th ssmlr or oprting systm. Most rhitturs: Som rgistrs must prsrv ross untion lls.

Gols or Toy Introu rgistr llotion or MIPSstyl mhin: Som numr o inivisil, gnrl-purpos rgistrs. Explor thr lgorithms or rgistr llotion: Nïv ( no ) rgistr llotion. Linr sn rgistr llotion. Grph-oloring rgistr llotion.

An Initil Rgistr Allotor I: Stor vry vlu in min mmory, loing vlus only whn thy'r n. To gnrt o tht prorms omputtion: Gnrt lo instrutions to pull th vlus rom min mmory into rgistrs. Gnrt o to prorm th omputtion on th rgistrs. Gnrt stor instrutions to stor th rsult k into min mmory.

Our Rgistr Allotor In Ation

Our Rgistr Allotor In Ation = + ; = ; = + ;

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N... Prm 1 Stor p Stor r p + 4N... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N... Prm 1 Stor p Stor r p + 4N... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20

Our Rgistr Allotor In Ation = + ; = ; = + ; lw $t0, -12(p) Prm N... Prm 1 Stor p Stor r p + 4N... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20

Our Rgistr Allotor In Ation = + ; = ; = + ; lw $t0, -12(p) lw $t1, -16(p) Prm N... Prm 1 Stor p Stor r p + 4N... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20

Our Rgistr Allotor In Ation = + ; = ; = + ; lw $t0, -12(p) lw $t1, -16(p) $t2, $t0, $t1 Prm N... Prm 1 Stor p Stor r p + 4N... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N p + 4N lw $t0, -12(p) lw $t1, -16(p) $t2, $t0, $t1 sw $t2, -8(p)... Prm 1 Stor p Stor r... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N p + 4N lw $t0, -12(p) lw $t1, -16(p) $t2, $t0, $t1 sw $t2, -8(p)... Prm 1 Stor p Stor r... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N p + 4N lw $t0, -12(p) lw $t1, -16(p) $t2, $t0, $t1 sw $t2, -8(p)... Prm 1 Stor p Stor r... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20 lw $t0, -8(p)

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N p + 4N lw $t0, -12(p) lw $t1, -16(p) $t2, $t0, $t1 sw $t2, -8(p)... Prm 1 Stor p Stor r... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20 lw $t0, -8(p) sw $t0, -20(p)

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N p + 4N lw $t0, -12(p) lw $t1, -16(p) $t2, $t0, $t1 sw $t2, -8(p)... Prm 1 Stor p Stor r... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20 lw $t0, -8(p) sw $t0, -20(p)

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N p + 4N lw $t0, -12(p) lw $t1, -16(p) $t2, $t0, $t1 sw $t2, -8(p)... Prm 1 Stor p Stor r... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20 lw $t0, -8(p) sw $t0, -20(p) lw $t0, -8(p)

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N p + 4N lw $t0, -12(p) lw $t1, -16(p) $t2, $t0, $t1 sw $t2, -8(p)... Prm 1 Stor p Stor r... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20 lw $t0, -8(p) sw $t0, -20(p) lw $t0, -8(p) lw $t1, -20(p)

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N p + 4N lw $t0, -12(p) lw $t1, -16(p) $t2, $t0, $t1 sw $t2, -8(p)... Prm 1 Stor p Stor r... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20 lw $t0, -8(p) sw $t0, -20(p) lw $t0, -8(p) lw $t1, -20(p) $t2, $t0, $t1

Our Rgistr Allotor In Ation = + ; = ; = + ; Prm N p + 4N lw $t0, -12(p) lw $t1, -16(p) $t2, $t0, $t1 sw $t2, -8(p)... Prm 1 Stor p Stor r... p + 4 p + 0 p - 4 p - 8 p - 12 p - 16 p - 20 lw $t0, -8(p) sw $t0, -20(p) lw $t0, -8(p) lw $t1, -20(p) $t2, $t0, $t1 sw $t2, -16(p)

Anlysis o our Allotor Disvntg: Gross iniiny. Issus unnssry los n stors y th ozn. Wsts sp on vlus tht oul stor purly in rgistrs. Esily n orr o mgnitu or two slowr thn nssry. Unptl in ny proution ompilr. Avntg: Simpliity. Cn trnslt h pi o IR irtly to ssmly s w go. Nvr n to worry out running out o rgistrs. Nvr n to worry out untion lls or spil-purpos rgistrs. Goo i you just n to gt prototyp ompilr up n running.

Builing Bttr Allotor Gol: Try to hol s mny vrils in rgistrs s possil. Rus mmory rs/writs. Rus totl mmory usg. W will n to rss ths qustions: Whih rgistrs o w put vrils in? Wht o w o whn w run out o rgistrs?

Rgistr Consistny = + = = =

Rgistr Consistny At h progrm point, h vril must in th sm lotion. Dos not mn tht h vril is lwys stor in th sm lotion! At h progrm point, h rgistr hols t most on liv vril. Cn ssign svrl vrils th sm rgistr i no two o thm vr will r togthr.

Liv Rngs n Liv Intrvls Rll: A vril is liv t prtiulr progrm point i its vlu my r ltr or it is writtn. Cn in this using glol livnss nlysis. Th liv rng or vril is th st o progrm points t whih tht vril is liv. Th liv intrvl or vril is th smllst surng o th IR o ontining ll vril's liv rngs. A proprty o th IR o, not th CFG. Lss pris thn liv rngs, ut simplr to work with.

Liv Rngs n Liv Intrvls

Liv Rngs n Liv Intrvls = + = + = + IZ Goto _L0 = + Goto _L1; _L0: = - _L1: g =

Liv Rngs n Liv Intrvls = + = + = + = + = + IZ Goto _L0 = + Goto _L1; = + _L0: = - _L1: g = = + = g =

Liv Rngs n Liv Intrvls = + = + = + = + = + IZ Goto _L0 = + Goto _L1; = + _L0: = - _L1: g = = + = g = { g }

Liv Rngs n Liv Intrvls = + = + = + = + = + IZ Goto _L0 = + Goto _L1; = + _L0: = - _L1: g = = + = { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + = + = + IZ Goto _L0 = + Goto _L1; = + _L0: _L1: = - g = = + { } = { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + = + = + IZ Goto _L0 = + Goto _L1; = + _L0: = - _L1: g = {, } = + { } = { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + = + = + IZ Goto _L0 = + Goto _L1; = + _L0: = - _L1: g = {, } = + { } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + = + = + IZ Goto _L0 = + Goto _L1; = + _L0: = - _L1: g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + = + = + IZ Goto _L0 = + _L0: Goto _L1; = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + = + = + IZ Goto _L0 _L0: = + Goto _L1; {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + = + IZ Goto _L0 = + Goto _L1; _L0: = + {,, } {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + = + IZ Goto _L0 = + Goto _L1; _L0: {,, } = + {,, } {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + IZ Goto _L0 = + Goto _L1; _L0: = + {,, } {,, } = + {,, } {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + IZ Goto _L0 = + Goto _L1; _L0: {,,, } = + {,, } {,, } = + {,, } {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + IZ Goto _L0 = + Goto _L1; _L0: {,,, } = + {,, } {,, } = + {,, } {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + IZ Goto _L0 = + Goto _L1; _L0: {,,, } = + {,, } {,, } = + {,, } {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + = + = + IZ Goto _L0 = + Goto _L1; _L0: {,,, } = + {,, } {,, } = + {,, } {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + {,,, } = + {,, } = + = + IZ Goto _L0 {,, } = + {,, } = + Goto _L1; _L0: {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + {,,, } = + {,, } = + = + IZ Goto _L0 {,, } = + {,, } = + Goto _L1; _L0: {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + {,,, } = + {,, } = + = + IZ Goto _L0 {,, } = + {,, } = + Goto _L1; _L0: {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + {,,, } = + {,, } = + = + IZ Goto _L0 {,, } = + {,, } = + Goto _L1; _L0: {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + {,,, } = + {,, } = + = + IZ Goto _L0 {,, } = + {,, } = + Goto _L1; _L0: {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Liv Rngs n Liv Intrvls = + g {,,, } = + {,, } = + = + IZ Goto _L0 {,, } = + {,, } = + Goto _L1; _L0: {,, } = + {, } _L1: = - g = {, } = + { } {, } = { } { } g = { g }

Rgistr Allotion with Liv Intrvls Givn th liv intrvls or ll th vrils in th progrm, w n llot rgistrs using simpl gry lgorithm. g I: Trk whih rgistrs r r t h point. Whn liv intrvl gins, giv tht vril r rgistr. Whn liv intrvl ns, th rgistr is on gin r. W n't lwys it vrything into rgistr; w'll s wht o to in minut.

Rgistr Allotion with Liv Intrvls g

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 23

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 23

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 23

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 23

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 23

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 32

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 32

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 32

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 32

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 32

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 23

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 23

Rgistr Allotion with Liv Intrvls g Fr Rgistrs R 0 R 1 R 2 R 23

Anothr Exmpl

Anothr Exmpl g

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2 Wht o w o now?

Rgistr Spilling I rgistr nnot oun or vril v, w my n to spill vril. Whn vril is spill, it is stor in mmory rthr thn rgistr. Whn w n rgistr or th spill vril: Evit som xisting rgistr to mmory. Lo th vril into th rgistr. Whn on, writ th rgistr k to mmory n rlo th rgistr with its originl vlu. Spilling is slow, ut somtims nssry.

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2 Wht o w o now?

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Anothr Exmpl g Fr Rgistrs R 0 R 1 R 2

Linr Sn Rgistr Allotion This lgorithm is ll linr sn rgistr llotion n is omprtivly nw lgorithm. Avntgs: Vry iint (tr omputing liv intrvls, runs in linr tim) Prous goo o in mny instns. Allotion stp works in on pss; n gnrt o uring itrtion. Otn us in JIT ompilrs lik Jv HotSpot. Disvntgs: Impris u to us o liv intrvls rthr thn liv rngs. Othr thniqus known to suprior in mny ss.

Corrtnss Proo Skth No rgistr hols two liv vrils t on: Liv intrvls r onsrvtiv pproximtions o liv rngs. No two vrils with ovrlpping liv rngs pl in th sm rgistr. At h progrm point, vry vril is in th sm lotion: All vrils ssign uniqu lotion.

Son-Chn Bin Pking A mor ggrssiv vrsion o linr-sn. Uss liv rngs inst o liv intrvls. I vril must spill, on't spill ll uss o it. A ltr liv rng might still it into rgistr. Rquirs inl t-low nlysis to onirm vrils r ssign onsistnt lotions. S Qulity n Sp in Linr-sn Rgistr Allotion y Tru, Hollowy, n Smith.

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

Son-Chn Bin Pking g Fr Rgistrs R 0 R 1 R 2

An Entirly Dirnt Approh

An Entirly Dirnt Approh {,,, } = + {,, } {,, } = + {,, } {,, } = + {, } {, } = + { } {, } = { } { } g = { g }

An Entirly Dirnt Approh {,,, } = + {,, } {,, } = + {,, } {, } = + { } {,, } = + {, } {, } = { } Wht n w inr rom ll ths vrils ing liv t this point? { } g = { g }

An Entirly Dirnt Approh {,,, } = + {,, } {,, } = + {,, } {,, } = + {, } {, } = + { } {, } = { } { } g = { g }

An Entirly Dirnt Approh {,,, } = + {,, } {,, } = + {,, } {, } = + { } {,, } = + {, } {, } = { } g { } g = { g }

An Entirly Dirnt Approh {,,, } = + {,, } {,, } = + {,, } {, } = + { } {,, } = + {, } {, } = { } g { } g = { g }

An Entirly Dirnt Approh {,,, } = + {,, } {,, } = + {,, } {, } = + { } {,, } = + {, } {, } = { } g { } g = { g }

An Entirly Dirnt Approh {,,, } = + {,, } {,, } = + {,, } {, } = + { } {,, } = + {, } {, } = { } g { } g = { g }

An Entirly Dirnt Approh {,,, } = + {,, } Rgistrs R 0 R 1 R 2 R 3 {,, } = + {,, } {, } = + { } {,, } = + {, } {, } = { } g { } g = { g }

An Entirly Dirnt Approh {,,, } = + {,, } Rgistrs R 0 R 1 R 2 R 3 {,, } = + {,, } {, } = + { } {,, } = + {, } {, } = { } g { } g = { g }

Th Rgistr Intrrn Grph Th rgistr intrrn grph (RIG) o ontrol-low grph is n unirt grph whr Eh no is vril. Thr is n g twn two vrils tht r liv t th sm progrm point. Prorm rgistr llotion y ssigning h vril irnt rgistr rom ll o its nighors. Thr's just on th...

Th On Cth This prolm is quivlnt to grpholoring, whih is NP-hr i thr r t lst thr rgistrs. No goo polynomil-tim lgorithms (or vn goo pproximtions!) r known or this prolm. W hv to ontnt with huristi tht is goo nough or RIGs tht ris in prti.

Th On Cth to Th On Cth

Th On Cth to Th On Cth I you n igur out wy to ssign rgistrs to ritrry RIGs, you'v just provn P = NP n will gt $1,000,000 hk rom th Cly Mthmtis Institut.

Th On Cth to Th On Cth I you n igur out wy to ssign rgistrs to ritrry RIGs, you'v just provn P = NP n will gt $1,000,000 hk rom th Cly Mthmtis Institut.

Bttling NP-Hrnss

Chitin's Algorithm Intuition: Suppos w r trying to k-olor grph n in no with wr thn k gs. I w lt this no rom th grph n olor wht rmins, w n in olor or this no i w it k in. Rson: With wr thn k nighors, som olor must lt ovr. Algorithm: Fin no with wr thn k outgoing gs. Rmov it rom th grph. Rursivly olor th rst o th grph. A th no k in. Assign it vli olor.

Chitin's Algorithm

Chitin's Algorithm g

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

Chitin's Algorithm g Rgistrs R 0 R 1 R 2 R 3

On Prolm Wht i w n't in no with wr thn k nighors? Choos n rmov n ritrry no, mrking it troulsom. Us huristis to hoos whih on. Whn ing no k in, it my possil to in vli olor. Othrwis, w hv to spill tht no.

Chitin's Algorithm Rlo g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo (spill) g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo (spill) g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo (spill) g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo (spill) g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo (spill) g g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo (spill) g Rgistrs R 0 R 1 R 2

Chitin's Algorithm Rlo (spill) g Rgistrs R 0 R 1 R 2

A Smrtr Algorithm {,,, } = + {,, } Rgistrs R 0 R 1 R 2 {,, } = + {,, } {,, } = + {, } g (spill) {, } = + { } {, } = { } { } g = { g }

A Smrtr Algorithm {,,, } = + {,, } Rgistrs R 0 R 1 R 2 {,, } = + {,, } {,, } = + {, } g (spill) {, } = + { } {, } = { } { } g = { g }

A Smrtr Algorithm {,,, } = + {,, } Rgistrs R 0 R 1 R 2 {,, } = + {,, } {,, } = + {, } g (spill) {, } ' = + { ' } {, } ' = { ' } { ' } g = ' { g }

A Smrtr Algorithm {,,, } = + {,, } Rgistrs R 0 R 1 R 2 {,, } = + {,, } {,, } = + {, } g (spill) ' {, } ' = + { ' } {, } ' = { ' } { ' } g = ' { g }

Anothr Exmpl

Anothr Exmpl

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl Rgistrs R 0 R 1 R 2

Anothr Exmpl (spill) Rgistrs R 0 R 1 R 2

Anothr Exmpl (spill) Rgistrs R 0 R 1 R 2

Anothr Exmpl (spill) (spill) Rgistrs R 0 R 1 R 2

Chitin's Algorithm Avntgs: For mny ontrol-low grphs, ins n xllnt ssignmnt o vrils to rgistrs. Whn istinguishing vrils y us, prous pris RIG. Otn us in proution ompilrs lik GCC. Disvntgs: Cor pproh s on th NP-hr grph oloring prolm. Huristi my prou pthologilly worst-s ssignmnts.

Corrtnss Proo Skth No two vrils liv t som point r ssign th sm rgistr. For y grph oloring. At ny progrm point h vril is lwys in on lotion. Automti i w ssign h vril on rgistr. Rquirs w triks i w sprt y us s.

Improvmnts to th Algorithm Choos wht to spill intlligntly. Us huristis (lst-ommonly us, grtst improvmnt, t.) to trmin wht to spill. Hnl spilling intlligntly. Whn spilling vril, romput th RIG s on th spill n us nw oloring to in rgistr.

Summry o Rgistr Allotion Critil stp in ll optimizing ompilrs. Th linr sn lgorithm uss liv intrvls to grily ssign vrils to rgistrs. Otn us in JIT ompilrs u to iiny. Chitin's lgorithm uss th rgistr intrrn grph (s on liv rngs) n grph oloring to ssign rgistrs. Th sis or th thniqu us in GCC.

Nxt Tim Grg Colltion Rrn Counting Mrk-n-Swp Stop-n-Copy Inrmntl Colltors