Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 614: Theory and Construction of Compilers Lecture 17 Fall 2003 Department of Computer Science University of Alabama Joel Jones.

Similar presentations


Presentation on theme: "CS 614: Theory and Construction of Compilers Lecture 17 Fall 2003 Department of Computer Science University of Alabama Joel Jones."— Presentation transcript:

1 CS 614: Theory and Construction of Compilers Lecture 17 Fall 2003 Department of Computer Science University of Alabama Joel Jones

2 Lecture 17©2003 Joel Jones2 Overview Lattices and Flow Functions Taxonomy of DataFlow Problems and Solution Methods Iterative Data-Flow Analysis Reading for Next Time

3 Lecture 17©2003 Joel Jones3 Lattices and Flow Functions Lattice – an algebraic structure that has associated with it elements and functions that map from one element of the lattice to the other. (these are necessary but not sufficient conditions).

4 Lecture 17©2003 Joel Jones4 Lattice Preliminaries See handout

5 Lecture 17©2003 Joel Jones5 Lattice properties A lattice consists of a set of values and two operations called meet and join Meet – forms greatest lower bound Join - forms least upper bound Properties of meet and join See handout

6 Lecture 17©2003 Joel Jones6 Properties of Common Lattices in Compilers Elements are bit vectors Meet and Join are bit-wise and and or, respectively Bottom element is all zeros and Top element is all ones Pair Up: What would the lattice for booleans look like?, factors of 12 ordered by divisibility?

7 Lecture 17©2003 Joel Jones7 Taxonomy of Data-Flow Problems and Solution Methods How characterize? Information provided Relational or independent Types of lattices, meanings, and functions Direction: forward, backward, both

8 Lecture 17©2003 Joel Jones8 Data-flow Problems Reaching DefinitionsIbit-vectorFWhich definitions reach which program points Available ExpressionsIbit-vectorFWhich expressions reach which program points Live VariablesIbit-vectorBWhich variables have a use between program point and exit Upwards Exposed Uses Ibit-vectorBWhat use of variables at program point are reached by which definitions Copy-propagationIbit-vectorFWhich program points a copy expression reaches (x  y) Constant-propagationIICP n F Which constant assignments (x  const) reach which points with same constant value Partial-redundancyIbit-vectorBiWhich computations are performed >1 times without modification

9 Lecture 17©2003 Joel Jones9 Iterative Data-Flow Analysis See handout Worklist_Iterate(N:set of Node; entry:Node, F: Node x L  L, dfin: Node  L, init: L) dfin(entry) := init; Worklist: set of Node := N - {entry} for each B: Node  N do dfin(B) := top od repeat B :=   ; Worklist -= {B}; totaleffect := top for each P  Pred(B) do effect := F(P, dfin(P)) totaleffect meetAssign effect od if dfin(B) ≠ totaleffect then dfin(B) := totaleffect; Worklist  Succ(B) fi Until Worklist = ø end

10 Lecture 17©2003 Joel Jones10 Readings for Next Time Sections 8.2–8.4 of the textbook


Download ppt "CS 614: Theory and Construction of Compilers Lecture 17 Fall 2003 Department of Computer Science University of Alabama Joel Jones."

Similar presentations


Ads by Google