TARGET CODE GENERATION

Slides:



Advertisements
Similar presentations
1 Code Generation The target machine Instruction selection and register allocation Basic blocks and flow graphs A simple code generator Peephole optimization.
Advertisements

Compiler Construction
Compiler Construction Sohail Aslam Lecture Code Generation  The code generation problem is the task of mapping intermediate code to machine code.
Target Code Generation
Target code Generation Made by – Siddharth Rakesh 11CS30036 Date – 12/11/2013.
Chapter 9 Code optimization Section 0 overview 1.Position of code optimizer 2.Purpose of code optimizer to get better efficiency –Run faster –Take less.
1 CS 201 Compiler Construction Machine Code Generation.
CS 31003: Compilers Introduction to Phases of Compiler.
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-
Dominators and CFGs Taken largely from University of Delaware Compiler Notes \course\cpeg421-05s\Topic2.ppt.
Lecture 11 – Code Generation Eran Yahav 1 Reference: Dragon 8. MCD
Lecture 23 Basic Blocks Topics Code Generation Readings: 9 April 17, 2006 CSCE 531 Compiler Construction.
Code Generation Professor Yihjia Tsai Tamkang University.
1 CS 201 Compiler Construction Lecture 1 Introduction.
Topic 6 -Code Generation Dr. William A. Maniatty Assistant Prof. Dept. of Computer Science University At Albany CSI 511 Programming Languages and Systems.
Topic #10: Optimization EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
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.
Department of Computer Science A Static Program Analyzer to increase software reuse Ramakrishnan Venkitaraman and Gopal Gupta.
1 Code Generation Part II Chapter 8 (1 st ed. Ch.9) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University,
CSc 453 Final Code Generation Saumya Debray The University of Arizona Tucson.
1 Code Generation Part II Chapter 9 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2005.
Execution of an instruction
1 CS 201 Compiler Construction Introduction. 2 Instructor Information Rajiv Gupta Office: WCH Room Tel: (951) Office.
Chapter 1 Introduction Study Goals: Master: the phases of a compiler Understand: what is a compiler Know: interpreter,compiler structure.
1 Code Generation. 2 Position of a Code Generator in the Compiler Model Front-End Code Optimizer Source program Symbol Table Lexical error Syntax error.
Code Generation Ⅰ CS308 Compiler Theory1. 2 Background The final phase in our compiler model Requirements imposed on a code generator –Preserving the.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Chapter# 6 Code generation.  The final phase in our compiler model is the code generator.  It takes as input the intermediate representation(IR) produced.
FOUNDATION IN INFORMATION TECHNOLOGY (CS-T-101) TOPIC : INFORMATION SYSTEM – SOFTWARE.
Compilers Modern Compiler Design
1 Control Flow Analysis Topic today Representation and Analysis Paper (Sections 1, 2) For next class: Read Representation and Analysis Paper (Section 3)
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Topic #9: Target Code EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
1 Chapter10: Code generator. 2 Code Generator Source Program Target Program Semantic Analyzer Intermediate Code Generator Code Optimizer Code Generator.
Code Generation Part I Chapter 8 (1st ed. Ch.9)
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
Chapter 8 Code Generation
COS341 Project 3 (2017): Executable Code for SPL
Code Optimization Code produced by compilation algorithms can often be improved (ideally optimized) in terms of run-time speed and the amount of memory.
Compiler Design (40-414) Main Text Book:
High-level optimization Jakub Yaghob
Code Optimization.
Computer Science 210 Computer Organization
Introduction to programming
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Chapter 1: Introduction to Compiling (Cont.)
Compiler Construction
Computer Science 210 Computer Organization
Pick up the handout on your way in!!
Code Generation Part I Chapter 9
Code Generation.
Unit IV Code Generation
Code Generation Part I Chapter 8 (1st ed. Ch.9)
CS 201 Compiler Construction
TARGET CODE GENERATION
Code Generation Part I Chapter 9
TARGET CODE -Next Usage
Instructions in Machine Language
8 Code Generation Topics A simple code generator algorithm
Optimization 薛智文 (textbook ch# 9) 薛智文 96 Spring.
Intermediate Code Generation
Compiler Construction
Taken largely from University of Delaware Compiler Notes
Code Generation Part II
Target Code Generation
CSc 453 Final Code Generation
Review: What is an activation record?
Intermediate Code Generating machine-independent intermediate form.
CS 201 Compiler Construction
Presentation transcript:

TARGET CODE GENERATION Prepared By: DHEERAJ KUMAR JAIN-04CS3015

INTRODUCTION

FACTORS EFFECTING THE GENERATION OF TARGET CODE Form of Input-How Complex/Simple is the IMC Absolute code Relocatable code Hardware facility to do the translation Compiler book marking Assembly code Assembler

FACTORS EFFECTING THE GENERATION OF TARGET CODE Dynamicity Mk independent It is still readable Intermediate code  Target Code Instruction selection : For each type of three address statement, we can design a code skeleton that outlines the target code to be generated for that construct.

FACTORS EFFECTING THE GENERATION OF TARGET CODE x=y+z  mov R1, y #y -> R1 mov R2, z #z -> R2 ADD R2, R1 #R2+R1->R2 mov x, R2 #R2->x OR mov R1,z # z->R1 ADD R1,y #R1+y->R1 mov x,R1 #R1->x

FACTORS EFFECTING THE GENERATION OF TARGET CODE Register allocation : Instructions involving register operands are usually shorter and faster than those involving operands in memory. Therefore, efficient utilization of registers is particularly important in generating good code. The use of registers is often subdivided into two sub problems: 1. During register allocation, we select the set of variables that will reside in registers at a point in the program.

FACTORS EFFECTING THE GENERATION OF TARGET CODE 2.During a subsequent register assignment phase, we pick the specific register that a variable will reside in. Evaluation order if(a>b) goto L1 if(a<=b) goto L2 goto L2 L1: L1: = = L2: L2:

BASIC BLOCKS IDENTIFYING BASIC BLOCKS:A basic block is a sequence of consecutive statements in which flow of control enters at the beginning and leaves at the end without halt or possibility of branching except at the end. 1. We first determine the set of leaders, the first statements of basic blocks. The rules we use are the following :

BASIC BLOCKS I) The first statement is a leader. II) Any statement that is the target of a conditional or unconditional goto is a leader. III) Any statement that immediately follows a goto or conditional goto statement is a leader. 2.For each leader, its basic block consists of the leader and all statements up to but not including the next leader or the end of the program.

BASIC BLOCKS Egs. 1. location = -1 2. i=0 3. if (i<100) goto 5 6. t2 = A[t1] 7. if t2 = x goto 9 8. goto 10 9. location = i 10. t3 = i+1 11. i = t3 12. goto 3 13. ..

BASIC BLOCKS Leaders : 1,3,4,5,8,9,10,13 Basic Blocks are : B1 = 1,2

BASIC BLOCKS

THE END Visit: http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Autumn2006/Compiler/main.html#Lecture