CMSC 430 Introduction to Compilers. Spring Register Allocation

Size: px
Start display at page:

Download "CMSC 430 Introduction to Compilers. Spring Register Allocation"

Transcription

1 CMSC 430 Introuction to Compilers Spring 2016 Register Allocation

2 Introuction Change coe that uses an unoune set of virtual registers to coe that uses a finite set of actual regs For ytecoe targets, can let the JIT hanle this - Even with finite set of ytecoe regs that finite set is proaly large But critical for compiling to real harware Critical properties Prouce correct coe Minimize ae spill coe - The coe neee to move values etween registers an memory, that wasn t neee when assuming unoune set of registers - Memory operations are slow on moern processors Minimize space for spille registers Operate efficiently - E.g., not exponential in size of coe 2

3 Register allocation approaches Local allocation (within asic locks) In single forwar pass through lock, spill an loa regs as necessary (Coul also try to look at lock as a whole to etermine some etter allocation) Gloal allocation (across asic locks) Use graph coloring Local allocation is simple to implement But can introuce inefficiencies at lock ounaries Most compilers use graph-coloring ase gloal allocation 3

4 Spill coe Where shoul spille registers e store? Each instance of a function nees its own storage store on stack Can allocate space for spille regs in function prolog coe - Refer to reg storage using frame pointer - Nee to reserve feasile set of physical regs only for spilling Inserte spill coe Definition of a spille register rs - a rs, r2, r3 insert store n(%ep), rs afterwar Use of spille register rs - a rs, r2, r3 insert loa rs, n(%ep) efore 4

5 Instruction set For illustration purposes, we ll use the instruction set from coegen-*.ml Will write rn for register n type instr = ILoa of reg * src (* st, src *) IStore of st * reg (* st, src *) IMov of reg * reg (* st, src *) IA of reg * reg * reg (* st, src1, src2 *) IMul of reg * reg * reg (* st, src1, src2 *) IJmp of int (* pc offset *) IIfZero of reg * int (* src, pc offset *) IReturn 5

6 Live ranges A register is live Starting at its efinition (x...), inclusive Ening at the point it ecomes ea (y... x...), inclusive - Can represent as an interval [i,j] or live range within a lock - Also nee to know which regs live on exit Source coe ILoa r1, 42 IMov r2, r1 IMul r3, r1, r2 ILoa r4, 5 IA r5, r4, r2 ILoa r6, 8 IMul r7, r5, r6 IA r8, r7, r3 IA r1, r8, r1 IStore &1234, r1 Live regs (en of instr) r1 r1 r2 r1 r2 r3 r1 r2 r3 r4 r1 r3 r5 r1 r3 r5 r6 r1 r3 r7 r1 r8 r1 (none) 6

7 Local register allocation Algorithm Start with empty reg set Loa from memory into reg on eman When no reg availale, spill to free one - Nee policy on which reg to spill - Common approach: one whose next use is farthest in the future - Keep values use soon in registers - Similar to cache line / page replacement 7

8 Example One possile ottom-up allocation to 3 regs (ra-rc) Notice r1 spille to memory after first IMul Reg alloc (at exit) Source coe Live regs ra r rc ILoa r1, 42 r1 r1 IMov r2, r1 r1 r2 r1 r2 IMul r3, r1, r2 r1 r2 r3 r1 r2 r3 (spill r1 to memory) ILoa r4, 5 r1 r2 r3 r4 r4 r2 r3 IA r5, r4, r2 r1 r3 r5 r4 r2 r5 r3 ILoa r6, 8 r1 r3 r5 r6 r6 r5 r3 IMul r7, r5, r6 r1 r3 r7 r6 r5 r7 r3 IA r8, r7, r3 r1 r8 r6 r7 r8 r3 (loa r1 from memory) IA r1, r8, r1 r1 r1 r8 r3 IStore &1234, r1 (none) means oth neee in this instruction. 8

9 Example generate coe One possile ottom-up allocation to 3 regs (ra-rc) Notice r1 spille to memory after first IMul Reg alloc (at exit) Source coe Live regs ra r rc ILoa ra, 42 r1 r1 IMov r, ra r1 r2 r1 r2 IMul rc, ra, r r1 r2 r3 r1 r2 r3 (spill ra to memory for r1) ILoa ra, 5 r1 r2 r3 r4 r4 r2 r3 IA r, ra, r r1 r3 r5 r4 r2 r5 r3 ILoa ra, 8 r1 r3 r5 r6 r6 r5 r3 IMul r, r, ra r1 r3 r7 r6 r5 r7 r3 IA r, r, rc r1 r8 r6 r8 r3 (loa ra from memory for r1) IA ra, r, ra r1 r1 r8 r3 IStore &1234, ra (none) 9

10 Register reuse Note that in some cases, can reuse the same register as source an target in single instruction Namely, when one live range ens an another egins Source coe ILoa r1, 42 ILoa r2, 43 IMul r3, r1, r2 Live regs r1 r1 r2 (none) - Suppose r1 ra an r2 r - Then coul assign r3 to ra, r, or some other register In previous slie, wrote register reuse as r1 r2 - r1 is assigne at eginning of instruction, r2 at en 10

