Rgistr Allotion Gol: rpl tmporry vril sss y rgistr sss Why? Constrints: Fix st of rgistrs Two simultnously liv vrils nnot llot to th sm rgistr A vril is liv if it will us gin for ing rfin.
1. Intify Liv Vril Rngs Bsi rul: Tmporris t1 n t2 n shr th sm rgistr if t ny point in th progrm t most on of t1 or t2 is liv!
Rgistr Intrfrn Grph
Wht is th Rgistr Infrn Grph for this xmpl?
Rgistr Intrfrn Grph 1. Wht nnot ssign sm rgistr? 2. Wht n ssign th sm rgistr?
Your Turn Writ own th liv vrils ftr h sttmnt." Hint: Strt t th ottom. Instrutions Liv vrs = + 2 = * = + 1 rturn *
Liv Vrils Instrutions Liv vrs = + 2 = * = + 1 rturn *,
Liv Vrils Instrutions Liv vrs = + 2 = * = + 1 rturn *,,
Liv Vrils Instrutions Liv vrs = + 2 = * = + 1 rturn *,,,
Instrutions Liv vrs = + 2, = *, = + 1, rturn * Liv Vrils
Intrfrn grph n Rgistr Allotion Nos of th grph = vrils Egs onnt vrils tht intrfr with on nothr Nos will ssign olor orrsponing to th rgistr ssign to th vril Two olors n t nxt to on nothr in th grph
Rgistr Allotion = Grph Coloring
Coloring th RIG olor rgistr Instrutions Liv vrs = + 2, = *, = + 1, rturn * R1 R2
Coloring th RIG olor rgistr Instrutions Liv vrs = + 2, = *, = + 1, rturn * R1 R2
How to o th Grph oloring Qustions: Cn w ffiintly fin oloring of th grph whnvr possil? Cn w ffiintly fin th optimum oloring of th grph? How o w hoos rgistrs to voi mov instrutions? Wht o w o whn thr rn t nough olors (rgistrs) to olor th grph?
Coloring grph Kmp s lgorithm [1879] for fining K- oloring of grph Assum K=3 Stp 1 (simplify): fin no with t most K-1 gs n rmov from th grph (with its gs). (Rmmr this no on stk for ltr stgs.)
Coloring grph On oloring is foun for th simplr grph, w n lwys olor th no w sv on th stk Stp 2 (olor): whn th simplifi sugrph hs n olor, k th no on th top of th stk n ssign it olor not tkn y on of th jnt nos
Coloring with K=2 olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Filur If th grph nnot olor, it will vntully simplifi to grph in whih vry no hs t lst K nighors Somtims, th grph is still K-olorl! Fining K-oloring in ll situtions is n NP-omplt prolm W will hv to pproximt to mk rgistr llotors fst nough
Coloring with K=2 olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk: ll nos hv 2 nighours!
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk:
Coloring olor rgistr R1 R2 stk: W got luky!
Try to Color this with 4 olors? " 3 olors?
On Possil 4 oloring
Th o woul look lik this
Coloring with K=2 olor rgistr R1 R2 Som grphs n t olor in K olors: stk:
Coloring olor rgistr R1 R2 Som grphs n t olor in K olors: stk:
Coloring olor rgistr R1 R2 Som grphs n t olor in K olors: stk:
Coloring olor rgistr R1 R2 Som grphs n t olor in K olors: stk: no olors lft for!
Spilling Stp 3 (spilling): on ll nos hv K or mor nighors, pik no for spilling Stor on th stk Thr r mny huristis tht n us to pik no E.g., not in n innr loop
Spilling: Insrting Co
Exmpl
Romputing Vril Livnss
Romput th RIG ftr spilling This is 3-olorl!
Ovrll Algorithm Simplify Livnss Mrk possil spills Color & tt tul spills Rwrit o to implmnt tul spills
Summry Rgistr llotion hs thr mjor prts Livnss nlysis Grph oloring Progrm trnsformtion (spilling) For mor informtion, hptr 11.1-11.3 in Appl