CS 432 Fall Mike Lam, Professor. Compilers. Advanced Systems Elective

Similar documents
CS 432 Fall Mike Lam, Professor. Compilers. Advanced Systems Elective

CS415 Compilers Overview of the Course. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Intermediate Representations

Compilers for Modern Architectures Course Syllabus, Spring 2015

CS 406/534 Compiler Construction Putting It All Together

CS 4120 and 5120 are really the same course. CS 4121 (5121) is required! Outline CS 4120 / 4121 CS 5120/ = 5 & 0 = 1. Course Information

CS 240 Fall Mike Lam, Professor. Just-for-fun survey:

Compiler Construction LECTURE # 1

CS 432 Fall Mike Lam, Professor. Code Generation

CMPE 152 Compiler Design

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

CS415 Compilers. Intermediate Represeation & Code Generation

G.PULLAIH COLLEGE OF ENGINEERING & TECHNOLOGY

CS/SE 153 Concepts of Compiler Design

CS/SE 153 Concepts of Compiler Design

CS 241 Data Organization. August 21, 2018

Compiling Techniques

CS415 Compilers Overview of the Course. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CMPE 152 Compiler Design

CSE P 501 Compilers. Intermediate Representations Hal Perkins Spring UW CSE P 501 Spring 2018 G-1

COMP 401 COURSE OVERVIEW

Compiler Optimisation

AE Computer Programming for Aerospace Engineers

Compiler Design. Dr. Chengwei Lei CEECS California State University, Bakersfield

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

UG3 Compiling Techniques Overview of the Course

General Course Information. Catalogue Description. Objectives

Overview of the Course

CSCI 565 Compiler Design and Implementation Spring 2014

Overview of the Class

CMPE 152 Compiler Design

San José State University College of Science/Department of Computer Science CS 152, Programming Language Paradigms, Section 03/04, Fall, 2018

CS Compiler Construction West Virginia fall semester 2014 August 18, 2014 syllabus 1.0

Code Shape Comp 412 COMP 412 FALL Chapters 4, 5, 6 & 7 in EaC2e. source code. IR IR target. code. Front End Optimizer Back End

ECE573 Introduction to Compilers & Translators

Compiling Regular Expressions COMP360

Lab 3, Tutorial 1 Comp 412

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims

Languages and Automata

Compilers and Interpreters

Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

Compiler Design (40-414)

Principles of Compiler Construction ( )

San José State University Department of Computer Science CS-144, Advanced C++ Programming, Section 1, Spring 2018

CS164: Midterm I. Fall 2003

Overview of the Class

University of Asia Pacific (UAP) Department of Computer Science and Engineering (CSE)

Compilers. Computer Science 431

Course introduction. Advanced Compiler Construction Michel Schinz

Book keeping. Will post HW5 tonight. OK to work in pairs. Midterm review next Wednesday

Program Proposal for a Direct Converted Program. BS in COMPUTER SCIENCE

CS 536. Class Meets. Introduction to Programming Languages and Compilers. Instructor. Key Dates. Teaching Assistant. Charles N. Fischer.

CISC 124: Introduction To Computing Science II

CS415 Compilers. Lexical Analysis

CS5363 Final Review. cs5363 1

CS 3030 Scripting Languages Syllabus

Compiler Theory Introduction and Course Outline Sandro Spina Department of Computer Science

CSE 114, Computer Science 1 Course Information. Spring 2017 Stony Brook University Instructor: Dr. Paul Fodor

Semantic Analysis. Lecture 9. February 7, 2018

Intermediate Representations

Who are we? Andre Platzer Out of town the first week GHC TAs Alex Crichton, senior in CS and ECE Ian Gillis, senior in CS

Important Project Dates

CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer

CS 553 Compiler Construction Fall 2007 Project #1 Adding floats to MiniJava Due August 31, 2005

B. Subject-specific skills B1. Problem solving skills: Supply the student with the ability to solve different problems related to the topics

Working of the Compilers

CS 553 Compiler Construction Fall 2009 Project #1 Adding doubles to MiniJava Due September 8, 2009