11 Gloal register allocation [Chaitin et al 1981] Definition: Graph coloring prolem Input: A graph G an an integer k - k is the numer of colors Output: an assignment of noes of G to colors such that - No noes that are connecte y an ege have the same color - The assignment uses at most k colors This prolem is NP-har for k > 2 Reuce register allocation to graph coloring Data flow analysis to fin live ranges of virtual registers Buil a color interference graph, where - Noes represent live ranges - Ege etween two noes inicates oth ranges live at some point Fin k coloring of graph, for k = # of physical regs - If unale to fin coloring, spill virtual regs an repeat 11

12 Live ranges All noes in CFG from efinition to use, inclusive Live ranges inicate when virtual registers shoul e in some physical reg to avoi spill coe (A single virtual register may comprise several live ranges) a live a = = a =... = = + a live a = = a a live 12

13 Builing the interference graph At each point p in the program A ege (x,y) for all pairs of live ranges x, y live at p a live a =... a live a = = a =... = = live... =... = a live a a 13

14 Graph coloring via simplification Algorithm Repeately remove noes with egree < k from graph - Push noes onto stack, removing from graph If every remaining noe is egree k - Spill noe with lowest spill cost - Use some heuristic to guess which virtual reg est to spill - Remove noe from graph - (Once spille, no longer causes interference) Reassemle graph with noes poppe from stack - Choose color iffering from neighors when ae to graph - Always possile since noe ha egree < k 14

15 Graph coloring example Assume 3 physical registers Simplify graph y removing noes with < 3 neighors a e e e e e c c Reassemle y popping noes from stack - Assigning colors not use y neighors a e e e e e c c 15

16 Graph coloring w/spill Assuming 2 physical registers No noe with < 2 neighors Must spill noe with lowest spill cost Remaining noes can then e simplifie an colore spill a c c c 16

17 Spill coe Here, we ve assume that spilling a removes it completely from live range But of course, the spill coe will nee to loa an store to register Thus, we either nee to - Recompute live ranges after we insert spill coe - Reserve a set of register that cannot e allocate to, ut that we will use to loa an store for spills 17

18 Discussion Gloal register allocation is an ol iea Material presente in these slies is just the eginning there s een lots of work coming up with etter variants Register pressure occurs when not enough physical registers availale, requiring spills Register allocation an optimization interact - If we optimize efore register alloc, might increase register pressure - E.g., y moving a computation earlier than it was efore, therey increasing live ranges - If we register alloc efore optimizing, might create false epenencies - E.g., reg alloc maps what are conceptually separate variales to the same physical register; coul confuse optimizer 18

Midterm 2. CMSC 430 Introduction to Compilers Spring Instructions Total 100. Name: April 18, 2012

Midterm 2. CMSC 430 Introduction to Compilers Spring Instructions Total 100. Name: April 18, 2012 Name: Midterm 2 CMSC 430 Introduction to Compilers Spring 2012 April 18, 2012 Instructions This exam contains 10 pages, including this one. Make sure you have all the pages. Write your name on the top

More information

Computer Organization

Computer Organization Computer Organization Douglas Comer Computer Science Department Purue University 250 N. University Street West Lafayette, IN 47907-2066 http://www.cs.purue.eu/people/comer Copyright 2006. All rights reserve.

More information

Compiler Optimisation

Compiler Optimisation Compiler Optimisation Michael O Boyle mob@inf.e.ac.uk Room 1.06 January, 2014 1 Two recommene books for the course Recommene texts Engineering a Compiler Engineering a Compiler by K. D. Cooper an L. Torczon.

More information

Midterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 11, 2015

Midterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 11, 2015 Name: Midterm 2 CMSC 430 Introduction to Compilers Fall 2015 November 11, 2015 Instructions This exam contains 8 pages, including this one. Make sure you have all the pages. Write your name on the top

More information

Fall Compiler Principles Lecture 12: Register Allocation. Roman Manevich Ben-Gurion University

Fall Compiler Principles Lecture 12: Register Allocation. Roman Manevich Ben-Gurion University Fall 2014-2015 Compiler Principles Lecture 12: Register Allocation Roman Manevich Ben-Gurion University Syllabus Front End Intermediate Representation Optimizations Code Generation Scanning Lowering Local

More information

Chapter 9 Memory Management

Chapter 9 Memory Management Contents 1. Introuction 2. Computer-System Structures 3. Operating-System Structures 4. Processes 5. Threas 6. CPU Scheuling 7. Process Synchronization 8. Dealocks 9. Memory Management 10.Virtual Memory

More information

Midterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 20, 2013

Midterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 20, 2013 Name: Midterm 2 CMSC 430 Introduction to Compilers Fall 2013 November 20, 2013 Instructions This exam contains 9 pages, including this one. Make sure you have all the pages. Write your name on the top

More information

Midterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 19, 2014

Midterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 19, 2014 Name: Midterm 2 CMSC 430 Introduction to Compilers Fall 2014 November 19, 2014 Instructions This exam contains 10 pages, including this one. Make sure you have all the pages. Write your name on the top

More information

Just-In-Time Software Pipelining

Just-In-Time Software Pipelining Just-In-Time Software Pipelining Hongbo Rong Hyunchul Park Youfeng Wu Cheng Wang Programming Systems Lab Intel Labs, Santa Clara What is software pipelining? A loop optimization exposing instruction-level

More information

Register Allocation. Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP 412 at Rice.

Register Allocation. Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP 412 at Rice. Register Allocation Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP at Rice. Copyright 00, Keith D. Cooper & Linda Torczon, all rights reserved.

More information

register allocation saves energy register allocation reduces memory accesses.

register allocation saves energy register allocation reduces memory accesses. Lesson 10 Register Allocation Full Compiler Structure Embedded systems need highly optimized code. This part of the course will focus on Back end code generation. Back end: generation of assembly instructions

More information

Register Allocation III. Interference Graph Allocators. Coalescing. Granularity of Allocation (Renumber step in Briggs) Chaitin

Register Allocation III. Interference Graph Allocators. Coalescing. Granularity of Allocation (Renumber step in Briggs) Chaitin Register Alloation III Last time Register alloation aross funtion alls Toay Register alloation options Interferene Graph Alloators Chaitin Briggs CS553 Leture Register Alloation III 1 CS553 Leture Register

More information

Generalized Edge Coloring for Channel Assignment in Wireless Networks

Generalized Edge Coloring for Channel Assignment in Wireless Networks TR-IIS-05-021 Generalize Ege Coloring for Channel Assignment in Wireless Networks Chun-Chen Hsu, Pangfeng Liu, Da-Wei Wang, Jan-Jan Wu December 2005 Technical Report No. TR-IIS-05-021 http://www.iis.sinica.eu.tw/lib/techreport/tr2005/tr05.html

More information

Compiler Design. Register Allocation. Hwansoo Han

Compiler Design. Register Allocation. Hwansoo Han Compiler Design Register Allocation Hwansoo Han Big Picture of Code Generation Register allocation Decides which values will reside in registers Changes the storage mapping Concerns about placement of

More information

Message Transport With The User Datagram Protocol

Message Transport With The User Datagram Protocol Message Transport With The User Datagram Protocol User Datagram Protocol (UDP) Use During startup For VoIP an some vieo applications Accounts for less than 10% of Internet traffic Blocke by some ISPs Computer

More information

Register Allocation III. Interference Graph Allocators. Computing the Interference Graph (in MiniJava compiler)

Register Allocation III. Interference Graph Allocators. Computing the Interference Graph (in MiniJava compiler) Register Alloation III Announements Reommen have interferene graph onstrution working by Monay Last leture Register alloation aross funtion alls Toay Register alloation options Interferene Graph Alloators

More information

Register Allocation (via graph coloring) Lecture 25. CS 536 Spring

Register Allocation (via graph coloring) Lecture 25. CS 536 Spring Register Allocation (via graph coloring) Lecture 25 CS 536 Spring 2001 1 Lecture Outline Memory Hierarchy Management Register Allocation Register interference graph Graph coloring heuristics Spilling Cache

More information

Preamble. Singly linked lists. Collaboration policy and academic integrity. Getting help

Preamble. Singly linked lists. Collaboration policy and academic integrity. Getting help CS2110 Spring 2016 Assignment A. Linke Lists Due on the CMS by: See the CMS 1 Preamble Linke Lists This assignment begins our iscussions of structures. In this assignment, you will implement a structure

More information

Topic 12: Register Allocation

Topic 12: Register Allocation Topic 12: Register Allocation COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Structure of backend Register allocation assigns machine registers (finite supply!) to virtual

More information

Register allocation. Overview

