Greg MorrisettFall 2013.  Compilers.  (duh)  Translating one programming language into another.  Also interpreters.  Translating and running a language.

Slides:



Advertisements
Similar presentations
Compilers Course 379K, TTH 9:30-11:00 Instructor: Dr. Doron A. Peled Office Hours: Mon 11:00-12:00.
Advertisements

Introduction to Compiler Construction
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
Goran Šuković, University of Montenegro 1/21 Compiler Construction Course at University of Montenegro 7 th Workshop on “Software Engineering Education.
Lecture 01 - Introduction Eran Yahav 1. 2 Who? Eran Yahav Taub 734 Tel: Monday 13:30-14:30
Cpeg421-08S/final-review1 Course Review Tom St. John.
CS 536 Spring Intermediate Code. Local Optimizations. Lecture 22.
1 Semantic Processing. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
Cse321, Programming Languages and Compilers 1 6/19/2015 Lecture #18, March 14, 2007 Syntax directed translations, Meanings of programs, Rules for writing.
January 12, Compiler Design Hongwei Xi Comp. Sci. Dept. Boston University.
Compiler Construction
Intermediate Code. Local Optimizations
Compiler Construction A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University Second Semester 2008/2009.
BİL744 Derleyici Gerçekleştirimi (Compiler Design)1.
CMPUT Compiler Design and Optimization1 CMPUT680 - Winter 2006 Topic0: Introduction José Nelson Amaral
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
September 7, September 7, 2015September 7, 2015September 7, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University.
9/18/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
COP4020 Programming Languages
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2011 Course Overview John Cavazos University.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 10, 10/30/2003 Prof. Roy Levow.
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.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Topic #1: Introduction EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Introduction to Compiling
Introduction CPSC 388 Ellen Walker Hiram College.
Compiler Construction (CS-636)
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.
1 Compiler & its Phases Krishan Kumar Asstt. Prof. (CSE) BPRCE, Gohana.
What is a compiler? –A program that reads a program written in one language (source language) and translates it into an equivalent program in another language.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
CSC 4181 Compiler Construction
©SoftMoore ConsultingSlide 1 Structure of Compilers.
CSC 8505 Compiler Construction
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 10 Ahmed Ezzat.
1 Compiler Construction Vana Doufexi office CS dept.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
CS416 Compiler Design1. 2 Course Information Instructor : Dr. Ilyas Cicekli –Office: EA504, –Phone: , – Course Web.
CS510 Compiler Lecture 1. Sources Lecture Notes Book 1 : “Compiler construction principles and practice”, Kenneth C. Louden. Book 2 : “Compilers Principles,
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Prologue Sung-Dong Kim, Dept. of Computer Engineering, Hansung University.
©SoftMoore ConsultingSlide 1 Code Optimization. ©SoftMoore ConsultingSlide 2 Code Optimization Code generation techniques and transformations that result.
Compiler Summary Lexical analysis—scanner – String of characters  token – Finite automata. Syntactical analysis – parser – Sequence of tokens –> language.
CHAPTER 1 INTRODUCTION TO COMPILER SUNG-DONG KIM, DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
Compiler Design (40-414) Main Text Book:
Introduction Chapter : Introduction.
COP 5621 Compiler Construction
课程名 编译原理 Compiling Techniques
Optimization Code Optimization ©SoftMoore Consulting.
Compiler Lecture 1 CS510.
CSc 453 Compilers & Systems Software 00. Background
Compiler Construction
Subject: Language Processor
Introduction to Compiler Construction
Compiler Construction
Introduction Chapter : Introduction.
Programming Languages and Compilers (CS 421)
Optimizing Compilers CISC 673 Spring 2009 Course Overview
Introduction to Compiler Construction
Presentation transcript:

Greg MorrisettFall 2013

 Compilers.  (duh)  Translating one programming language into another.  Also interpreters.  Translating and running a language from within another language.

ParsingElaborationLowering Code Generation Optimization Source Code Target Code

 Lexing & Parsing  From strings to data structures  Usually split into two phases: Strings/FilesTokens Abstract Syntax Trees Lexing Parsing

 Parsing is something that happens in essentially all applications.  E.g., Google search bar, calendar, etc.  First step in going from raw data to information  Lots of CS theory (121) to help out  Regular expressions (finite state automata)  Context-free grammars (push-down automata)  These abstractions show up in optimization too!  Lots of tool support  E.g., Lex and Yacc; parsing combinators; etc.

Type-checking.  Resolve variables, modules, etc.  Check that operations are given values of the right types.  Infer types for sub-expressions.  Check for other safety/security problems. Untyped Abstract Syntax Trees Typed Abstract Syntax Trees

Translate high-level features into a small number of target-like constructs.  e.g., while, for, do-loops all compiled to code using goto’s.  e.g., objects, closures to records and function pointers.  e.g., make type-tests, array-bounds checks, etc. explicit. Typed Abstract Syntax Trees Intermediate Code ASTs

Rewrite expensive sequences of operations into less expensive.  e.g., constant folding: 3+4  7  e.g., lift an invariant computation out of a loop  e.g., parallelize a loop optimization Intermediate Code ASTs

Translate intermediate code into target code.  Register assignment  Instruction selection  Instruction scheduling  Machine-specific optimization Machine Code Intermediate Code ASTs

 People fascinated by languages & compilers  Why does[n’t] this language include this feature?  Systems programmers  Know the one tool that you use every day.  What can[’t] a compiler do well?  Architecture designers  See 432, itanium disasters; register windows  These days, architecture folks use compilers too!  API designers  A language is the ultimate API  c.f., Facebook

 Ideally CS51 & CS61  But 51 is probably good enough.  61 is okay, but you will have to pick up Ocaml.  Some assumptions:  Assume you know a little bit about how machines work (e.g., 2’s compliment arithmetic). ▪ If you don’t know something, ask me!  Assume you can write functional programs.  Assume you are willing to work your tail off.

 Web site:   TF: Lucas Waye  9 programming assignments.  Bulk of your grade.  Work with a partner.  No late days. Ever.  Mid-term (Oct 9) and Final exams.

 Ocaml  Not familiar? Pick up along the way or take 51.  Ideal for writing compilers.  SPIM  MIPS simulator.  Ideal target for compilers.

Modern Compiler Implementation in ML, by Andrew Appel. Good for background reading, but we won’t follow closely.

 MIPS simulator  Understand the machine we are targeting  Fortran-ish -> MIPS  Simple front-end  Simple lowering & code generation  C-ish -> MIPS  1 st -order procedures, structs, arrays  Scheme-ish -> C-ish  Higher-order procedures, type-tests  ML-ish -> Scheme-ish  Type inference

 Algebraic optimization  Tree-based rewriting  Control-flow graphs  Rip out naïve C-ish backend and replace with one based on control-flow graphs.  Implement liveness analysis  Implement graph-coloring register allocation

 Understand how compilers work  Parsing, type-checking & inference, lowering, analysis, optimization, code generation.  How to rewrite your code so that the compiler can do its job better.  Significant engineering experience on a big project.  Understand language and architecture design tradeoffs.  e.g., why are error messages in compilers so bad?  e.g., why do advanced languages essentially require garbage collection?  e.g., what prevents us from parallelizing C/C++?

 What’s happening with architecture?  Multi-core  Heterogeneous units  What’s happening with languages?  Security may matter more than performance  Productivity may matter more than performance  Cluster-level performance (e.g., Map/Reduce)  Feedback-driven optimization