Intermediate Code Generating machine-independent intermediate form.

Slides:



Advertisements
Similar presentations
Chapter 6 Intermediate Code Generation
Advertisements

ANALYSIS OF PROG. LANG. PROGRAM ANALYSIS Instructors: Crista Lopes Copyright © Instructors. 1.
1 Lecture 10 Intermediate Representations. 2 front end »produces an intermediate representation (IR) for the program. optimizer »transforms the code in.
Intermediate Code Generation
8. Code Generation. Generate executable code for a target machine that is a faithful representation of the semantics of the source code Depends not only.
Intermediate Representations Saumya Debray Dept. of Computer Science The University of Arizona Tucson, AZ
Backpatching: The syntax directed definition we discussed before can be implemented in two or more passes (we have both synthesized attributes and inheritent.
Loop invariant code removal CS 480. Our sample calculation for i := 1 to n for j := 1 to m c [i, j] := 0 for k := 1 to p c[i, j] := c[i, j] + a[i, k]
8 Intermediate code generation
1 Compiler Construction Intermediate Code Generation.
Program Representations. Representing programs Goals.
Intermediate Representation I High-Level to Low-Level IR Translation EECS 483 – Lecture 17 University of Michigan Monday, November 6, 2006.
Chapter 14: Building a Runnable Program Chapter 14: Building a runnable program 14.1 Back-End Compiler Structure 14.2 Intermediate Forms 14.3 Code.
Representing programs Goals. Representing programs Primary goals –analysis is easy and effective just a few cases to handle directly link related things.
Intermediate Code Generation Professor Yihjia Tsai Tamkang University.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
Intermediate Code CS 471 October 29, CS 471 – Fall Intermediate Code Generation Source code Lexical Analysis Syntactic Analysis Semantic.
1 Intermediate representation Goals: encode knowledge about the program facilitate analysis facilitate retargeting facilitate optimization scanning parsing.
1 CS 201 Compiler Construction Lecture 1 Introduction.
CSC 8505 Compiler Construction Intermediate Representations.
Topic 6 -Code Generation Dr. William A. Maniatty Assistant Prof. Dept. of Computer Science University At Albany CSI 511 Programming Languages and Systems.
Partial Automation of an Integration Reverse Engineering Environment of Binary Code Author : Cristina Cifuentes Reverse Engineering, 1996., Proceedings.
Compiler Construction A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University Second Semester 2008/2009.
ECE355 Fall 2004Software Reliability1 ECE-355 Tutorial Jie Lian.
COP4020 Programming Languages
What is Three Address Code? A statement of the form x = y op z is a three address statement. x, y and z here are the three operands and op is any logical.
Compiler Chapter# 5 Intermediate code generation.
Chapter 8: Intermediate Code Generation
Review: –What is an activation record? –What are the typical fields in an activation record? –What are the storage allocation strategies? Which program.
Intermediate Code Generation
1 June 3, June 3, 2016June 3, 2016June 3, 2016 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University Azusa Pacific University,
1 CS 201 Compiler Construction Introduction. 2 Instructor Information Rajiv Gupta Office: WCH Room Tel: (951) Office.
Winter Compilers Software Eng. Dept. – Ort Braude Compiling Assignments and Expressions Lecturer: Esti Stein brd4.ort.org.il/~esti2.
Intermediate Code Representations
Compilers Modern Compiler Design
1 Compiler & its Phases Krishan Kumar Asstt. Prof. (CSE) BPRCE, Gohana.
Prepared By: Abhisekh Biswas - 04CS3002 Intermediate Code Generation.
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.
1 Structure of a Compiler Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Front End Code Optimizer Target Code Generator.
CSC 4181 Compiler Construction
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 10 Ahmed Ezzat.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Code Generation Part I Chapter 8 (1st ed. Ch.9)
CS 404 Introduction to Compiler Design
PRINCIPLES OF COMPILER DESIGN
Introduction to Compiler Construction
Language Translation Compilation vs. interpretation.
Intermediate code Jakub Yaghob
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Compiler Construction
Compiler Construction
An Overview to Compiler Design
Intermediate Code Generation
Compiler Optimization and Code Generation
Code Generation Part I Chapter 9
Intermediate Representations Hal Perkins Autumn 2011
Intermediate Code Generation
Unit IV Code Generation
Chapter 6 Intermediate-Code Generation
Code Generation Part I Chapter 8 (1st ed. Ch.9)
CS 201 Compiler Construction
Code Generation Part I Chapter 9
Intermediate code generation
Three-address code A more common representation is THREE-ADDRESS CODE . Three address code is close to assembly language, making machine code generation.
Compiler Design 21. Intermediate Code Generation
8 Code Generation Topics A simple code generator algorithm
Intermediate Code Generation
Compiler Design 21. Intermediate Code Generation
Review: What is an activation record?
CS 201 Compiler Construction
Presentation transcript:

Intermediate Code Generating machine-independent intermediate form. Decouple backend from frontend, facilitate retargeting Machine independent code optimizer can be applied here. Position of intermediate code generator: Intermediate Code generation Static semantic analysis parser Machine-specific Code optimization Target code generation Machine-independent Code optimization

Intermediate languages, many kinds for different purposes High-level representation for source to source translation to keep the program structure: Abstract syntax tree Low-level representation for compiling for target machine. An intermediate form that is close to low level machine language. Three address code (more later) gcc uses RTL, a variation of the three address code. Other commonly used intermediate language Control flow graph, Program dependence graph (PDG), DAG (direct acyclic graph)

Three address code: A sequence of statement of the form x:=y op z Example: a:=b*-c + b * -c Three address statements are close to the assembly statements (OP src1 src2 dst) t1 := -c t2 := b * t1 t3 := -c t4 := b * t3 t5 = t2 + t4 a = t5 t1 := -c t2 := b * t1 t3 = t2 + t2 a = t3

Some three-address statements that will be used later: Assignment statements: With a binary operation: x := y op z With a unary operation: x:= op y With no operation(copy) : x := y Branch statements Unconditional jump: goto L Conditional jumps: if x relop y goto L Statement for procedure calls Param x, set a parameter for a procedure call Call p, n call procedure p with n parameters Return y return from a procedure with return value y

Example: instructions for procedure call: p(x1, x2, x3, …, xn): param x1 param x2 … param xn call p, n Indexed assignments: x := y[i] and x[i] := y Address and pointer assignments x := &y, x := *y