Register Allocation. Xiao Jia April 25 th, 2012

Similar documents
Main idea. Register Allocation. Interference graph. Register allocation. Interference graph. Interference graph

Global Register Allocation

Register Allocation. Goal: replace temporary variable accesses by register accesses Why? Constraints:

Memory Management. Memory Management. Chapter 11. Memory Management Techniques. I. Single Contiguous. II. Overlays. Advantages: Disadvantages:

Minimum Spanning Tree. EECS 214, Fall 2017

Graph coloring. Kempe s algorithm removes nodes with < K edges

Routing Lectures! Advanced Topics in Routing! But there is more to the story.! Self-Learning! Interdomain: Path-vector! Intradomain (L3)!

PRILEX STEEL DETAILING LLC

Math Circles Finite Automata Question Sheet 3 (Solutions)

ENCODER1 XXX LED POWER LED POWER GROUND CHAN A INDEX INPUT INPUT GROUND GROUND CHAN B +5V TTL XXX PWM XXX STATUS LED LED POWER DIR XXX INPUT XXX XXX

Name & Address. Listening and Speaking. Listening and Speaking UNIT Listen and repeat the letters.

STEP 7 'KEY' ON INNER INSERT ASSY. H. CRIMP CONTACTS ONTO INDIVIDUAL CONDUCTORS (REFER TO SHEET 5 FOR DETAILS).

Tries. nimize. mize nimize ze. 4/18/2016 6:48 AM Tries 1

Geometric quantities for polar curves

EE Controls Lab #2: Implementing State-Transition Logic on a PLC

SEE PAGE 4 FOR MANUFACTURER SPECIFIC BLDC MOTOR WIRING EXAMPLES

In this project you ll learn how to create a game in which you have to save the Earth from space monsters.

Mathematics. Exponentials and Logarithms. hsn.uk.net. Higher. Contents. Exponentials and Logarithms 134 HSN23300

P-194 Sheet Bar Measures 1 inch

Red Room Poetry. Find out more at redroomcompany.org

Algorithms for Memory Hierarchies Lecture 14

Student Book SERIES. Patterns and Algebra. Name

MAXIMUM FLOWS IN FUZZY NETWORKS WITH FUNNEL-SHAPED NODES

Aquauno Select MINUTES. (duration) FREQUENCY LED. OFF 8h AQUAUNO SELECT 5 MIN FREQUENCY. the timer is being programmed;

Supplementary Online Content

Polar Coordinates. July 30, 2014

Student Book SERIES. Fractions. Name

Birka B22: threaded in variation

Patterns and Algebra

Solutions to exercise 1 in ETS052 Computer Communication

Probability and Statistics P(A) Mathletics Instant Workbooks. Copyright

Comparing Fractions page 1 of 2 1 Color in the grid to show the fractions below. Each grid represents 1 whole. a 1 2 b 1. d 16

MOS Transistors. Silicon Lattice

Deluxe Let s Cook Kitchen

ESCI 241 Meteorology Lesson 6 Humidity

GLONASS PhaseRange biases in RTK processing

ITEC2620 Introduction to Data Structures

1/24/2017. Electrical resistance

p M M M O O M M M M M M M M O vo M M M M MM

Positron Emission Tomography (PET) Images

More Fun with D/A Converters

Homework #1 due Monday at 6pm. White drop box in Student Lounge on the second floor of Cory. Tuesday labs cancelled next week

EASY DISC Assessment

Kirchhoff s Rules. Kirchhoff s Laws. Kirchhoff s Rules. Kirchhoff s Laws. Practice. Understanding SPH4UW. Kirchhoff s Voltage Rule (KVR):

cos The points in an Argand diagram which represent the numbers (iii) Write down a polynomial equation of degree 5 which is satisfied by w.

Section 6.1 Law of Sines. Notes. Oblique Triangles - triangles that have no right angles. A c. A is acute. A is obtuse

CSE 554 Lecture 1: Binary Pictures

ESE535: Electronic Design Automation. Today. Topological Worst-Case Delay. Topological Worst-Case Delay. Topological Worst-Case Delay.

THIS LECTURE looks at bell ringing (the posh name is Tintinnalogia) which as. WE NORMALLY think of a bell as hanging mouth down. If we swing the bell,

Samantha s Strategies page 1 of 2

Common Collector & Common Base Amplifier Circuits

