Review: What is an activation record?

Slides:



Advertisements
Similar presentations
Intermediate Representations CS 671 February 12, 2008.
Advertisements

Chapter 6 Intermediate Code Generation
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
The University of Adelaide, School of Computer Science
Intermediate Representations Saumya Debray Dept. of Computer Science The University of Arizona Tucson, AZ
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.
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.
1 Handling nested procedures Method 1 : static (access) links –Reference to the frame of the lexically enclosing procedure –Static chains of such links.
Cpeg421-08S/final-review1 Course Review Tom St. John.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
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.
Compiler Construction A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University Second Semester 2008/2009.
Presented by Dr Ioanna Dionysiou
5.3 Machine-Independent Compiler Features
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.
Chapter 5: Programming Languages and Constructs by Ravi Sethi Activation Records Dolores Zage.
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.
Chapter# 6 Code generation.  The final phase in our compiler model is the code generator.  It takes as input the intermediate representation(IR) produced.
Winter Compilers Software Eng. Dept. – Ort Braude Compiling Assignments and Expressions Lecturer: Esti Stein brd4.ort.org.il/~esti2.
Intermediate Code Representations
1 Structure of a Compiler Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Front End Code Optimizer Target Code Generator.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 10 Ahmed Ezzat.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
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)
Compiler Summary Lexical analysis—scanner – String of characters  token – Finite automata. Syntactical analysis – parser – Sequence of tokens –> language.
CS 404 Introduction to Compiler Design
Run-Time Environments Chapter 7
Intermediate code Jakub Yaghob
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Review: Chapter 5: Syntax directed translation
Compiler Construction
Compiler Construction
An Overview to Compiler Design
Intermediate Code Generation
Compiler Optimization and Code Generation
Code Generation Part I Chapter 9
Intermediate Code Generation Part I
Unit IV Code Generation
Chapter 6 Intermediate-Code Generation
Code Generation Part I Chapter 8 (1st ed. Ch.9)
CS 201 Compiler Construction
Intermediate Code Generation Part I
Code Generation Part I Chapter 9
Run-Time Environments
Code Optimization Overview and Examples Control Flow Graph
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
Intermediate Code Generation Part I
8 Code Generation Topics A simple code generator algorithm
Intermediate Code Generation
Intermediate Code Generation Part I
Compiler Design 21. Intermediate Code Generation
Intermediate Code Generating machine-independent intermediate form.
Run-time environments
Code Optimization.
CS 201 Compiler Construction
Presentation transcript:

Review: What is an activation record? What are the typical fields in an activation record? What are the storage allocation strategies? Which program construct in C prevents the compiler from using the static allocation scheme? What do we do in a calling sequence? In a return sequence? Accessing nonlocal variables, is it a problem in static allocation scheme? Accessing nonlocal variables, how to do it in the stack allocation scheme? What is the difference with and without nested loop? How to access the non-locals with access link, how to maintain the access link.

Chapter 8: Intermediate Code Generation 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 generator Code optimizer Static checker parser Code generator

Intermediate Languages: Graphical representations: Syntax tree Control flow graph Program dependence graph (PDG) DAG (direct acyclic graph) Example: a := b* -c + b * -c

Three address code: A sequence of statement of the form x:=y op z Example: a:=b*-c + b * -c Three address statements are very 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

How to choose an intermediate language to be used by the compiler? 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 How to choose an intermediate language to be used by the compiler?