CSE 401/M501 Compilers

San José State University Department of Computer Science CS 166 / SE 166, Information Security, Section 4, spring, 2017

ESET 369 Embedded Systems Software, Fall 2017

San José State University Department of Computer Science CS049J, Programming in Java, Section 2, Fall, 2016

Network Fundamentals and Design Fall Semester 2014

COMP 181 Compilers. Administrative. Last time. Prelude. Compilation strategy. Translation strategy. Lecture 2 Overview

CIS 101 Orientation Document Fall 2017

Philadelphia University Faculty of Information Technology Department of Computer Science --- Semester, 2007/2008. Course Syllabus

ECE Introduction to Compilers and Translation Engineering

Administration Computers Software Algorithms Programming Languages

Introduction to Data Structures

CS 241 Data Organization using C

San José State University Department of Computer Science CS151, Section 04 Object Oriented Design Spring 2018

Lecture 02, Fall 2018 Friday September 7

Compilers and Code Optimization EDOARDO FUSELLA

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

Welcome to CSE131b: Compiler Construction

CS 553 Compiler Construction Fall 2006 Project #4 Garbage Collection Due November 27, 2005

The View from 35,000 Feet

Introduction & First Content Comp 412

COMP251: Algorithms and Data Structures. Jérôme Waldispühl School of Computer Science McGill University

MSc(IT) Program. MSc(IT) Program Educational Objectives (PEO):

CS 415 Midterm Exam Spring SOLUTION

HOLY ANGEL UNIVERSITY COLLEGE OF INFORMATION AND COMMUNICATIONS TECHNOLOGY COMPILER THEORY COURSE SYLLABUS

CS187 - Science Gateway Seminar for CS and Math

CS 3030 Scripting Languages Syllabus

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

Code Shape II Expressions & Assignment

BCIS 3630 Dr. GUYNES FALL 2014 MONDAY SECTION

Compilers. Prerequisites

CS2112 Fall Assignment 4 Parsing and Fault Injection. Due: March 18, 2014 Overview draft due: March 14, 2014

San José State University Computer Science Department CS49J, Section 3, Programming in Java, Fall 2015

Transcription:

CS 432 Fall 2018 Mike Lam, Professor Compilers Advanced Systems Elective

Discussion question What is a compiler?

Automated translation A compiler is a computer program that automatically translates other programs from one language to another (usually from a human-readable language to a machineexecutable language, but not necessarily) Program in Source Language Compiler Program in Target Language

Automated translation Compilation vs. interpretation: Program in Source Language Compiler Program in Target Language Program in Source Language Interpreter Results

Discussion question Why should we study compilers? (besides getting systems elective credit...)

Compilers: a convergent topic Data structures CS 240 Architectures, machine languages, and operating systems CS 261, CS 450 Automata and language theory CS 327, CS 430 Graph algorithms CS 327 Software and systems engineering CS 345, CS 361 Greedy, heuristic, and fixed-point algorithms CS 452

Reasons to study compilers Shows how many areas of CS can be combined to solve a truly "hard" problem (automated language translation) Bridges theory vs. implementation gap Theory informs implementation Applicable in many other domains Practical experience with large(er) software systems My master copy is nearly 7K LOC Of this, you will re-write over 1K LOC this semester Exposure to open problems in CS Many optimization issues are subject to ongoing research

Course goal Fundamental question "How do compilers translate from a human-readable language to a machine-executable language?" After this course, your response should be: "It's really cool! Let me tell you..." 1. Step A 2. Step B 6. Profit!!!???

Course design theory First, a bit of background...

Course design theory Big ideas E.g., "A compiler is a large software system consisting of a sequence of phases" "Enduring understandings" (stuff you should remember in five years) E.g, "Large problems can sometimes be solved by composing existing solutions to smaller problems." Learning objectives (stuff you should remember at the end of the course) E.g., "Identify the technical challenges of building a large software system such as a compiler." Activities and assignments flow from learning objectives E.g., "Draw a diagram illustrating the major phases of a modern compiler." Exams reflect activities and assignments Goal: engaged and effective learning