(1) Primary Trigonometric Ratios (SOH CAH TOA): Given a right triangle OPQ with acute angle, we have the following trig ratios: ADJ

MATHEMATICS. Student Booklet

CS 135: Computer Architecture I. Boolean Algebra. Basic Logic Gates

10.4 AREAS AND LENGTHS IN POLAR COORDINATES

E WHITE HEAD V-102 V-103 HAMPTON HILL PLANTERS HILL GENERAL NOTES:

SAFETY PRODUCT NAVIGATOR APPLICATION OF SAFETY PRODUCTS OVERVIEW

EECE 301 Signals & Systems Prof. Mark Fowler

Macroscopic and Microscopic Springs Procedure

contents Once you learn a handful of stitches, you ll be amazed at the jewelry you can create and wear!

Example. Check that the Jacobian of the transformation to spherical coordinates is

Addition Mission: Facts Practice

OR BUILDING PERMIT SHEET DATA PRELIMINARY NOT FOR CONSTRUCTION PROJECT. Author. Checker STAMP INTERIOR DESIGN: REVIEWED BY: DRAWN BY:

3-Dimensions. 3-Dimensions. 3D Shapes. Recognise 3-D Shapes and know their properties. 2 Dimensional. 3 Dimensional. Exercise 1

If you d like your friends to have it, too, please refer them to my site so they can subscribe as well:

Installation Instructions Model # TEL-100 / 200 Manual Locking or Self Locking

Lab 12. Speed Control of a D.C. motor. Controller Design

PERMIT DRAWINGS GULF COAST AMMONIA TERMINAL DOCK GULF COAST AMMONIA (GCA) GALVESTON COUNTY, TEXAS DECEMBER 2018

Resistors, Current and Voltage measurements, Ohm s law, Kirchhoff s first and second law. Kirchhoff s first Objectives:

Defeating a Scarcity Mindset

model 8317CTFPC1D1 OPTIONS

Laser Interferometry Tools for Precision Measurement

ASY P.O. BOX 729 TERRELL, TEXAS / PAGE 1 OF 13 SAM

Topic 20: Huffman Coding

Algebra Practice. Dr. Barbara Sandall, Ed.D., and Travis Olson, M.S.

Chapter 18. State Transfer Taxes

Efficient and Resilient Key Discovery based on Pseudo-Random Key Pre-Deployment

Exercise 1-1. The Sine Wave EXERCISE OBJECTIVE DISCUSSION OUTLINE. Relationship between a rotating phasor and a sine wave DISCUSSION

The Discussion of this exercise covers the following points:

Assembly Instructions for Model: VMDD26

Vision Vol. 1: Little Worse Than A Man By Tom King, Gabriel Hernandez Walta READ ONLINE

Regular languages can be expressed as regular expressions.

Lecture 16: Four Quadrant operation of DC Drive (or) TYPE E Four Quadrant chopper Fed Drive: Operation

The PWM switch model introduced by Vatché Vorpérian in 1986 describes a way to model a voltage-mode switching converter with the VM-PWM switch model.

Dataflow Language Model. DataFlow Models. Applications of Dataflow. Dataflow Languages. Kahn process networks. A Kahn Process (1)

& Y Connected resistors, Light emitting diode.

Include a copy of this drawing with each set of parts. 2 B 1 SHEET 1 OF 6 ITEM DESCRIPTION RCK0001

Hello, Linx Part Number CSI-RGFB-ccc-UFFR CSI-RSFB-ccc-UFFR CSI-RSFE-ccc-UFFR CSI-SAFB-ccc-UFFR CSI-SAFE-ccc-UFFR

Vitreous Wirewound Resistors with Lugs

MONOCHRONICLE STRAIGHT

Include a copy of this document with each set of parts.

ECE 274 Digital Logic Spring Digital Design. Combinational Logic Design Process and Common Combinational Components Digital Design

Introduction to Medical Imaging. Signal Processing Basics. Strange Effects. Ever tried to reduce the size of an image and you got this?

Fubini for continuous functions over intervals

Lecture 16. Double integrals. Dan Nichols MATH 233, Spring 2018 University of Massachusetts.

ECE 274 Digital Logic. Digital Design. Datapath Components Shifters, Comparators, Counters, Multipliers Digital Design

WPCA AMEREN ESP. SEMINAR Understanding ESP Controls. By John Knapik. 2004, General Electric Company

Assembly Instructions for Model: VMAA18

