CS 671 Compilers Prof. Kim Hazelwood Spring 2008.

Slides:



Advertisements
Similar presentations
1 CIS 461 Compiler Design and Construction Fall 2014 Instructor: Hugh McGuire slides derived from Tevfik Bultan, Keith Cooper, and Linda Torczon Lecture-Module.
Advertisements

Software & Services Group, Developer Products Division Copyright© 2010, Intel Corporation. All rights reserved. *Other brands and names are the property.
Introduction to Advanced Topics Chapter 1 Mooly Sagiv Schrierber
CPSC Compiler Tutorial 9 Review of Compiler.
Lecture 01 - Introduction Eran Yahav 1. 2 Who? Eran Yahav Taub 734 Tel: Monday 13:30-14:30
Modern Compiler Internal Representations Silvius Rus 1/23/2002.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
From Cooper & Torczon1 Implications Must recognize legal (and illegal) programs Must generate correct code Must manage storage of all variables (and code)
Compiler Construction
Compiler Construction1 A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University First Semester 2009/2010.
CS 153: Concepts of Compiler Design August 25 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Lecture 2 Phases of Compiler. Preprocessors, Compilers, Assemblers, and Linkers Preprocessor Compiler Assembler Linker Skeletal Source Program Source.
CPSC 388 – Compiler Design and Construction Lecture: MWF 11:00am-12:20pm, Room 106 Colton.
CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.
September 7, September 7, 2015September 7, 2015September 7, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University.
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
COP4020 Programming Languages
Chapter 1. Introduction.
CS 363 Comparative Programming Languages
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.
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
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.
CST320 - Lec 11 Why study compilers? n n Ties lots of things you know together: –Theory (finite automata, grammars) –Data structures –Modularization –Utilization.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Joey Paquet, 2000, 2002, 2007, Concordia University Department of Computer Science COMP 442/6421 Compiler Design.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
Compiler design Lecture 1: Compiler Overview Sulaimany University 2 Oct
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
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.
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.
Topic #1: Introduction EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Chapter 1 Introduction Study Goals: Master: the phases of a compiler Understand: what is a compiler Know: interpreter,compiler structure.
Compilers: Overview/1 1 Compiler Structures Objective – –what are the main features (structures) in a compiler? , Semester 1,
Introduction to Compiling
Introduction CPSC 388 Ellen Walker Hiram College.
Chapter 1 Introduction. Chapter 1 -- Introduction2  Def: Compiler --  a program that translates a program written in a language like Pascal, C, PL/I,
Compiler Construction Composed By, Muhammad Bilal Qureshi.
Introduction to Language Programming Hierarchy of programming lang. Based on machine independences: 1. Machine language 2. Assembly language 3. Higher.
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.
CSC 4181 Compiler Construction
©SoftMoore ConsultingSlide 1 Structure of Compilers.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
1 Compiler Construction Vana Doufexi office CS dept.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Objective of the course Understanding the fundamentals of the compilation technique Assist you in writing you own compiler (or any part of compiler)
CHAPTER 1 INTRODUCTION TO COMPILER SUNG-DONG KIM, DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
Advanced Computer Systems
Compiler Design (40-414) Main Text Book:
PRINCIPLES OF COMPILER DESIGN
Chapter 1 Introduction.
Introduction to Compiler Construction
Microprocessor and Assembly Language
CMPUT Compiler Design and Optimization
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Compiler Lecture 1 CS510.
Compiler Construction
Compiler Construction
Compiler Construction
Compiler Structures 1. Overview Objective
Presentation transcript:

CS 671 Compilers Prof. Kim Hazelwood Spring 2008

CS 671 – Spring What is a Compiler? Compiler High-Level Programming Languages Machine Code Error Messages Then What? Machine Code Program Inputs Program Outputs

CS 671 – Spring What is an Interpreter? Interpreter Source Code Program Outputs Program Inputs

CS 671 – Spring What is a Just-in-Time Compiler? IR Generator Source Code Program Outputs Program Inputs Virtual Machine Intermediate Program

CS 671 – Spring Why Study Compilers? Fundamental tool in computer science since 1952 Remains a vibrant research topic Machines keep changing Languages keep changing Applications keep changing When to compile keeps changing Challenging! Must correctly handle an infinite set of legal programs Is itself a large program → “Where theory meets practice”

CS 671 – Spring Goals of a Compiler A compiler’s job is to Lower the abstraction level Eliminate overhead from language abstractions Map source program onto hardware efficiently –Hide hardware weaknesses, utilize hardware strengths Equal the efficiency of a good assembly programmer Optimizing compilers should improve the code Performance* Code size Security Reliability Power consumption