Learning objectives Identify and discuss the technical and social challenges of building a large software system such as a compiler. Develop and analyze formal descriptions of computer languages. Apply finite automata theory to build recognizers (lexers) for regular languages. Apply pushdown automata theory to build recognizers (parsers) for context-free languages. Evaluate the role of static analysis in automated program translation. Apply tree traversals to convert a syntax tree to low-level code. Discuss the limitations that an architecture or execution environment places on the generation of machine code. Describe common optimizations and evaluate the tradeoffs associated with good optimization.

Course format Website: https://w3.cs.jmu.edu/lam2mo/cs432/ Make sure you re using the right year s website! Weekly schedule (roughly) Formative vs. summative assessment Formative: quizzes and activities (20% of final grade) Summative: projects and exams (80% of final grade)

Course textbook Engineering a Compiler, 2 nd Edition Keith Cooper and Linda Torczon 1 st chapter scanned; posted under Files on Canvas Reserve copy at Rose library Decaf/ILOC references PDFs on website

Semester-long project Compiler for "Decaf" language Implementation in Java Maven build system w/ fully-integrated test suite Five major projects: "pieces" of the full system Compiles to ILOC (new machine language from textbook) Submission: code + reflection + review + response Code can be written in teams of two Benefits vs. costs of working in a team Reflection must be submitted individually Individual graded code reviews due a week later Review responses (how did your reviewer do?)

Course policies Questions?

Compiler rule #1 "The compiler must preserve the meaning of the program being compiled." What is a program's meaning?

Intermediate representation Compilers encode a program's meaning using an intermediate representation (IR) Tree- or graph-based: abstract syntax tree (AST), control flow graph (CFG) Linear: register transfer language (RTL), Java bytecode, intermediate language for an optimizing compiler (ILOC) = a * + b c d load b r1 load c r2 add r1, r2 r3 load d r4 mult r3, r4 r5 store r5 a

Standard compiler framework Front end: understand the program (src IR) Back end: encode in target language (IR targ) Primary benefit: easier re-targeting to different languages or architectures Program in Source Language A Front End Compiler IR Program in Target Language 1 Program in Source Language B Front End Back End Program in Target Language 1

Modern compiler framework Multiple front-end passes Compiler Lexing/scanning and parsing Tree analysis processing Front End IR Middle End IR Back End Multiple middle-end passes Local optimizations Compiler Global optimizations Multiple back-end passes Instruction selection/scheduling Register allocation Linking

Compiler rule #2 The compiler should help the programmer in some way What does help mean?

Discussion question What would be your design goals for a compiler? E.g., what functionality or properties would you like it to have?

Compiler design goals Translate to target language/architecture Optimize for fast execution Minimize memory/energy use Catch software defects early Provide helpful error messages Run quickly Be easily extendable

Differing design goals What differences might you expect in compilers designed for the following applications? A just-in-time compiler for running server-side user scripts A compiler used in an introductory programming course A compiler used to build scientific computing codes to run on a massively-parallel supercomputer A compiler that targets a number of diverse systems A compiler that targets an embedded sensor network platform

Decaf language Simple imperative language similar to C or Java Example: // add.decaf - simple addition example def int add(int x, int y) { return x + y; } def int main() { int a; a = 3; return add(a, 2); } reference compiler interpret flag and source file $ java -jar decaf-1.0.jar -i add.decaf 5

Before Wednesday Readings "Engineering a Compiler" (EAC) Ch. 1 (23 pages) Decaf reference ("Resources" page on website) Tasks Complete first reading quiz on Canvas Complete course intro survey on Canvas Download the reference compiler from Canvas ("Files") Write some code in Decaf Install the JDK and Maven on your system

Upcoming events CS senior night Wednesday, Sept. 5, 5:00-6:30pm Graduation info, job fairs, photos, etc. Senior students only CISE career fair Wednesday, Sept. 19, time/location TBD Over 20 companies looking for technology majors Internships and full-time positions

See you Wednesday Have a great semester!