The Math Learning Center PO Box 12929, Salem, Oregon Math Learning Center

Digital Signal Processing, Fall 2009

Transcription:

Rgistr Allotion Xio Ji April 25 th, 2012 1

Outlin Introution Grph oloring Linr sn 2

Introution Wnt to rpl tmporry vrils with som fix st of rgistrs 3

Introution Wnt to rpl tmporry vrils with som fix st of rgistrs W will jug this phs y Co rviw Limiting # of xut instrutions,.g. no grtr thn 1 million Compr: only 160,000 for my optimiz 8-qun 4

Grph oloring First: n to know whih vrils r liv ftr h instrution Two simultnously liv vrils nnot llot to th sm rgistr 5

Grph oloring For vry no n in CFG, w hv out[n] St of tmporris liv out of n Two vrils intrfr if Control Flow Grph oth initilly liv (i.. funtion rgumnts), or oth ppr in out[n] for ny n, or on is fin n th othr is in out[n] x = - whr x is & is liv intrfr How to ssign rgistrs to vrils? 6

Intrfrn grph 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 7

Intrfrn grph Instrutions Liv vrs = + 2 = * = + 1 rturn * 8

Intrfrn grph Instrutions Liv vrs = + 2 = * = + 1 rturn *, 9

Intrfrn grph Instrutions Liv vrs = + 2 = * = + 1 rturn *,, 10

Intrfrn grph Instrutions = + 2 = * = + 1 rturn * Liv vrs,,, 11

Intrfrn grph Instrutions = + 2 = * = + 1 rturn * Liv vrs,,, 12

Intrfrn grph olor rgistr Instrutions = + 2 = * = + 1 rturn * Liv vrs,,, $t1 $t2 13

Intrfrn grph olor rgistr Instrutions = + 2 = * = + 1 rturn * Liv vrs,,, $t1 $t2 14

Grph oloring Qustions: Cn w ffiintly fin oloring of th grph whnvr possil? Cn w ffiintly fin th optimum oloring of th grph? Wht o w o whn thr rn t nough olors (rgistrs) to olor th grph? 15

Coloring grph Kmp s lgorithm [1879] for fining K- oloring of grph Stp 1 (simplify): fin no with t most K-1 gs n ut it out of th grph. (Rmmr this no on stk for ltr stgs.) 16

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 17

Coloring olor rgistr $t1 $t2 stk: 18

Coloring olor rgistr $t1 $t2 stk: 19

Coloring olor rgistr $t1 $t2 stk: 20

Coloring olor rgistr $t1 $t2 stk: 21

Coloring olor rgistr $t1 $t2 stk: 22

Coloring olor rgistr $t1 $t2 stk: 23

Coloring olor rgistr $t1 $t2 stk: 24

Coloring olor rgistr $t1 $t2 stk: 25

Coloring olor rgistr $t1 $t2 stk: 26

Coloring olor rgistr $t1 $t2 stk: 27

Coloring olor rgistr $t1 $t2 stk: 28

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 29

Coloring olor rgistr $t1 $t2 stk: 30

Coloring olor rgistr $t1 $t2 stk: ll nos hv 2 nighours! 31

Coloring olor rgistr $t1 $t2 stk: 32

Coloring olor rgistr $t1 $t2 stk: 33

Coloring olor rgistr $t1 $t2 stk: 34

Coloring olor rgistr $t1 $t2 stk: 35

Coloring olor rgistr $t1 $t2 stk: 36

Coloring olor rgistr $t1 $t2 stk: 37

Coloring olor rgistr $t1 $t2 stk: W got luky! 38

Coloring olor rgistr $t1 $t2 Som grphs n t olor in K olors: stk: 39

Coloring olor rgistr $t1 $t2 Som grphs n t olor in K olors: stk: 40

Coloring olor rgistr $t1 $t2 Som grphs n t olor in K olors: stk: 41

Coloring olor rgistr $t1 $t2 Som grphs n t olor in K olors: stk: no olors lft for! 42

Spilling Stp 3 (spilling): on ll nos hv K or mor nighors, pik no for spilling Storg on th stk Thr r mny huristis tht n us to pik no not in n innr loop 43

Spilling o W n to gnrt xtr instrutions to lo vrils from stk n stor thm Ths instrutions us rgistrs thmslvs. Wht to o? Stupi pproh: lwys kp xtr rgistrs hny for shuffling t in n out: wht wst! Bttr pproh:? Dit rgistrs 44

