registerAllocation - Register Allocation cs5363 1 Register...

Info icon This preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
cs5363 1 Register Allocation
Image of page 1

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

View Full Document Right Arrow Icon
cs5363 2 Register Allocation And Assignment Values in registers are easier and faster to access than memory Reserve a few registers for stack pointers, base addresses etc Efficiently utilize the rest of general-purpose registers Register allocation At each program point, select a set of values to reside in registers Register assignment Pick a specific register for each value, subject to hardware constraints Register classes: not all registers are equal Optimal register allocation/assignment in general are NP-complete Register assignment in many cases can be solved in polynomial time …… i := 0 s0: if i < 50 goto s1 goto s2 s1: t1 := b * 2 a := a + t1 goto s0 S2: … • Un-aliased calar variables i, a, b, t1 (can stay in registers) • Need to know how variables will be used after each statement. Live variable analysis
Image of page 2
cs5363 3 The Register Allocation Problem At each point of execution, a program may have an arbitrary number of live variables Only a subset may be kept in registers If a value cannot be kept in register, it must be stored in memory and loaded again when next needed spilling value to register Goal: make effective use of registers Minimize the number of loads and stores for spilling Register-to-register model Early translation stores all values in registers; select values to spill to memory later Memory-to-memory model Early translation stores all values in memory; promote values to register later Must decide which values do not require memory storage Register allocator Input program Output program Assumes infinite # of registers Uses registers on machine
Image of page 3

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

View Full Document Right Arrow Icon
cs5363 4 Local Register Allocation Allocating registers for a single basic block Assumes register-to-register memory model Input program assumes infinite # of registers Assume all registers on target machine are equivalent Two approaches Top-down: count the number of references to each value the most heavily used values should reside in registers Weakness: dedicate a register to a value for entire duration of the block Bottom-up: spill the value that is needed the latest
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern