Wrapping Up Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.

Slides:



Advertisements
Similar presentations
Compiler Support for Superscalar Processors. Loop Unrolling Assumption: Standard five stage pipeline Empty cycles between instructions before the result.
Advertisements

1 Code Optimization Code produced by compilation algorithms can often be improved (ideally optimized) in terms of run-time speed and the amount of memory.
The Last Lecture Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University have explicit permission.
Introduction to Code Optimization Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice.
Intermediate Representations Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Instruction Selection Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
The Procedure Abstraction Part I: Basics Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
From Cooper & Torczon1 Implications Must recognize legal (and illegal) programs Must generate correct code Must manage storage of all variables (and code)
Compiler Construction
Introduction to Optimization Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Introduction to Code Generation Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Instruction Selection Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Introduction & Overview CS4533 from Cooper & Torczon.
Overview of the Course. Critical Facts Welcome to CISC 672 — Advanced Compiler Construction Instructor: Dr. John Cavazos Office.
Invitation to Computer Science 5th Edition
Topic #10: Optimization EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
Introduction For some compiler, the intermediate code is a pseudo code of a virtual machine. Interpreter of the virtual machine is invoked to execute the.
Overview of the Course Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Overview of the Course Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Introduction to Optimization, II Value Numbering & Larger Scopes Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students.
Lexical Analysis - An Introduction Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at.
Lexical Analysis - An Introduction Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at.
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
Local Register Allocation & Lab Exercise 1 Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp.
Instruction Selection and Scheduling. The Problem Writing a compiler is a lot of work Would like to reuse components whenever possible Would like to automate.
May 31, May 31, 2016May 31, 2016May 31, 2016 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University Azusa Pacific University,
1 EECS 6083 Compiler Theory Based on slides from text web site: Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Overview of Compilers and JikesRVM John.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Introduction to Code Generation Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Compiler Introduction 1 Kavita Patel. Outlines 2  1.1 What Do Compilers Do?  1.2 The Structure of a Compiler  1.3 Compilation Process  1.4 Phases.
Compiler Construction Dr. Naveed Ejaz Lecture 4. 2 The Back End Register Allocation:  Have each value in a register when it is used. Instruction selection.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
Instruction Scheduling Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
1 Compiler Construction Vana Doufexi office CS dept.
CS510 Compiler Lecture 1. Sources Lecture Notes Book 1 : “Compiler construction principles and practice”, Kenneth C. Louden. Book 2 : “Compilers Principles,
Lecture 02: Compiler Overview Kwangman Man ( SangJi University.
Single Static Assignment Intermediate Representation (or SSA IR) Many examples and pictures taken from Wikipedia.
CHAPTER 1 INTRODUCTION TO COMPILER SUNG-DONG KIM, DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
Code Optimization Code produced by compilation algorithms can often be improved (ideally optimized) in terms of run-time speed and the amount of memory.
Advanced Computer Systems
Introduction to Optimization
Compiler Design (40-414) Main Text Book:
Code Optimization.
Local Register Allocation & Lab Exercise 1
Optimization Code Optimization ©SoftMoore Consulting.
Compiler Lecture 1 CS510.
Overview of the Course Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Local Instruction Scheduling
Lexical Analysis - An Introduction
Introduction to Optimization
Intermediate Representations
Introduction to Code Generation
Wrapping Up Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit.
Lecture 02: Compiler Overview
Instruction Scheduling: Beyond Basic Blocks
Intermediate Representations
The Last Lecture COMP 512 Rice University Houston, Texas Fall 2003
Overview of the Course Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Local Register Allocation & Lab Exercise 1
Introduction to Optimization
Lecture 16: Register Allocation
Compiler Construction
8 Code Generation Topics A simple code generator algorithm
Optimization 薛智文 (textbook ch# 9) 薛智文 96 Spring.
Compiler Construction
Compiler Construction
Presentation transcript:

Wrapping Up Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.

The Last Lecture High-level View Definitions Compiler consumes code & produces code Interpreter consumes executable & produces results Source code Machine code Compiler Errors

The Last Lecture High-level View Front end consumes source code & produces IR  Determines code shape for rest of compiler Middle reads & writes IR  Analyzes & transforms IR to “improve” it  Myriad techniques at several distinct scopes Back end consumes optimizes IR & produces target code  Maps code to target ISA & handles resource issues Errors Source Code Middle Front End Machine code Back End IR

The Last Lecture Front End Scanner Applies DFA technology to classify words Use RE-based tools to generate fast scanners Parser Takes stream of classified words & computes structure Many techniques (TDRD, LL(1), LR(1) + others) Context-sensitive Analysis Type-checking & IR generation (AGs & Ad-hoc SDT) Problems are harder & tools not as well developed Errors Source Code Middle Front End Machine code Back End IR Solved Problems

The Last Lecture Middle (Optimizer) Typically structured as a series of passes  Allows for separation of concerns  Simplifies development & debugging Rewrites IR to improve running time, code space, … We studied redundancy elimination  Other optimizations include code motion, dead-code elimination, constant propagation, strength reduction, … (see Ch 10) Errors Source Code Middle Front End Machine code Back End IR Most compilers need better optimization …

The Last Lecture Back End Errors Source Code Middle Front End Machine code Back End IR Three Problems Instruction Selection  Mapping optimized IR to target machine’s ISA Instruction Scheduling  Reordering operations to hide latencies & speed execution Register Allocation  Mapping name space of optimized IR to target’s register set

The Last Lecture Back End Errors Source Code Middle Front End Machine code Back End IR Instruction Selection This is a pattern-matching problem  We looked at tree pattern matching, peephole optimization  Other ideas: string matching, ad-hoc matching, parsing, … Criterion is “local optimality”  Map immediate context to ISA in an efficient way  Leave “global optimality” to optimizer My algorithm of choice: peephole matching

The Last Lecture Back End Errors Source Code Middle Front End Machine code Back End IR Instruction Scheduling Fixed set of operations, can vary the order  Must preserve inter-operation dependences  May change demand for registers List scheduling is dominant paradigm  Applied to blocks, extended blocks, regions in code My algorithm of choice: Schielke’s RBF algorithm on EBBs

The Last Lecture Back End Errors Source Code Middle Front End Machine code Back End IR Register Allocation Handle disconnect between optimizer’s assumption of unlimited registers and chip’s limited set  Insert loads and stores to reconcile the two models (spills)  Minimize the slowdown Global allocation via graph coloring is the dominant paradigm  Build interference graph and color it  Many minor variations, but one strong theme

The Last Lecture Perspective Different concerns in each phase Front end worries about shaping code for optimization  Expose facts that can be improved & tailored Middle worries about global issues that affect speed, space  Redundancy, constants, code motion, locality,... Back end worries about using the target’s resources  Address modes, functional units, registers, issue slots, … Errors Source Code Middle Front End Machine code Back End IR These concerns “bleed” from one phase to another

The Last Lecture Perspective Different complexities in each phase Front end is mostly linear time  DFAs, parsers take time proportional to size of input stream Middle is low-order polynomial time  Analysis & optimization are O(n) to O(n 2 ), in general Back end solves hard problems with approximations  Heuristics that typically take O(n) to (n 2 )  Underlying problems are seriously hard Errors Source Code Middle Front End Machine code Back End IR

The Last Lecture Perspective Remaining work Front end is solved  No more theses on parsing Middle has some room for work ( not a wide open frontier )  New machines, new languages present new problems Back end has room for work  Complications from new machines  Longer latencies, wider processors Errors Source Code Middle Front End Machine code Back End IR