Compiler Construction CS 606 Sohail Aslam Lecture 1.

Slides:



Advertisements
Similar presentations
Code Optimization and Performance Chapter 5 CS 105 Tour of the Black Holes of Computing.
Advertisements

1 Homework / Exam Turn in mp2 at start of class today Reading –PAL, pp 3-6, Exam #1 next class –Open Book / Open Notes –NO calculators or other.
University of Washington Last Time For loops  for loop → while loop → do-while loop → goto version  for loop → while loop → goto “jump to middle” version.
Machine-Level Programming III: Procedures Apr. 17, 2006 Topics IA32 stack discipline Register saving conventions Creating pointers to local variables CS213.
Lecture 18 Procedures Topics Procedural Abstraction Activation records Readings: 7.4 March 20, 2006 CSCE 531 Compiler Construction.
Chapter 16 Programming and Languages: Telling the Computer What to Do.
Lecture 25 Generating Code for Basic Blocks Topics Code Generation Readings: April 19, 2006 CSCE 531 Compiler Construction.
Compiler Construction
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
Stack Activation Records Topics IA32 stack discipline Register saving conventions Creating pointers to local variables February 6, 2003 CSCE 212H Computer.
CPSC 388 – Compiler Design and Construction Lecture: MWF 11:00am-12:20pm, Room 106 Colton.
THE PROCESS OF WRITING SOFTWARE Python: System Engineering 1.
410/510 1 of 20 Week 1 – Lecture 1 Introduction The Textbook Assessment Programming & Tools A v. small compiler Compiler Construction.
Y86 Processor State Program Registers
Introduction CS 104: Applied C++ What is Programming? For some given problem: __________ a solution for it -- identify, organize & store the problem's.
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.
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.
1 CPSC 185 Introduction to Computing The course home page
Introduction 1 (Read Chap. 1) What is Programming? For some given problem: design a solution for it -- identify, organize & store the problem's data --
Low Level Programming Lecturer: Duncan Smeed The Interface Between High-Level and Low-Level Languages.
University of Amsterdam Computer Systems – the instruction set architecture Arnoud Visser 1 Computer Systems The instruction set architecture.
CS 3214 Computer Systems Godmar Back Lecture 8. Announcements Stay tuned for Project 2 & Exercise 4 Project 1 due Sep 16 Auto-fail rule 1: –Need at least.
Improvements to the Compiler Lecture 27 Mon, Apr 26, 2004.
Lecture 1 Overview Topics InstructionsReadings: January 9, 2006 CSCE 531 Compiler Construction.
Prologue Sung-Dong Kim, Dept. of Computer Engineering, Hansung University.
Software Engineering Algorithms, Compilers, & Lifecycle.
IA32 Stack –Region of memory managed with stack discipline –Grows toward lower addresses –Register %esp indicates lowest stack address address of top element.
COMP 3002: Compiler Construction Pat Morin School of Computer Science.
Machine-Level Programming 2 Control Flow Topics Condition Codes Setting Testing Control Flow If-then-else Varieties of Loops Switch Statements.
A job ad at a game programming company
Reading Condition Codes (Cont.)
Machine-Level Programming 2 Control Flow
COMP Compilers Lecture 1: Introduction
Assembly language.
Introduction to programming languages, Algorithms & flowcharts
IA32 Processors Evolutionary Design
Introduction to programming languages, Algorithms & flowcharts
Conditional Branch Example
Microprocessor and Assembly Language
课程名 编译原理 Compiling Techniques
CS 3114 Many of the following slides are taken with permission from
Homework In-line Assembly Code Machine Language
Introduction to Compilers Tim Teitelbaum
Compiler Lecture 1 CS510.
Recitation 2 – 2/4/01 Outline Machine Model
Assembly Language Programming V: In-line Assembly Code
Machine-Level Programming 1 Introduction
Introduction to programming languages, Algorithms & flowcharts
Y86 Processor State Program Registers
Machine-Level Programming 4 Procedures
Course supervisor: Lubna Siddiqui
Compiler Construction
COMP Compilers Lecture 1: Introduction
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
Machine-Level Programming 2 Control Flow
Assembly Language Programming II: C Compiler Calling Sequences
Lecture 30 (based on slides by R. Bodik)
Machine-Level Programming 2 Control Flow
Machine-Level Programming III: Procedures Sept 18, 2001
Machine-Level Representation of Programs III
Machine-Level Programming 2 Control Flow
Compiler Construction
Machine-Level Programming: Introduction
Machine-Level Programming II: Control Flow
C structures and Compilation to IA32
CISC 7120X Programming Languages and Compilers
CS 3114 Many of the following slides are taken with permission from
Algorithms Lecture # 26 Dr. Sohail Aslam.
Presentation transcript:

Compiler Construction CS 606 Sohail Aslam Lecture 1

2 Course Organization  General course information  Homework and project information

3 General Information InstructorSohail Aslam Lectures45 TextCompilers – Principles, Techniques and Tools by Aho, Sethi and Ullman

4 Work Distribution  Theory homeworks = 20% exams = 40%  Practice build a compiler = 40%

5 ProjectProject Implementation  language: subset of java  Generated code: Intel x86 assembly  Implementation language: C++  Six programming assignments

6 Why Take this Course Reason #1: understand compilers and languages  understand the code structure  understand language semantics  understand relation between source code and generated machine code  become a better programmer

7 Why Take this Course Reason #2: nice balance of theory and practice  Theory mathematical models: regular expressions, automata, grammars, graphs algorithms that use these models

8 Why Take this Course Reason #2: nice balance of theory and practice  Practice Apply theoretical notions to build a real compiler

9 Why Take this Course Reason #3: programming experience  write a large program which manipulates complex data structures  learn more about C++ and Intel x86

10 What are Compilers  Translate information from one representation to another  Usually information = program

11 ExamplesExamples  Typical Compilers: VC, VC++, GCC, JavaC FORTRAN, Pascal, VB(?)  Translators Word to PDF PDF to Postscript

12 In This Course We will study typical compilation:  from programs written in high- level languages to low-level object code and machine code

13 Typical Compilation High-level source code Compiler Low-level machine code

14 Source Code int expr( int n ) { int d; d = 4*n*n*(n+1)*(n+1); return d; }

15 Source Code  Optimized for human readability  Matches human notions of grammar  Uses named constructs such as variables and procedures

16 Assembly Code. globl _expr _expr: pushl %ebp movl %esp,%ebp subl $24,%esp movl 8(%ebp),%eax movl %eax,%edx leal 0(,%edx,4),%eax movl %eax,%edx imull 8(%ebp),%edx movl 8(%ebp),%eax incl %eax imull %eax,%edx movl 8(%ebp),%eax incl %eax imull %eax,%edx movl %edx,-4(%ebp) movl -4(%ebp),%edx movl %edx,%eax jmp L2.align 4 L2: leave ret

17 Assembly Code Optimized for hardware  Consists of machine instructions  Uses registers and unnamed memory locations  Much harder to understand by humans

18 How to Translate Correctness: the generated machine code must execute precisely the same computation as the source code

19 How to Translate  Is there a unique translation? No!  Is there an algorithm for an “ideal translation”? No!

20 How to Translate  Translation is a complex process  source language and generated code are very different  Need to structure the translation