Compiler Construction

Slides:



Advertisements
Similar presentations
CSC 4181 Compiler Construction Code Generation & Optimization.
Advertisements

CMPUT Compiler Design and Optimization1 CMPUT680 - Winter 2006 Topic 5: Peep Hole Optimization José Nelson Amaral
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
1 CS 201 Compiler Construction Machine Code Generation.
Chapter 10 Code Optimization. A main goal is to achieve a better performance Front End Code Gen Intermediate Code source Code target Code user Machine-
Lecture 11: Operating System Services. What is an Operating System? An operating system is an event driven program which acts as an interface between.
Introduction to Code Optimization Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
CS189A/172 - Winter 2008 Lecture 7: Software Specification, Architecture Specification.
From Cooper & Torczon1 Implications Must recognize legal (and illegal) programs Must generate correct code Must manage storage of all variables (and code)
Introduction to Optimization Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Wrapping Up Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
BY: SACHIN SHRIVASTAVA Operating System By : Sachin Shrivastava 1.
Intro to Java The Java Virtual Machine. What is the JVM  a software emulation of a hypothetical computing machine that runs Java bytecodes (Java compiler.
ENGR. SHOAIB ASLAM Computer Programming I Lecture 02.
Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System.
Introduction For some compiler, the intermediate code is a pseudo code of a virtual machine. Interpreter of the virtual machine is invoked to execute the.
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
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.
Invitation to Computer Science 5 th Edition Chapter 6 An Introduction to System Software and Virtual Machine s.
CS 671 Compilers Prof. Kim Hazelwood Spring 2008.
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
Operating System Principles And Multitasking
Chapter 1 Introduction Study Goals: Master: the phases of a compiler Understand: what is a compiler Know: interpreter,compiler structure.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Compiler Construction Dr. Naveed Ejaz Lecture 4. 2 The Back End Register Allocation:  Have each value in a register when it is used. Instruction selection.
3/2/2016© Hal Perkins & UW CSES-1 CSE P 501 – Compilers Optimizing Transformations Hal Perkins Autumn 2009.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
Lecture 02: Compiler Overview Kwangman Man ( SangJi University.
System Components Operating System Services System Calls.
Single Static Assignment Intermediate Representation (or SSA IR) Many examples and pictures taken from Wikipedia.
Chapter 1 Introduction Samuel College of Computer Science & Technology Harbin Engineering University.
Lecture 38: Compiling for Modern Architectures 03 May 02
Invitation to Computer Science 6th Edition
Advanced Computer Systems
Component 1.6.
Introduction to Optimization
Lecture 1: Operating System Services
Processes and threads.
Chapter 1 Introduction.
컴파일러 첫째주 2005/09/01 권혁철.
Compiler Construction (CS-636)
Chapter 2: System Structures
Lecture Topics: 11/1 Processes Process Management
ACOE301: Computer Architecture II Labs
Intro to Programming Week # 1 Hardware / Software Lecture # 2
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Compiler Lecture 1 CS510.
OPERATING SYSTEM OVERVIEW
Compiler Construction
Introduction to Optimization
Optimizing Transformations Hal Perkins Autumn 2011
Wrapping Up Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit.
Lecture 02: Compiler Overview
CGS 3763 Operating Systems Concepts Spring 2013
Compiler Construction
Optimizing Transformations Hal Perkins Winter 2008
Unit 1: Introduction to Operating System
System Programming and administration
Lecture Topics: 11/1 General Operating System Concepts Processes
Compiler Construction
Chapter 2: Operating-System Structures
Introduction to Optimization
Optimization 薛智文 (textbook ch# 9) 薛智文 96 Spring.
Lecture 19: Code Optimisation
Chapter 2 Operating System Overview
Chapter 2: Operating-System Structures
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Presentation transcript:

Compiler Construction CS 606 Sohail Aslam Lecture 4 compiler: intro

The Back End Register Allocation: IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Register Allocation: Have each value in a register when it is used.

The Back End Register Allocation: IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Register Allocation: Manage a limited set of resources – register file.

The Back End Register Allocation: IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Register Allocation: Can change instruction choices and insert LOADs and STOREs.

The Back End Register Allocation: IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Register Allocation: Optimal register allocation is NP-Complete.

The Back End Instruction Scheduling: IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Instruction Scheduling: Avoid hardware stalls and interlocks.

The Back End Instruction Scheduling: IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Instruction Scheduling: Use all functional units productively.

The Back End Instruction Scheduling: IR Instruction selection IR Register allocation IR Instruction scheduling machine code errors Instruction Scheduling: Optimal scheduling is NP-Complete in nearly all cases.

Three-pass Compiler IR IR Front End Source code Middle End Back End machine code errors Intermediate stage for code improvement or optimization

Three-pass Compiler Analyzes IR and rewrites (or transforms) IR IR IR Front End Source code Middle End Back End machine code errors Analyzes IR and rewrites (or transforms) IR

Three-pass Compiler IR IR Front End Source code Middle End Back End machine code errors Primary goal is to reduce running time of the compiled code

Three-pass Compiler IR IR Front End Source code Middle End Back End machine code errors May also improve space usage, power consumption, ...

Three-pass Compiler Must preserve “meaning” of the code. IR IR Front End Source code Middle End Back End machine code errors Must preserve “meaning” of the code. Measured by values of named variables

Optimizer Modern optimizers are structured as a series of passes Opt 1 IR errors Opt 2 n 3 Modern optimizers are structured as a series of passes

Optimizer Typical transformations IR errors Opt 2 n 3 Typical transformations Discover & propagate some constant value

Optimizer Typical transformations IR errors Opt 2 n 3 Typical transformations Move a computation to a less frequently executed place

Optimizer Typical transformations IR errors Opt 2 n 3 Typical transformations Specialize some computation based on context

Optimizer Typical transformations IR errors Opt 2 n 3 Typical transformations Discover a redundant computation & remove it

Optimizer Typical transformations Remove useless or unreachable code IR errors Opt 2 n 3 Typical transformations Remove useless or unreachable code

Optimizer Typical transformations IR errors Opt 2 n 3 Typical transformations Encode an idiom in some particularly efficient form

Role of Run-time System Memory management Allocate/deallocate Garbage collection Run-time type checking Error/exception processing Interface to OS – I/O Support for parallelism Parallel threads Communication and synchronization

Related to Compilers Interpreters (direct execution) Assemblers Preprocessors Text formatters (non-WYSIWYG) Analysis tools