Application Specific Signal Processors S

Size: px
Start display at page:

Download "Application Specific Signal Processors S"

Transcription

1 1 Application Specific Signal Processors S Dept. of Computer Science and Engineering Mehdi Safarpour

2 Course contents Lecture contents 1. Introduction and number formats 2. Signal processor architectures 3. Transport-triggered processors 4. Program code and compilation 5. Performance optimization 6. Tools and FPGAs

3 What you will learn this time Structure of a compiler How to improve program performance by SW changes

4 Introduction In Lecture 2 we concentrated on the processor Human-readable code Compiler Machinereadable code Processor Output

5 Introduction This time we will concentrate on the compiler Human-readable code Compiler Machinereadable code Processor Output

6 Compiler structure Human-readable code Compiler

7 Compiler structure Human-readable code Front-end Compiler Intermediate representation

8 Compiler structure Human-readable code Front-end Compiler Intermediate representation Optimization Intermediate representation

9 Compiler structure Human-readable code Front-end Compiler Intermediate representation Optimization Intermediate representation Back-end

10 Compiler structure Human-readable code Front-end Compiler Intermediate representation Optimization Intermediate representation Back-end Target machine program

11 Compiler structure C C++ Fortran Java... Front-end Compiler Intermediate representation Optimization Intermediate representation Back-end x86 ARM c6x TTA

12

13 language-dependent front-end code optimizer processor dependent back-end Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

14 Lexical analysis: divides the source code into parts Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

15 Lexical analysis: divides the source code into parts for example: Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007) y = x + 3 y symbol 1 x symbol 2 = token (=) + token (+) 3 number 1

16 Lexical analysis: divides the source code into parts for example: Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007) y = x + 3 y symbol 1 x symbol 2 = token (=) + token (+) 3 number 1

17 Lexical analysis: divides the source code into parts An example of an entry that creates an error in the lexical analyzer: 6a = x + c; Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007) supposing this is C language, identifiers can not start with a number

18 Symbol table: maintains a list of symbols that exist in the code Generally there are multiple symbol tables for different parts of the code Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

19 Syntax analyzer (parser) Analyzes the relations between symbols, tokens and numbers according to precendence rules etc. Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

20 Syntax analyzer (parser) Analyzes the relations between symbols, tokens and numbers according to precendence rules etc. y = x + 3 = y + Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007) x 3

21 Syntax analyzer (parser) Analyzes the relations between symbols, tokens and numbers according to precendence rules etc. y = * + 3 = Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007) y?

22 Semantic analyzer Analyzes the relations between symbols, tokens and numbers according to precendence rules etc. Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

23 Semantic analyzer Analyzes the relations between symbols, tokens and numbers according to precendence rules etc. int array[10]; float index; return array[index]; Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

24 Semantic analyzer Analyzes the relations between symbols, tokens and numbers according to precendence rules etc. int array[10]; float index; return array[index]; Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

25 Intermediate code generator Translates the input coming from the previous stages to an abstract language that is used by the compiler for optimization etc. Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

26 Two major styles of intermediate representation exist: 1) syntax trees 2) three-address codes Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

27 Two major styles of intermediate representation exist: 1) syntax trees 2) three-address codes Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007) + + * * a - d b c a + a * (b c) + (b - c) * d

28 Two major styles of intermediate representation exist: 1) syntax trees 2) three-address codes t 1 = b c t 2 = a * t 1 t 3 = a + t 2 t 4 = t 1 * d t 5 = t 3 + t 4 Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007) a + a * (b c) + (b - c) * d

29 Reminder: This is the compiler front-end The front-end is languagedependent Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

30 Code optimizer: Make transformations to the program so that it executes faster, but behaves identically to the original version. Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

31 Exercise Together with your pair, answer the questions: 1) What does the C source code do? 2) What does the unoptimized assembly code contain? 3) What does the optimized assembly do? Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007) Description of puts(): int puts ( const char * str ); Writes the C string pointed by str to the standard output (stdout) and appends a newline character ('\n').

32 Code generator: Produces assembly instructions or machine code for a specific processor out of the intermediate representation. Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

33 Machine dependent code optimizer: Optimizes the assembly/machine code for a specific platform. For example, instruction scheduling. Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

34 language-dependent front-end code optimizer processor dependent back-end Figure source: Aho, Lam, Sethi, Ullman Compilers principles, techniques and tools (2007)

35 39 Loop scheduling Software pipelining: reorganize a loop so that parts of different loop iterations run in parallel Need prolog and epilog around the loop to set up

36 Practical compiler-related issues