Spilling o W n to gnrt xtr instrutions to lo vrils from stk n stor thm Ths instrutions us rgistrs thmslvs. Wht to o? Stupi pproh: lwys kp xtr rgistrs hny for shuffling t in n out: wht wst! Bttr pproh: rwrit o introuing nw tmporry; rrun livnss nlysis n rgistr llotion 45

Rwriting o Consir: t1, t1, t2 Suppos t2 is slt for spilling n ssign to stk lotion 24($fp) Introu nw tmporry t3 for just this instrution n rwrit: l t3, 24($fp) t1, t1, t3 Avntg: t3 hs vry short liv rng n is muh lss likly to intrfr. Rrun th lgorithm; fwr vrils will spill 46

Prolor Nos S Tigr ook for mor tils Som vrils r pr-ssign to rgistrs Frm pointr Argumnts ($0, $1, $2, $3) Funtion ll fins (trshs) llr-sv rgistrs Trt ths rgistrs s spil tmporris; for ginning, thm to th grph with thir olors 47

Prolor Nos S Tigr ook for mor tils Cn t simplify grph y rmoving prolor no Prolor nos r th strting point of th oloring pross On simplifi own to olor nos strt ing k th othr nos s for 48

Optimizing Movs Co gnrtion prous lot of xtr mov instrutions mov t1, t2 If w n ssign t1 n t2 to th sm rgistr, w o not hv to xut th mov I: if t1 n t2 r not onnt in th intrfrn grph, w ols into singl vril 49

Colsing Prolm: olsing n inrs th numr of intrfrn gs n mk grph unolorl ols t1 t2 t1/t2 Solution 1 (Briggs): voi rtion of high-gr (>= K) nos Solution 2 (Gorg): n ols with if vry nighour t of : lry intrfrs with, or hs low-gr (< K) 50

Simplify & Cols Stp 1 (simplify): simplify s muh s possil without rmoving nos tht r th sour or stintion of mov (mov-rlt nos) Stp 2 (ols): ols mov-rlt nos provi low-gr no rsults Stp 3 (frz): if nithr stps 1 or 2 pply, frz mov instrution: rgistrs involv r mrk not mov-rlt n try stp 1 gin 51

Ovrll Algorithm Simplify, frz n ols Livnss Mrk possil spills Color & tt tul spills Rwrit o to implmnt tul spills 52

Vritions My r pprs for mor vritions 53

Qustions? 54

Linr sn Givn th liv rngs of vrils in funtion, th lgorithm sns ll th liv rngs in singl pss, lloting rgistrs to vrils in gry fshion. M. Poltto, V. Srkr. Linr sn rgistr llotion. 1999. 55

56

57

58

Exmpl Initilly, tiv is mpty # of vill rgistrs is R = 2 59

Exmpl Stp 1: tiv =< A > # of vill rgistrs is R = 2 60

Exmpl Stp 2: tiv =< A, B > # of vill rgistrs is R = 2 61

Exmpl Stp 3: 3 liv intrvls ovrlp # of vill rgistrs is R = 2 62

Exmpl # of vill rgistrs is R = 2 Stp 3: 3 liv intrvls ovrlp spills C, whos intrvl ns furthst wy from th urrnt point tiv =< A, B > 63

Exmpl Stp 4: A xpirs tiv =< A, B, D > # of vill rgistrs is R = 2 64

Exmpl Stp 5: B xpirs tiv =< B, D, E > # of vill rgistrs is R = 2 65

Exmpl In th n, C is th only vril not llot to rgistr. # of vill rgistrs is R = 2 66

Exmpl In th n, C is th only vril not llot to rgistr. # of vill rgistrs is R = 2 Othrwis, oth on of A n B n on of D n E woul hv n spill to mmory. 67

Qustions? 68

Conlusion # of slis Grph oloring: ~50 Linr sn: ~10 69

Conlusion # of slis Grph oloring: ~50 Linr sn: ~10 Linr sn is muh mor simplr! Only out 10% slowr thn prftly implmnt grph oloring lgorithm An your o my not tht prft 70

Aknowlgmnts Grph oloring slis r pt from Rgistr Allotion y Dvi Wlkr Linr sn psuo-o n xmpl r pt from Linr Sn Rgistr Allotion y M. Poltto n V. Srkr. 71