CS 671 – Spring An Interface to High-Level Languages Programmers write in high-level languages Increases productivity Easier to maintain/debug More portable HLLs also protect the programmer from low- level details Registers and caches – the register keyword Instruction selection Instruction-level parallelism The catch: HLLs are less efficient Compiler High-Level Programming Languages Machine Code

CS 671 – Spring High-Level Languages and Features C (80’s) … C++ (Early 90’s) … Java (Late 90’s) Each language had features that spawned new research C/Fortran/COBOL User-defined aggregate data types (arrays, structures) Control-flow and procedures Prompted data-flow optimizations C++/Simula/Modula II/Smalltalk Object orientation (more, smaller procedures) Prompted inlining Java Type safety, bounds checking, garbage collection Prompted bounds removal, dynamic optimization

CS 671 – Spring An Interface to Computer Architectures Parallelism Instruction level –multiple operations at once –want to minimize dependences Processor level –multiple threads at once –want to minimize synchronization Memory Hierarchies Register allocation (only portion explicitly managed in SW) Code and data layout (helps the hardware cache manager) Designs driven by how well compilers can leverage new features! Compiler High-Level Programming Languages Machine Code

CS 671 – Spring How Can We Translate Effectively? ? High-Level Source Code Low-Level Machine Code

CS 671 – Spring Idea: Translate in Steps Series of program representations Intermediate representations optimized for various manipulations (checking, optimization) More machine specific, less language specific as translation proceeds

CS 671 – Spring Simplified Compiler Structure Lexical Analysis Parsing Intermediate Code Generation Optimization Source code (character stream) if (b==0) a = b; Assembly code (character stream) CMP CX, 0 CMOVZ CX, DX Token stream Abstract syntax tree Intermediate code Front End Back End Machine dependent Machine independent Register Allocation LIR

CS 671 – Spring Why Separate the Front and Back Ends? Recall: An interface between HLLs and architectures Option: X*Y compilers or X-front ends + Y-back ends Compiler Hello alpha Hello x86 Hello sparc hello.c hello.f hello.cc hello.ada X FEs Y BEs Front End Hello alpha Hello x86 Hello sparc hello.c hello.f hello.cc hello.ada Back End IR

CS 671 – Spring Internal Compiler Structure –Front End Series of filter passes Source program – Written in a HLL Lexical analysis – Convert keywords into “tokens” Parser – Forms a syntax “tree” (statements, expressions, etc.) Semantic analysis – Type checking, etc. Intermediate code generator – Three-address code, interface for back end Lexical Analyzer Parser Semantic Analyzer Source Program Token Stream Syntax Tree Intermediate Code Gen IR

CS 671 – Spring Internal Compiler Structure –Back End Code optimization – “improves” the intermediate code (most time is spent here) Consists of machine independent & dependent optimizations Code generation Register allocation, instruction selection Code Optimizer Code Generator IR Target program

CS 671 – Spring GCC Demo

CS 671 – Spring Traditional Compiler Infrastructures GNU GCC Targets: everything (pretty much) Strength: Targets everything (pretty much) Weakness: Not as extensible as research infrastructures, poor optimization Stanford SUIF Compiler with Harvard MachSUIF Targets: Alpha, x86, IPF, C Strength: high level analysis, parallelization on scientific codes Intel Open Research Compiler (ORC) Targets: IPF Strength: robust with OK code quality Weakness: Many IR levels

CS 671 – Spring Modern Compiler Infrastructures IBM Jikes RVM Targets Linux, x86 or AIX Strengths: Open-source, wide user base Weaknesses: In maintenance mode Microsoft Phoenix Targets Windows Strengths: Actively developed Weaknesses: Closed source, extensive API

CS 671 – Spring What will we learn in this course? Structure of Compilers The Front End The Back End Advanced Topics –Just-in-time compilation –Dynamic optimization –Power and size optimizations

CS 671 – Spring Required Work Two Non-Cumulative Exams (15% each) –February 21 and April 10 Homework (30%) –About 4 assignments –Some are pencil/paper; some are implementation-based Semester Project (40%) –Groups of 2 –Staged submission –proposal 30% –report 55% –presentation 15% Late Policy 2 ^ (days late) points off (where days late > 0)

CS 671 – Spring Course Materials We will use the Dragon book Course Website – Lecture Slides –On the course website –I will try to post them before class –Attending class is in your best interest Other Helpful Books

CS 671 – Spring Next Time… Read Dragon Chapter 1 We will begin discussing lexical analysis Look out for HW1