Register allocation. Overview Register allocation Register allocation Overview Variables may be stored in the main memory or in registers. { Main memory is much slower than registers. { The number of registers is strictly limited.

More information

Prelim 1. Solution. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer

Prelim 1. Solution. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer Prelim 1. Solution CS 2110, 14 March 2017, 7:30 PM 1 2 3 4 5 Total Question Name Short answer OO Recursion Loop invariants Max 1 36 33 15 15 100 Score Grader 1. Name (1 point) Write your name and NetID

More information

You Can Do That. Unit 16. Motivation. Computer Organization. Computer Organization Design of a Simple Processor. Now that you have some understanding

You Can Do That. Unit 16. Motivation. Computer Organization. Computer Organization Design of a Simple Processor. Now that you have some understanding .. ou Can Do That Unit Computer Organization Design of a imple Clou & Distribute Computing (CyberPhysical, bases, Mining,etc.) Applications (AI, Robotics, Graphics, Mobile) ystems & Networking (Embee ystems,

More information

Virtual Memory: Policies. CS439: Principles of Computer Systems March 5, 2018

Virtual Memory: Policies. CS439: Principles of Computer Systems March 5, 2018 Virtual Memory: Policies CS439: Principles of Computer Systems March 5, 28 Last Time Overlays Paging Pages Page frames Address translation Today s Agenda Paging: Mechanisms Page Tales Page Faults Paging:

More information

Register Allocation 1

Register Allocation 1 Register Allocation 1 Lecture Outline Memory Hierarchy Management Register Allocation Register interference graph Graph coloring heuristics Spilling Cache Management The Memory Hierarchy Registers < 1

More information

Register Allocation. Lecture 38

Register Allocation. Lecture 38 Register Allocation Lecture 38 (from notes by G. Necula and R. Bodik) 4/27/08 Prof. Hilfinger CS164 Lecture 38 1 Lecture Outline Memory Hierarchy Management Register Allocation Register interference graph

More information

Generalized Edge Coloring for Channel Assignment in Wireless Networks

Generalized Edge Coloring for Channel Assignment in Wireless Networks Generalize Ege Coloring for Channel Assignment in Wireless Networks Chun-Chen Hsu Institute of Information Science Acaemia Sinica Taipei, Taiwan Da-wei Wang Jan-Jan Wu Institute of Information Science

More information

Politehnica University of Timisoara Mobile Computing, Sensors Network and Embedded Systems Laboratory. Testing Techniques

Politehnica University of Timisoara Mobile Computing, Sensors Network and Embedded Systems Laboratory. Testing Techniques Politehnica University of Timisoara Mobile Computing, Sensors Network an Embee Systems Laboratory ing Techniques What is testing? ing is the process of emonstrating that errors are not present. The purpose

More information

6.823 Computer System Architecture. Problem Set #3 Spring 2002

6.823 Computer System Architecture. Problem Set #3 Spring 2002 6.823 Computer System Architecture Problem Set #3 Spring 2002 Stuents are strongly encourage to collaborate in groups of up to three people. A group shoul han in only one copy of the solution to the problem

More information

PART 5. Process Coordination And Synchronization

PART 5. Process Coordination And Synchronization PART 5 Process Coorination An Synchronization CS 503 - PART 5 1 2010 Location Of Process Coorination In The Xinu Hierarchy CS 503 - PART 5 2 2010 Coorination Of Processes Necessary in a concurrent system

More information

Outline. Register Allocation. Issues. Storing values between defs and uses. Issues. Issues P3 / 2006

Outline. Register Allocation. Issues. Storing values between defs and uses. Issues. Issues P3 / 2006 P3 / 2006 Register Allocation What is register allocation Spilling More Variations and Optimizations Kostis Sagonas 2 Spring 2006 Storing values between defs and uses Program computes with values value

More information

Global Register Allocation

Global Register Allocation Global Register Allocation Y N Srikant Computer Science and Automation Indian Institute of Science Bangalore 560012 NPTEL Course on Compiler Design Outline n Issues in Global Register Allocation n The

More information

The C2 Register Allocator. Niclas Adlertz

The C2 Register Allocator. Niclas Adlertz The C2 Register Allocator Niclas Adlertz 1 1 Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated

More information

Unit 15. Building Wide Muxes. Building Wide Muxes. Common Hardware Components WIDE MUXES

Unit 15. Building Wide Muxes. Building Wide Muxes. Common Hardware Components WIDE MUXES 5. 5.2 Unit 5 Common Harware Components WIE MUXE 5.3 5.4 Builing Wie Muxes Builing Wie Muxes o far muxesonly have single bit inputs I is only -bit I is only -bit What if we still want to select between

More information

Almost Disjunct Codes in Large Scale Multihop Wireless Network Media Access Control

Almost Disjunct Codes in Large Scale Multihop Wireless Network Media Access Control Almost Disjunct Coes in Large Scale Multihop Wireless Network Meia Access Control D. Charles Engelhart Anan Sivasubramaniam Penn. State University University Park PA 682 engelhar,anan @cse.psu.eu Abstract

More information

Register allocation. Register allocation: ffl have value in a register when used. ffl limited resources. ffl changes instruction choices

Register allocation. Register allocation: ffl have value in a register when used. ffl limited resources. ffl changes instruction choices Register allocation IR instruction selection register allocation machine code errors Register allocation: have value in a register when used limited resources changes instruction choices can move loads

More information

Midterm 2. CMSC 430 Introduction to Compilers Fall 2018

Midterm 2. CMSC 430 Introduction to Compilers Fall 2018 Name: Directory ID: University ID: Midterm 2 CMSC 430 Introduction to Compilers Fall 2018 Instructions This exam contains 14 pages, including this one. Make sure you have all the pages. Write your name,

More information

Register Allocation. Global Register Allocation Webs and Graph Coloring Node Splitting and Other Transformations

Register Allocation. Global Register Allocation Webs and Graph Coloring Node Splitting and Other Transformations Register Allocation Global Register Allocation Webs and Graph Coloring Node Splitting and Other Transformations Copyright 2015, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class

More information

Register allocation. TDT4205 Lecture 31

Register allocation. TDT4205 Lecture 31 1 Register allocation TDT4205 Lecture 31 2 Variables vs. registers TAC has any number of variables Assembly code has to deal with memory and registers Compiler back end must decide how to juggle the contents

More information

Abstract Interpretation Continued

Abstract Interpretation Continued Abstract Interpretation Continued Height of Lattice: Length of Max. Chain height=5 size=14 T height=2 size = T -2-1 0 1 2 Chain of Length n A set of elements x 0,x 1,..., x n in D that are linearly ordered,

More information

Global Register Allocation - Part 2

Global Register Allocation - Part 2 Global Register Allocation - Part 2 Y N Srikant Computer Science and Automation Indian Institute of Science Bangalore 560012 NPTEL Course on Compiler Design Outline Issues in Global Register Allocation

More information

Global Register Allocation via Graph Coloring

Global Register Allocation via Graph Coloring Global Register Allocation via Graph Coloring Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission

More information

PART 2. Organization Of An Operating System

PART 2. Organization Of An Operating System PART 2 Organization Of An Operating System CS 503 - PART 2 1 2010 Services An OS Supplies Support for concurrent execution Facilities for process synchronization Inter-process communication mechanisms

More information

Global Register Allocation - Part 3

Global Register Allocation - Part 3 Global Register Allocation - Part 3 Y N Srikant Computer Science and Automation Indian Institute of Science Bangalore 560012 NPTEL Course on Compiler Design Outline Issues in Global Register Allocation

More information

Introduction to Machine Learning Spring 2018 Note Sparsity and LASSO. 1.1 Sparsity for SVMs

Introduction to Machine Learning Spring 2018 Note Sparsity and LASSO. 1.1 Sparsity for SVMs CS 189 Introduction to Machine Learning Spring 2018 Note 21 1 Sparsity and LASSO 1.1 Sparsity for SVMs Recall the oective function of the soft-margin SVM prolem: w,ξ 1 2 w 2 + C Note that if a point x

More information

An ECA-based Control-rule formalism for the BPEL Process Modularization *

An ECA-based Control-rule formalism for the BPEL Process Modularization * Availale online at www.scienceirect.com Proceia Environmental Sciences 11 (2011) 511 517 An ECA-ase Control-rule formalism for the BPEL Process Moularization * Bang Ouyang, Farong Zhong **, Huan Liu Department

More information

Register allocation. instruction selection. machine code. register allocation. errors

Register allocation. instruction selection. machine code. register allocation. errors Register allocation IR instruction selection register allocation machine code errors Register allocation: have value in a register when used limited resources changes instruction choices can move loads

More information

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science. EECS150, Spring 2010

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science. EECS150, Spring 2010 University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science EECS10, Spring 010 Homework Assignment 7 Solutions: Memories and Video 1. Your task

More information

Today's Topics. CISC 458 Winter J.R. Cordy

Today's Topics. CISC 458 Winter J.R. Cordy Today's Topics Last Time Semantics - the meaning of program structures Stack model of expression evaluation, the Expression Stack (ES) Stack model of automatic storage, the Run Stack (RS) Today Managing

More information

Multilevel Paging. Multilevel Paging Translation. Paging Hardware With TLB 11/13/2014. CS341: Operating System

Multilevel Paging. Multilevel Paging Translation. Paging Hardware With TLB 11/13/2014. CS341: Operating System CS341: Operating System Lect31: 21 st Oct 2014 Dr A Sahu Dept o Comp Sc & Engg Inian Institute o Technology Guwahati ain Contiguous Allocation, Segmentation, Paging Page Table an TLB Paging : Larger Page

More information

Code generation for modern processors

Code generation for modern processors Code generation for modern processors Definitions (1 of 2) What are the dominant performance issues for a superscalar RISC processor? Refs: AS&U, Chapter 9 + Notes. Optional: Muchnick, 16.3 & 17.1 Instruction

More information

Code generation for modern processors

Code generation for modern processors Code generation for modern processors What are the dominant performance issues for a superscalar RISC processor? Refs: AS&U, Chapter 9 + Notes. Optional: Muchnick, 16.3 & 17.1 Strategy il il il il asm

More information

CS 188: Artificial Intelligence Fall Search Gone Wrong?

CS 188: Artificial Intelligence Fall Search Gone Wrong? CS 188: Artificial Intelligence Fall 2009 Lecture 3: A* Search 9/3/2009 Pieter Aeel UC Berkeley Many slides from Dan Klein Search Gone Wrong? 1 Announcements Assignments: Project 0 (Python tutorial): due

More information

Global Register Allocation - 2

Global Register Allocation - 2 Global Register Allocation - 2 Y N Srikant Computer Science and Automation Indian Institute of Science Bangalore 560012 NPTEL Course on Principles of Compiler Design Outline n Issues in Global Register

More information

Array Dependence Analysis as Integer Constraints. Array Dependence Analysis Example. Array Dependence Analysis as Integer Constraints, cont

Array Dependence Analysis as Integer Constraints. Array Dependence Analysis Example. Array Dependence Analysis as Integer Constraints, cont Theory of Integers CS389L: Automated Logical Reasoning Omega Test Işıl Dillig Earlier, we talked aout the theory of integers T Z Signature of T Z : Σ Z : {..., 2, 1, 0, 1, 2,..., 3, 2, 2, 3,..., +,, =,

More information

Prelim 1. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader

Prelim 1. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader Prelim 1 CS 2110, 14 March 2017, 7:30 PM 1 2 3 4 5 Total Question Name Short answer OO Recursion Loop invariants Max 1 36 33 15 15 100 Score Grader The exam is closed ook and closed notes. Do not egin

More information

CS 406/534 Compiler Construction Putting It All Together

CS 406/534 Compiler Construction Putting It All Together CS 406/534 Compiler Construction Putting It All Together Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy

More information

NEWTON METHOD and HP-48G

NEWTON METHOD and HP-48G NEWTON METHOD an HP-48G DE TING WU DEPART. of MATH. MOREHOUSE COLLEGE I. Introuction Newton metho is an often-use proceure to fin the approximate values of the solutions of an equation. Now, it is covere

More information

Topics Introduction to Microprocessors

Topics Introduction to Microprocessors Topics 22440 Introduction to Microprocessors C-Language Review (I) Important: : You will not learn how to code in C in this one lecture! You ll still need some sort of C reference. C Syntax Important Tidits

More information

T Parallel and Distributed Systems (4 ECTS)

T Parallel and Distributed Systems (4 ECTS) T 79.4301 Parallel and Distriuted Systems (4 ECTS) T 79.4301 Rinnakkaiset ja hajautetut järjestelmät (4 op) Lecture 4 11th of Feruary 2008 Keijo Heljanko Keijo.Heljanko@tkk.fi T 79.4301 Parallel and Distriuted

More information

Register Allocation. CS 502 Lecture 14 11/25/08

Register Allocation. CS 502 Lecture 14 11/25/08 Register Allocation CS 502 Lecture 14 11/25/08 Where we are... Reasonably low-level intermediate representation: sequence of simple instructions followed by a transfer of control. a representation of static

More information

Register Allocation. Lecture 16

Register Allocation. Lecture 16 Register Allocation Lecture 16 1 Register Allocation This is one of the most sophisticated things that compiler do to optimize performance Also illustrates many of the concepts we ve been discussing in

More information

Theory of Integers. CS389L: Automated Logical Reasoning. Lecture 13: The Omega Test. Overview of Techniques. Geometric Description

Theory of Integers. CS389L: Automated Logical Reasoning. Lecture 13: The Omega Test. Overview of Techniques. Geometric Description Theory of ntegers This lecture: Decision procedure for qff theory of integers CS389L: Automated Logical Reasoning Lecture 13: The Omega Test şıl Dillig As in previous two lectures, we ll consider T Z formulas

More information

Lecture 25: Register Allocation

Lecture 25: Register Allocation Lecture 25: Register Allocation [Adapted from notes by R. Bodik and G. Necula] Topics: Memory Hierarchy Management Register Allocation: Register interference graph Graph coloring heuristics Spilling Cache

More information

Recitation Caches and Blocking. 4 March 2019

Recitation Caches and Blocking. 4 March 2019 15-213 Recitation Caches an Blocking 4 March 2019 Agena Reminers Revisiting Cache Lab Caching Review Blocking to reuce cache misses Cache alignment Reminers Due Dates Cache Lab (Thursay 3/7) Miterm Exam

More information

Register Allocation 3/16/11. What a Smart Allocator Needs to Do. Global Register Allocation. Global Register Allocation. Outline.

Register Allocation 3/16/11. What a Smart Allocator Needs to Do. Global Register Allocation. Global Register Allocation. Outline. What a Smart Allocator Needs to Do Register Allocation Global Register Allocation Webs and Graph Coloring Node Splitting and Other Transformations Determine ranges for each variable can benefit from using

More information

Proving Vizing s Theorem with Rodin

Proving Vizing s Theorem with Rodin Proving Vizing s Theorem with Roin Joachim Breitner March 25, 2011 Proofs for Vizing s Theorem t to be unwiely unless presente in form a constructive algorithm with a proof of its correctness an termination.

More information

Introduction to Optimization, Instruction Selection and Scheduling, and Register Allocation

Introduction to Optimization, Instruction Selection and Scheduling, and Register Allocation Introduction to Optimization, Instruction Selection and Scheduling, and Register Allocation Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Traditional Three-pass Compiler

More information

Computer Architecture

Computer Architecture Computer Architecture Chapter 2 Instructions: Language of the Computer Fall 2005 Department of Computer Science Kent State University Assembly Language Encodes machine instructions using symbols and numbers

More information

Additional Divide and Conquer Algorithms. Skipping from chapter 4: Quicksort Binary Search Binary Tree Traversal Matrix Multiplication

Additional Divide and Conquer Algorithms. Skipping from chapter 4: Quicksort Binary Search Binary Tree Traversal Matrix Multiplication Aitional Divie an Conquer Algorithms Skipping from chapter 4: Quicksort Binary Search Binary Tree Traversal Matrix Multiplication Divie an Conquer Closest Pair Let s revisit the closest pair problem. Last

More information

MODULE VII. Emerging Technologies

MODULE VII. Emerging Technologies MODULE VII Emerging Technologies Computer Networks an Internets -- Moule 7 1 Spring, 2014 Copyright 2014. All rights reserve. Topics Software Define Networking The Internet Of Things Other trens in networking

More information

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed. Preface Here are my online notes for my Calculus I course that I teach here at Lamar University. Despite the fact that these are my class notes, they shoul be accessible to anyone wanting to learn Calculus

More information

Simple Machine Model. Lectures 14 & 15: Instruction Scheduling. Simple Execution Model. Simple Execution Model

Simple Machine Model. Lectures 14 & 15: Instruction Scheduling. Simple Execution Model. Simple Execution Model Simple Machine Model Fall 005 Lectures & 5: Instruction Scheduling Instructions are executed in sequence Fetch, decode, execute, store results One instruction at a time For branch instructions, start fetching

More information

1 Disjoint-set data structure.

1 Disjoint-set data structure. CS 124 Setion #4 Union-Fin, Greey Algorithms 2/20/17 1 Disjoint-set ata struture. 1.1 Operations Disjoint-set ata struture enale us to effiiently perform operations suh as plaing elements into sets, querying

More information

Binary Decision Diagrams (BDDs) Pingqiang Zhou ShanghaiTech University

Binary Decision Diagrams (BDDs) Pingqiang Zhou ShanghaiTech University Binary Decision Diagrams (BDDs) Pingqiang Zhou ShanghaiTech University Computational Boolean Algera Representations Applying unate recursive paradigm (URP) in solving tautology is a great warm up example.

More information

CS 106 Winter 2016 Craig S. Kaplan. Module 01 Processing Recap. Topics

CS 106 Winter 2016 Craig S. Kaplan. Module 01 Processing Recap. Topics CS 106 Winter 2016 Craig S. Kaplan Moule 01 Processing Recap Topics The basic parts of speech in a Processing program Scope Review of syntax for classes an objects Reaings Your CS 105 notes Learning Processing,

More information

TENTAMEN / EXAM. General instructions

TENTAMEN / EXAM. General instructions Linköpings universitet IDA Department of Computer and Information Sciences Prof. Peter Fritzson and Doc. Christoph Kessler TENTAMEN / EXAM TDDB29 Kompilatorer och interpretatorer / Compilers and interpreters

More information

CHAPTER 3. Register allocation

CHAPTER 3. Register allocation CHAPTER 3 Register allocation In chapter 1 we simplified the generation of x86 assembly by placing all variables on the stack. We can improve the performance of the generated code considerably if we instead

More information

Low-level optimization

Low-level optimization Low-level optimization Advanced Course on Compilers Spring 2015 (III-V): Lecture 6 Vesa Hirvisalo ESG/CSE/Aalto Today Introduction to code generation finding the best translation Instruction selection

More information

What Compilers Can and Cannot Do. Saman Amarasinghe Fall 2009

What Compilers Can and Cannot Do. Saman Amarasinghe Fall 2009 What Compilers Can and Cannot Do Saman Amarasinghe Fall 009 Optimization Continuum Many examples across the compilation pipeline Static Dynamic Program Compiler Linker Loader Runtime System Optimization

More information

Overview. Operating Systems I. Simple Memory Management. Simple Memory Management. Multiprocessing w/fixed Partitions.

Overview. Operating Systems I. Simple Memory Management. Simple Memory Management. Multiprocessing w/fixed Partitions. Overview Operating Systems I Management Provie Services processes files Manage Devices processor memory isk Simple Management One process in memory, using it all each program nees I/O rivers until 96 I/O

More information

Memory Usage 0x7fffffff. stack. dynamic data. static data 0x Code Reserved 0x x A software convention

Memory Usage 0x7fffffff. stack. dynamic data. static data 0x Code Reserved 0x x A software convention Subroutines Why we use subroutines more modular program (small routines, outside data passed in) more readable, easier to debug code reuse i.e. smaller code space Memory Usage A software convention stack

More information

Efficient and Scalable Sequence-Based XML Filtering

Efficient and Scalable Sequence-Based XML Filtering Efficient an Scalale Sequence-Base XML Filtering Mariam Salloum University of California, Riversie, CA, USA msalloum@cs.ucr.eu ABSTRACT The uiquitous aoption of XML as the stanar of ata exchange over the

More information

Project 3 Due October 21, 2015, 11:59:59pm

Project 3 Due October 21, 2015, 11:59:59pm Project 3 Due October 21, 2015, 11:59:59pm 1 Introduction In this project, you will implement RubeVM, a virtual machine for a simple bytecode language. Later in the semester, you will compile Rube (a simplified

More information

CSc 453 Interpreters & Interpretation

CSc 453 Interpreters & Interpretation CSc 453 Interpreters & Interpretation Saumya Debray The University of Arizona Tucson Interpreters An interpreter is a program that executes another program. An interpreter implements a virtual machine,

More information

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands Stored Program Concept nstructions: nstructions are bits Programs are stored in memory to be read or written just like data Processor Memory memory for data, programs, compilers, editors, etc. Fetch &

More information

Bottom Up Parsing. Shift and Reduce. Sentential Form. Handle. Parse Tree. Bottom Up Parsing 9/26/2012. Also known as Shift-Reduce parsing

Bottom Up Parsing. Shift and Reduce. Sentential Form. Handle. Parse Tree. Bottom Up Parsing 9/26/2012. Also known as Shift-Reduce parsing Also known as Shift-Reduce parsing More powerful than top down Don t need left factored grammars Can handle left recursion Attempt to construct parse tree from an input string eginning at leaves and working

More information

Variables vs. Registers/Memory. Simple Approach. Register Allocation. Interference Graph. Register Allocation Algorithm CS412/CS413

Variables vs. Registers/Memory. Simple Approach. Register Allocation. Interference Graph. Register Allocation Algorithm CS412/CS413 Variables vs. Registers/Memory CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 33: Register Allocation 18 Apr 07 Difference between IR and assembly code: IR (and abstract assembly) manipulate

More information

CSC 2400: Computer Systems. Using the Stack for Function Calls

CSC 2400: Computer Systems. Using the Stack for Function Calls CSC 24: Computer Systems Using the Stack for Function Calls Lecture Goals Challenges of supporting functions! Providing information for the called function Function arguments and local variables! Allowing

More information

Assembly Language: Function Calls

Assembly Language: Function Calls Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems: Calling and returning Passing parameters Storing local variables Handling registers without interference

More information

1 Model checking and equivalence checking

1 Model checking and equivalence checking 978--52-85972- - Practical Design Verification Model checking and equivalence checking Masahiro Fujita. Introduction Owing to the advances in semiconductor technology, a large and complex system that has

More information

L4: Binary Decision Diagrams. Reading material

L4: Binary Decision Diagrams. Reading material L4: Binary Decision Diagrams de Micheli pp. 75-85 Reading material R. Bryant, Graph-ased algorithms for Boolean function manipulation, IEEE Transactions on computers, C-35, No 8, August 1986; can e downloaded

More information

Compilation /17a Lecture 10. Register Allocation Noam Rinetzky

Compilation /17a Lecture 10. Register Allocation Noam Rinetzky Compilation 0368-3133 2016/17a Lecture 10 Register Allocation Noam Rinetzky 1 What is a Compiler? 2 Registers Dedicated memory locations that can be accessed quickly, can have computations performed on

More information

Assembly Language: Function Calls" Goals of this Lecture"

Assembly Language: Function Calls Goals of this Lecture Assembly Language: Function Calls" 1 Goals of this Lecture" Help you learn:" Function call problems:" Calling and returning" Passing parameters" Storing local variables" Handling registers without interference"

More information

CHAPTER 3. Register allocation

CHAPTER 3. Register allocation CHAPTER 3 Register allocation In chapter 1 we simplified the generation of x86 assembly by placing all variables on the stack. We can improve the performance of the generated code considerably if we instead

More information

Assembly Language: Function Calls. Goals of this Lecture. Function Call Problems

Assembly Language: Function Calls. Goals of this Lecture. Function Call Problems Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems: Calling and urning Passing parameters Storing local variables Handling registers without interference Returning

More information

Hot X: Algebra Exposed

Hot X: Algebra Exposed Hot X: Algera Exposed Solution Guide for Chapter 5 Here are the solutions for the Doing the Math exercises in Hot X: Algera Exposed! (assume that all denominators 0) DTM from p.59 2. Since they have the

More information

Assembly Language: Function Calls" Goals of this Lecture"

Assembly Language: Function Calls Goals of this Lecture Assembly Language: Function Calls" 1 Goals of this Lecture" Help you learn:" Function call problems:" Calling and urning" Passing parameters" Storing local variables" Handling registers without interference"

More information

Compiler Architecture

Compiler Architecture Code Generation 1 Compiler Architecture Source language Scanner (lexical analysis) Tokens Parser (syntax analysis) Syntactic structure Semantic Analysis (IC generator) Intermediate Language Code Optimizer

More information

Loop Scheduling and Partitions for Hiding Memory Latencies

Loop Scheduling and Partitions for Hiding Memory Latencies Loop Scheuling an Partitions for Hiing Memory Latencies Fei Chen Ewin Hsing-Mean Sha Dept. of Computer Science an Engineering University of Notre Dame Notre Dame, IN 46556 Email: fchen,esha @cse.n.eu Tel:

More information

Spanheight, A Natural Extension of Bandwidth and Treedepth

Spanheight, A Natural Extension of Bandwidth and Treedepth Master s Thesis Spanheight, A Natural Extension of Banwith an Treeepth Author: N. van Roen Supervisor: Prof. r. Hans. L. Bolaener A thesis sumitte in fulfilment of the requirements for the egree of Master

More information