37 Practical compiler-related issues Key question: how to make the program run more efficiently on the processor? Efficiency means Avoiding behavior that is not needed (e.g. Memory accesses) Improving the utilization of processor resources (less empty instructions) As a consequence the execution time improves and power consumption reduces The software-related methods how to do this depend somewhat on the processor and on the programming language that is used

38 Practical compiler-related issues For TTA processors the following issues slow down the program: 1. Global data 2. Use of pointers in some cases (int *p) 3. Data size changes (8-bit integer, 16-bit integer, etc) 4. Conditionals (if-then-else, switch)

39 Practical compiler-related issues 1. Global data In the C language, it is preferable that variables and arrays are defined inside functions, which means that they are local int main() { int x;... } However, sometimes, by accident or for some important reason, variables are defined outside functions, making them global. Reading and writing global variables is slow. int x; int main() {... } The reason is global variable is likely to be assigned in Memory rather than a register file

40 Practical compiler-related issues 2. Pointers In the C language, pointers are problematic because they can point to any place in the memory Because of this general problem, the C compiler cannot much optimize the code around a pointer. As a consequence, code containing pointer may run slow and/or use the data memory

41 Practical compiler-related issues 2. Pointers These cases can make pointers problematic for the compiler: Pointers as function parameters int filter (int *x, int *y) { } Pointer arithmetic int array[3] *(array + i) = value;

42 Practical compiler-related issues 2. Pointers How to avoid performance loss caused by pointers: Using the restrict keyword int filter (int * restrict x, int * restrict y) { } Index arrays by [] int array[3] array[i] = value;

43 Practical compiler-related issues 3. Data size changes Data size changes force the compiler to insert extra operations to the program code short val1; int val2; val2 = val1; A sign extension (sxhw) is inserted Or: unsigned int data; _TCE_FIFO_U8_STREAM_IN(0, data, status); An and-operation is inserted

44 Practical compiler-related issues 4. Conditionals The C compiler in the TTA toolset is very advanced and can most usually transform small if-statements to logical computations Still, in some cases the removal of if-statements must be done manually

45 Mini Assignment Take the filter.c program from Exercise 1 (\float folder). Compile using gcc compiler with optimization levels of 0 to 3. Use S to instruct the compiler to generate assembly code. Report obsereved changes in generated asm code. Example: gcc filter.c o filterlevel_1.asm O1 S Of course the asm code will be for X86 machine.

LECTURE 3. Compiler Phases

LECTURE 3. Compiler Phases LECTURE 3 Compiler Phases COMPILER PHASES Compilation of a program proceeds through a fixed series of phases. Each phase uses an (intermediate) form of the program produced by an earlier phase. Subsequent

More information

CA Compiler Construction

CA Compiler Construction CA4003 - Compiler Construction David Sinclair Overview This module will cover the compilation process, reading and parsing a structured language, storing it in an appropriate data structure, analysing

More information

COMP 3002: Compiler Construction. Pat Morin School of Computer Science

COMP 3002: Compiler Construction. Pat Morin School of Computer Science COMP 3002: Compiler Construction Pat Morin School of Computer Science Course Information Instructor: Pat Morin morin@scs.carleton.ca Just "Pat" Office Hours: Tuesdays 9:00-10:00, 13:30-14:30 Webpage: http://cg.scs.carleton.ca/~morin/teaching/3002/

More information

Working of the Compilers

Working of the Compilers Working of the Compilers Manisha Yadav Nisha Thakran IT DEPARTMENT IT DEPARTMENT DCE,GURGAON DCE,GURGAON Abstract- The objective of the paper is to depict the working of the compilers that were designed

More information

CST-402(T): Language Processors

CST-402(T): Language Processors CST-402(T): Language Processors Course Outcomes: On successful completion of the course, students will be able to: 1. Exhibit role of various phases of compilation, with understanding of types of grammars

More information

Compilers Crash Course

Compilers Crash Course Compilers Crash Course Prof. Michael Clarkson CSci 6907.85 Spring 2014 Slides Acknowledgment: Prof. Andrew Myers (Cornell) What are Compilers? Translators from one representation of program code to another

More information

Introduction to Syntax Analysis. Compiler Design Syntax Analysis s.l. dr. ing. Ciprian-Bogdan Chirila

Introduction to Syntax Analysis. Compiler Design Syntax Analysis s.l. dr. ing. Ciprian-Bogdan Chirila Introduction to Syntax Analysis Compiler Design Syntax Analysis s.l. dr. ing. Ciprian-Bogdan Chirila chirila@cs.upt.ro http://www.cs.upt.ro/~chirila Outline Syntax Analysis Syntax Rules The Role of the

