lec03mod - CS415 Compilers Register Allocation These slides...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CS415 Compilers Register Allocation These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
Background image of page 1

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

View Full DocumentRight Arrow Icon
Lecture 3 2 cs415, spring 10 Review: Register Allocation Part of the compiler’s back end Critical properties Produce correct code that uses k (or fewer) registers Minimize added loads and stores Minimize space used to hold spilled values Operate efficiently O(n), O(n log 2 n), maybe O(n 2 ), but not O(2 n ) Errors IR Register Allocation Instruction Selection Machine code Instruction Scheduling m register IR k register IR
Background image of page 2
Lecture 3 3 cs415, spring 10 Memory Model / Code Shape register-register model Values that may safely reside in registers are assigned to a unique virtual register Register allocation/assignment maps virtual registers to limited set of physical registers Register allocation/assignment pass needed to make code “work” memory-memory model All values reside in memory, and are only kept in registers as briefly as possible (load operands from memory just before computation, perform computation, store result into memory) Register allocation/assignment has to try to identify cases where values can be safely kept in registers Safety verification is hard at the low level or program abstraction Even without register allocation/assignment, code will “work”
Background image of page 3

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

View Full DocumentRight Arrow Icon
Lecture 3 4 cs415, spring 10 Memory Model / Code Shape register-register model Values that may safely reside in registers are assigned to a unique virtual register Register allocation/assignment maps virtual registers to limited set of physical registers Register allocation/assignment pass needed to make code “work” memory-memory model All values reside in memory, and are only kept in registers as briefly as possible (load operands from memory just before computation, perform computation, store result into memory) Register allocation/assignment has to try to identify cases where values can be safely kept in registers Safety verification is hard at the low level or program abstraction Even without register allocation/assignment, code will “work” Will use this one from now on
Background image of page 4
Lecture 3 5 cs415, spring 10 Register Allocation Consider a fragment of assembly code (or ILOC ) loadI 2 r1 // r1 2 load AI r0, @y r2 // r2 y mult r1, r2 r3 // r3 2 · y loadAI r0, @x r4 // r4 x sub r4, r3 r5 // r5 x –(2 · y) The Problem At each instruction, decide which values to keep in registers Note: a value corresponds to a unique pseudo-register (code shape issue) Simple if |values| |physical registers| Harder if |values| > |physical registers|
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/29/2010 for the course CS 198:415 taught by Professor Kremer,u. during the Spring '10 term at Rutgers.

Page1 / 22

lec03mod - CS415 Compilers Register Allocation These slides...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online