More information

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation Language Implementation Methods The Design and Implementation of Programming Languages Compilation Interpretation Hybrid In Text: Chapter 1 2 Compilation Interpretation Translate high-level programs to

More information

CS426 Compiler Construction Fall 2006

CS426 Compiler Construction Fall 2006 CS426 Compiler Construction David Padua Department of Computer Science University of Illinois at Urbana-Champaign 0. Course organization 2 of 23 Instructor: David A. Padua 4227 SC, 333-4223 Office Hours:

More information

Compiler Design (40-414)

Compiler Design (40-414) Compiler Design (40-414) Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007 Evaluation: Midterm Exam 35% Final Exam 35% Assignments and Quizzes 10% Project

More information

CSE450. Translation of Programming Languages. Lecture 11: Semantic Analysis: Types & Type Checking

CSE450. Translation of Programming Languages. Lecture 11: Semantic Analysis: Types & Type Checking CSE450 Translation of Programming Languages Lecture 11: Semantic Analysis: Types & Type Checking Structure Project 1 - of a Project 2 - Compiler Today! Project 3 - Source Language Lexical Analyzer Syntax

More information

Programming in C++ 4. The lexical basis of C++

Programming in C++ 4. The lexical basis of C++ Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++

More information

Introduction to Compiler Construction

Introduction to Compiler Construction Introduction to Compiler Construction Robert van Engelen http://www.cs.fsu.edu/~engelen/courses/cop5621 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2011 Syllabus

More information

An Overview to Compiler Design. 2008/2/14 \course\cpeg421-08s\topic-1a.ppt 1

An Overview to Compiler Design. 2008/2/14 \course\cpeg421-08s\topic-1a.ppt 1 An Overview to Compiler Design 2008/2/14 \course\cpeg421-08s\topic-1a.ppt 1 Outline An Overview of Compiler Structure Front End Middle End Back End 2008/2/14 \course\cpeg421-08s\topic-1a.ppt 2 Reading

More information

Earlier edition Dragon book has been revised. Course Outline Contact Room 124, tel , rvvliet(at)liacs(dot)nl

Earlier edition Dragon book has been revised. Course Outline Contact Room 124, tel , rvvliet(at)liacs(dot)nl Compilerconstructie najaar 2013 http://www.liacs.nl/home/rvvliet/coco/ Rudy van Vliet kamer 124 Snellius, tel. 071-527 5777 rvvliet(at)liacs(dot)nl college 1, dinsdag 3 september 2013 Overview 1 Why this

More information

MANIPAL INSTITUTE OF TECHNOLOGY (Constituent Institute of MANIPAL University) MANIPAL

MANIPAL INSTITUTE OF TECHNOLOGY (Constituent Institute of MANIPAL University) MANIPAL MANIPAL INSTITUTE OF TECHNOLOGY (Constituent Institute of MANIPAL University) MANIPAL-576104 CSE 312 LANGUAGE PROCESSORS LAB MANUAL VI Sem, BE (CS&E) 2015 Prepared By Approved By 1. Dr. Ashalatha Nayak

More information

Introduction to Compiler Construction

Introduction to Compiler Construction Introduction to Compiler Construction Robert van Engelen http://www.cs.fsu.edu/~engelen/courses/cop5621 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2005 Syllabus

More information

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS

More information

ST. XAVIER S COLLEGE

ST. XAVIER S COLLEGE ST. XAVIER S COLLEGE MAITIGHAR, KATHMANDU Compiler Design and Construction Lab Assignment #1 Submitted by: Aashish Raj Shrestha 013BSCCSIT002 Submitted to: Mr. Ramesh Shahi Lecturer, Department of Computer

More information

Advanced Systems Programming

Advanced Systems Programming Advanced Systems Programming Introduction to C++ Martin Küttler September 19, 2017 1 / 18 About this presentation This presentation is not about learning programming or every C++ feature. It is a short

More information

Final CSE 131B Spring 2004

Final CSE 131B Spring 2004 Login name Signature Name Student ID Final CSE 131B Spring 2004 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 (25 points) (24 points) (32 points) (24 points) (28 points) (26 points) (22 points)

More information

Introduction to Compiler Design

Introduction to Compiler Design Introduction to Compiler Design Lecture 1 Chapters 1 and 2 Robb T. Koether Hampden-Sydney College Wed, Jan 14, 2015 Robb T. Koether (Hampden-Sydney College) Introduction to Compiler Design Wed, Jan 14,

More information

A simple syntax-directed

A simple syntax-directed Syntax-directed is a grammaroriented compiling technique Programming languages: Syntax: what its programs look like? Semantic: what its programs mean? 1 A simple syntax-directed Lexical Syntax Character

More information

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 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 4120 / 4121 CS 5120/5121 Introduction to Compilers Fall 2011 Andrew Myers Lecture 1: Overview Outline About this course Introduction to compilers What are compilers? Why should we learn about them?

More information

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

COMP 181 Compilers. Administrative. Last time. Prelude. Compilation strategy. Translation strategy. Lecture 2 Overview COMP 181 Compilers Lecture 2 Overview September 7, 2006 Administrative Book? Hopefully: Compilers by Aho, Lam, Sethi, Ullman Mailing list Handouts? Programming assignments For next time, write a hello,

More information

Lecture 31: Building a Runnable Program

Lecture 31: Building a Runnable Program The University of North Carolina at Chapel Hill Spring 2002 Lecture 31: Building a Runnable Program April 10 1 From Source Code to Executable Code program gcd(input, output); var i, j: integer; begin read(i,

More information

LECTURE NOTES ON COMPILER DESIGN P a g e 2

LECTURE NOTES ON COMPILER DESIGN P a g e 2 LECTURE NOTES ON COMPILER DESIGN P a g e 1 (PCCS4305) COMPILER DESIGN KISHORE KUMAR SAHU SR. LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY ROLAND INSTITUTE OF TECHNOLOGY, BERHAMPUR LECTURE NOTES ON COMPILER

More information

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou Administrative! Next time reading assignment [ALSU07] Chapters 1,2 [ALSU07] Sections 1.1-1.5 (cover in class) [ALSU07] Section 1.6 (read on your

More information

CPS 506 Comparative Programming Languages. Syntax Specification

CPS 506 Comparative Programming Languages. Syntax Specification CPS 506 Comparative Programming Languages Syntax Specification Compiling Process Steps Program Lexical Analysis Convert characters into a stream of tokens Lexical Analysis Syntactic Analysis Send tokens

More information

C - Basics, Bitwise Operator. Zhaoguo Wang

C - Basics, Bitwise Operator. Zhaoguo Wang C - Basics, Bitwise Operator Zhaoguo Wang Java is the best language!!! NO! C is the best!!!! Languages C Java Python 1972 1995 2000 (2.0) Procedure Object oriented Procedure & object oriented Compiled

More information

Compilers and Interpreters

Compilers and Interpreters Compilers and Interpreters Pointers, the addresses we can see Programs that write other programs Managing the details A compiler is a program that, when fed itself as input, produces ITSELF! Then how was

More information

Principles of Programming Languages. Lecture Outline

Principles of Programming Languages. Lecture Outline Principles of Programming Languages CS 492 Lecture 1 Based on Notes by William Albritton 1 Lecture Outline Reasons for studying concepts of programming languages Programming domains Language evaluation

More information

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline CS 0 Lecture 8 Chapter 5 Louden Outline The symbol table Static scoping vs dynamic scoping Symbol table Dictionary associates names to attributes In general: hash tables, tree and lists (assignment ) can

More information

PROGRAMMING FUNDAMENTALS

PROGRAMMING FUNDAMENTALS PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write

More information

Evaluation of Semantic Actions in Predictive Non- Recursive Parsing

Evaluation of Semantic Actions in Predictive Non- Recursive Parsing Evaluation of Semantic Actions in Predictive Non- Recursive Parsing José L. Fuertes, Aurora Pérez Dept. LSIIS School of Computing. Technical University of Madrid Madrid, Spain Abstract To implement a syntax-directed

More information

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

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers Leonidas Fegaras CSE 5317/4305 L1: Course Organization and Introduction 1 General Course Information Instructor:

More information

Compilers and Code Optimization EDOARDO FUSELLA

Compilers and Code Optimization EDOARDO FUSELLA Compilers and Code Optimization EDOARDO FUSELLA The course covers Compiler architecture Pre-requisite Front-end Strong programming background in C, C++ Back-end LLVM Code optimization A case study: nu+

More information

names names identifiers variables subroutines constants

names names identifiers variables subroutines constants names (source: Louden, "Programming Languages, Principles and Practices", 2nd Edition, Ch. 5, pp. 125-134)!p. 126: "A fundamental abstraction mechanism in a programming language is the use of names, or

More information

DOID: A Lexical Analyzer for Understanding Mid-Level Compilation Processes

DOID: A Lexical Analyzer for Understanding Mid-Level Compilation Processes www.ijecs.in International Journal Of Engineering And Computer Science ISSN: 2319-7242 Volume 5 Issue 12 Dec. 2016, Page No. 19507-19511 DOID: A Lexical Analyzer for Understanding Mid-Level Compilation

More information

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

Compiler Design. Dr. Chengwei Lei CEECS California State University, Bakersfield Compiler Design Dr. Chengwei Lei CEECS California State University, Bakersfield The course Instructor: Dr. Chengwei Lei Office: Science III 339 Office Hours: M/T/W 1:00-1:59 PM, or by appointment Phone:

More information

Error Recovery during Top-Down Parsing: Acceptable-sets derived from continuation

Error Recovery during Top-Down Parsing: Acceptable-sets derived from continuation 2015 http://excel.fit.vutbr.cz Error Recovery during Top-Down Parsing: Acceptable-sets derived from continuation Alena Obluková* Abstract Parser is one of the most important parts of compiler. Syntax-Directed

More information

ATOMS. 3.1 Interface. The Atom interface is simple: atom.h #ifndef ATOM_INCLUDED #define ATOM_INCLUDED

ATOMS. 3.1 Interface. The Atom interface is simple: atom.h #ifndef ATOM_INCLUDED #define ATOM_INCLUDED 3 ATOMS An atom is a pointer to a unique, immutable sequence of zero or more arbitrary bytes. Most atoms are pointers to null-terminated strings, but a pointer to any sequence of bytes can be an atom.

More information

Formal Languages and Compilers Lecture I: Introduction to Compilers

Formal Languages and Compilers Lecture I: Introduction to Compilers Formal Languages and Compilers Lecture I: Introduction to Compilers Free University of Bozen-Bolzano Faculty of Computer Science POS Building, Room: 2.03 artale@inf.unibz.it http://www.inf.unibz.it/ artale/

More information

PLAGIARISM. Administrivia. Compilers. CS143 11:00-12:15TT B03 Gates. Text. Staff. Instructor. TAs. Office hours, contact info on 143 web site

PLAGIARISM. Administrivia. Compilers. CS143 11:00-12:15TT B03 Gates. Text. Staff. Instructor. TAs. Office hours, contact info on 143 web site Administrivia Everything is on the class Web site http://www.stanford.edu/class/cs143/ Compilers CS143 11:00-12:15TT B03 Gates Syllabus is on-line, of course Assignment dates will not change Midterm Thursday,

More information

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Objective PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Explain what is meant by compiler. Explain how the compiler works. Describe various analysis of the source program. Describe the

More information

DSP Mapping, Coding, Optimization

DSP Mapping, Coding, Optimization DSP Mapping, Coding, Optimization On TMS320C6000 Family using CCS (Code Composer Studio) ver 3.3 Started with writing a simple C code in the class, from scratch Project called First, written for C6713

More information

Compiler Construction LECTURE # 1

Compiler Construction LECTURE # 1 Compiler Construction AN OVERVIEW LECTURE # 1 The Course Course Code: CS-4141 Course Title: Compiler Construction Instructor: JAWAD AHMAD Email Address: jawadahmad@uoslahore.edu.pk Web Address: http://csandituoslahore.weebly.com/cc.html

More information

CS 403 Compiler Construction Lecture 3 Lexical Analysis [Based on Chapter 1, 2, 3 of Aho2]

CS 403 Compiler Construction Lecture 3 Lexical Analysis [Based on Chapter 1, 2, 3 of Aho2] CS 403 Compiler Construction Lecture 3 Lexical Analysis [Based on Chapter 1, 2, 3 of Aho2] 1 What is Lexical Analysis? First step of a compiler. Reads/scans/identify the characters in the program and groups

More information

Compiler Design Overview. Compiler Design 1

Compiler Design Overview. Compiler Design 1 Compiler Design Overview Compiler Design 1 Preliminaries Required Basic knowledge of programming languages. Basic knowledge of FSA and CFG. Knowledge of a high programming language for the programming

More information

Tools of the Trade The C Language Laboration 04. Outline. 1 Tools of the Trade. 2 The C Language. 3 Laboration 04

Tools of the Trade The C Language Laboration 04. Outline. 1 Tools of the Trade. 2 The C Language. 3 Laboration 04 Outline 1 2 3 GNU Project GNU Project - Free Software(?) Licensed under GPL(v2 v3) - GNU Public Licence. Freedom to modify, bound to distribute source (if you distribute it!). Effort initiated (announced)

More information

Where We Are. Lexical Analysis. Syntax Analysis. IR Generation. IR Optimization. Code Generation. Machine Code. Optimization.

Where We Are. Lexical Analysis. Syntax Analysis. IR Generation. IR Optimization. Code Generation. Machine Code. Optimization. Where We Are Source Code Lexical Analysis Syntax Analysis Semantic Analysis IR Generation IR Optimization Code Generation Optimization Machine Code Where We Are Source Code Lexical Analysis Syntax Analysis

More information

COMP 202 Java in one week

COMP 202 Java in one week COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of

More information

CSC 467 Lecture 3: Regular Expressions

CSC 467 Lecture 3: Regular Expressions CSC 467 Lecture 3: Regular Expressions Recall How we build a lexer by hand o Use fgetc/mmap to read input o Use a big switch to match patterns Homework exercise static TokenKind identifier( TokenKind token

More information

These are reserved words of the C language. For example int, float, if, else, for, while etc.

These are reserved words of the C language. For example int, float, if, else, for, while etc. Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.

More information

COS 140: Foundations of Computer Science

COS 140: Foundations of Computer Science COS 140: Foundations of Computer Science Variables and Primitive Data Types Fall 2017 Introduction 3 What is a variable?......................................................... 3 Variable attributes..........................................................

More information

A Simple Syntax-Directed Translator

A Simple Syntax-Directed Translator Chapter 2 A Simple Syntax-Directed Translator 1-1 Introduction The analysis phase of a compiler breaks up a source program into constituent pieces and produces an internal representation for it, called

More information

1. Lexical Analysis Phase

1. Lexical Analysis Phase 1. Lexical Analysis Phase The purpose of the lexical analyzer is to read the source program, one character at time, and to translate it into a sequence of primitive units called tokens. Keywords, identifiers,

More information

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

Compiling and Interpreting Programming. Overview of Compilers and Interpreters Copyright R.A. van Engelen, FSU Department of Computer Science, 2000 Overview of Compilers and Interpreters Common compiler and interpreter configurations Virtual machines Integrated programming environments

More information

Compilers. Lecture 2 Overview. (original slides by Sam

Compilers. Lecture 2 Overview. (original slides by Sam Compilers Lecture 2 Overview Yannis Smaragdakis, U. Athens Yannis Smaragdakis, U. Athens (original slides by Sam Guyer@Tufts) Last time The compilation problem Source language High-level abstractions Easy

More information

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou Administrative! Any questions about the syllabus?! Course Material available at www.cs.unic.ac.cy/ioanna! Next time reading assignment [ALSU07]

More information

Lexical analysis. Syntactical analysis. Semantical analysis. Intermediate code generation. Optimization. Code generation. Target specific optimization

Lexical analysis. Syntactical analysis. Semantical analysis. Intermediate code generation. Optimization. Code generation. Target specific optimization Second round: the scanner Lexical analysis Syntactical analysis Semantical analysis Intermediate code generation Optimization Code generation Target specific optimization Lexical analysis (Chapter 3) Why

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

COSE312: Compilers. Lecture 1 Overview of Compilers

COSE312: Compilers. Lecture 1 Overview of Compilers COSE312: Compilers Lecture 1 Overview of Compilers Hakjoo Oh 2017 Spring Hakjoo Oh COSE312 2017 Spring, Lecture 1 March 7, 2017 1 / 15 What is Compiler? Software systems that translate a program written

More information

Parallel Execution of Tasks of Lexical Analyzer using OpenMP on Multi-core Machine

Parallel Execution of Tasks of Lexical Analyzer using OpenMP on Multi-core Machine Parallel Execution of Tasks of Lexical Analyzer using OpenMP on Multi-core Machine Rohitkumar Rudrappa Wagdarikar* and Rajeshwari Krishnahari Gundla** *-**Computer Science and Engineering Dept, Walchand

More information

Compilers. Prerequisites

Compilers. Prerequisites Compilers Prerequisites Data structures & algorithms Linked lists, dictionaries, trees, hash tables Formal languages & automata Regular expressions, finite automata, context-free grammars Machine organization

More information

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

Compiler Theory Introduction and Course Outline Sandro Spina Department of Computer Science Compiler Theory 001 - Introduction and Course Outline Sandro Spina Department of Computer Science ( course Books (needed during this My slides are based on the three books: Compilers: Principles, techniques

More information

COP 3402 Systems Software. Lecture 4: Compilers. Interpreters

COP 3402 Systems Software. Lecture 4: Compilers. Interpreters COP 3402 Systems Software Lecture 4: Compilers 1 Outline 1. Compiler and interpreters 2. Compilers 3. 4. PL/0 lexical tokens 2 Compilers / Programming languages are notations for describing computations

More information

Grammars and Parsing. Paul Klint. Grammars and Parsing

Grammars and Parsing. Paul Klint. Grammars and Parsing Paul Klint Grammars and Languages are one of the most established areas of Natural Language Processing and Computer Science 2 N. Chomsky, Aspects of the theory of syntax, 1965 3 A Language...... is a (possibly

More information

Goals of C "" The Goals of C (cont.) "" Goals of this Lecture"" The Design of C: A Rational Reconstruction"

Goals of C  The Goals of C (cont.)  Goals of this Lecture The Design of C: A Rational Reconstruction Goals of this Lecture The Design of C: A Rational Reconstruction Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C Why? Learning

More information

Creating a C++ Program

Creating a C++ Program Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an

More information

COP4020 Programming Assignment 1 - Spring 2011

COP4020 Programming Assignment 1 - Spring 2011 COP4020 Programming Assignment 1 - Spring 2011 In this programming assignment we design and implement a small imperative programming language Micro-PL. To execute Mirco-PL code we translate the code to

More information

CD Assignment I. 1. Explain the various phases of the compiler with a simple example.

CD Assignment I. 1. Explain the various phases of the compiler with a simple example. CD Assignment I 1. Explain the various phases of the compiler with a simple example. The compilation process is a sequence of various phases. Each phase takes input from the previous, and passes the output

More information

Lecture08: Scope and Lexical Address

Lecture08: Scope and Lexical Address Lecture08: Scope and Lexical Address Free and Bound Variables (EOPL 1.3.1) Given an expression E, does a particular variable reference x appear free or bound in that expression? Definition: A variable

More information

LECTURE 18. Control Flow

LECTURE 18. Control Flow LECTURE 18 Control Flow CONTROL FLOW Sequencing: the execution of statements and evaluation of expressions is usually in the order in which they appear in a program text. Selection (or alternation): a

More information

Compilers - Chapter 2: An introduction to syntax analysis (and a complete toy compiler)

Compilers - Chapter 2: An introduction to syntax analysis (and a complete toy compiler) Compilers - Chapter 2: An introduction to syntax analysis (and a complete toy compiler) Lecturers: Paul Kelly (phjk@doc.ic.ac.uk) Office: room 304, William Penney Building Naranker Dulay (nd@doc.ic.ac.uk)

More information

COMPILER DESIGN LECTURE NOTES

COMPILER DESIGN LECTURE NOTES COMPILER DESIGN LECTURE NOTES UNIT -1 1.1 OVERVIEW OF LANGUAGE PROCESSING SYSTEM 1.2 Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing:

More information

University of Utrecht. 1992; Fokker, 1995), the use of monads to structure functional programs (Wadler,

University of Utrecht. 1992; Fokker, 1995), the use of monads to structure functional programs (Wadler, J. Functional Programming 1 (1): 1{000, January 1993 c 1993 Cambridge University Press 1 F U N C T I O N A L P E A R L S Monadic Parsing in Haskell Graham Hutton University of Nottingham Erik Meijer University

More information

COSC121: Computer Systems: Runtime Stack

COSC121: Computer Systems: Runtime Stack COSC121: Computer Systems: Runtime Stack Jeremy Bolton, PhD Assistant Teaching Professor Constructed using materials: - Patt and Patel Introduction to Computing Systems (2nd) - Patterson and Hennessy Computer

More information

Variables and literals

Variables and literals Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of

More information

CSE 452: Programming Languages. Outline of Today s Lecture. Expressions. Expressions and Control Flow

CSE 452: Programming Languages. Outline of Today s Lecture. Expressions. Expressions and Control Flow CSE 452: Programming Languages Expressions and Control Flow Outline of Today s Lecture Expressions and Assignment Statements Arithmetic Expressions Overloaded Operators Type Conversions Relational and

More information

Compiler Construction

Compiler Construction Compiler Construction Lecture 1: Introduction Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de http://moves.rwth-aachen.de/teaching/ss-14/cc14/ Summer

More information

Administrivia. Compilers. CS143 10:30-11:50TT Gates B01. Text. Staff. Instructor. TAs. The Purple Dragon Book. Alex Aiken. Aho, Lam, Sethi & Ullman

Administrivia. Compilers. CS143 10:30-11:50TT Gates B01. Text. Staff. Instructor. TAs. The Purple Dragon Book. Alex Aiken. Aho, Lam, Sethi & Ullman Administrivia Compilers CS143 10:30-11:50TT Gates B01 Syllabus is on-line, of course cs143.stanford.edu Assignment dates will not change Midterm Thursday, 5/3 in class Final Monday, 6/11 12:15-3:15pm Communication

More information

2.2 Syntax Definition

2.2 Syntax Definition 42 CHAPTER 2. A SIMPLE SYNTAX-DIRECTED TRANSLATOR sequence of "three-address" instructions; a more complete example appears in Fig. 2.2. This form of intermediate code takes its name from instructions

More information

Pointers (continued), arrays and strings

Pointers (continued), arrays and strings Pointers (continued), arrays and strings 1 Last week We have seen pointers, e.g. of type char *p with the operators * and & These are tricky to understand, unless you draw pictures 2 Pointer arithmetic

More information

BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC ELEMENTS OF A COMPUTER PROGRAM BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators

More information

Introduction to Lexical Analysis

Introduction to Lexical Analysis Introduction to Lexical Analysis Outline Informal sketch of lexical analysis Identifies tokens in input string Issues in lexical analysis Lookahead Ambiguities Specifying lexers Regular expressions Examples

More information

Lecture 2: C Programming Basic

Lecture 2: C Programming Basic ECE342 Introduction to Embedded Systems Lecture 2: C Programming Basic Ying Tang Electrical and Computer Engineering Rowan University 1 Facts about C C was developed in 1972 in order to write the UNIX

More information

ISA: The Hardware Software Interface

ISA: The Hardware Software Interface ISA: The Hardware Software Interface Instruction Set Architecture (ISA) is where software meets hardware In embedded systems, this boundary is often flexible Understanding of ISA design is therefore important

More information

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program Syntax What the Compiler needs to understand your program 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line Possibly replacing it with other

More information

[Syntax Directed Translation] Bikash Balami

[Syntax Directed Translation] Bikash Balami 1 [Syntax Directed Translation] Compiler Design and Construction (CSc 352) Compiled By Central Department of Computer Science and Information Technology (CDCSIT) Tribhuvan University, Kirtipur Kathmandu,

More information

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O Overview of C Basic Data Types Constants Variables Identifiers Keywords Basic I/O NOTE: There are six classes of tokens: identifiers, keywords, constants, string literals, operators, and other separators.

More information

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup starting in 1979 based on C Introduction to C++ also

More information

Extending xcom. Chapter Overview of xcom

Extending xcom. Chapter Overview of xcom Chapter 3 Extending xcom 3.1 Overview of xcom xcom is compile-and-go; it has a front-end which analyzes the user s program, a back-end which synthesizes an executable, and a runtime that supports execution.

More information

! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented

! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented Course Goal CMSC 330: Organization of Programming Languages Introduction Learn how programming languages work Broaden your language horizons! Different programming languages! Different language features

More information

Programming Language Processor Theory

Programming Language Processor Theory Programming Language Processor Theory Munehiro Takimoto Course Descriptions Method of Evaluation: made through your technical reports Purposes: understanding various theories and implementations of modern

More information

CS 415 Midterm Exam Spring 2002

CS 415 Midterm Exam Spring 2002 CS 415 Midterm Exam Spring 2002 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Good Luck! Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming

More information

Advanced Programming & C++ Language

Advanced Programming & C++ Language Advanced Programming & C++ Language ~1~ Introduction. Compilation Process Ariel University 2018 Dr. Miri (Kopel) Ben-Nissan 2 Administration Stuff Final Exam: 70% Exercises: 30% Both lectures and exercises

More information

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003 Control Flow COMS W1007 Introduction to Computer Science Christopher Conway 3 June 2003 Overflow from Last Time: Why Types? Assembly code is typeless. You can take any 32 bits in memory, say this is an

More information

Reminder: tutorials start next week!

Reminder: tutorials start next week! Previous lecture recap! Metrics of computer architecture! Fundamental ways of improving performance: parallelism, locality, focus on the common case! Amdahl s Law: speedup proportional only to the affected

More information

Pioneering Compiler Design

Pioneering Compiler Design Pioneering Compiler Design NikhitaUpreti;Divya Bali&Aabha Sharma CSE,Dronacharya College of Engineering, Gurgaon, Haryana, India nikhita.upreti@gmail.comdivyabali16@gmail.com aabha6@gmail.com Abstract

More information