Control Flow
Boolean expressions
Boolean expressions are often used to:
Alter the flow of control
Compute logical values
Two basic approaches
Numerical Representation
true represented as 1
false represented as 0
work like arithmetic expressions
Con
Backpatching
The main difficulty with code generation for boolean
expressions and flow-of-control statement is that we may not
know the target of a branch in one pass
Backpatching is the technique to get around this problem.
Generate branch instruction
Translation of Array References
Elements are typically stored in a block of consecutive
locations.
If the width of each array element is w, then the ith element
of array A (say, starting at the address base), begins at the
location
For two-dimensions,
Reaching Definitions
The definitions that may reach a program point along some
path are known as reaching definitions
"Reaching definitions" is one of the most common, and useful
data-flow schemas
Uses
a compiler knows whether a program variable x is
Dynamic Programming Algorithm
Compute bottom-up for each node n of the expression tree T an
array C of costs, in which the ith component C[i] is the optimal cost
of computing the subtree S rooted at n into a register, assuming i
registers are available f
DATA FLOW ANALYSIS
Optimizations depend on data flow analysis
Data-flow analysis
techniques that derive information about the flow
of data along program execution paths
Execution path / path
Program state
consists of the values of all the variables
Affine array accesses
shows how we model array index functions
that map each loop iteration to the array
locations accessed by the iteration
Affine array accesses functions
each array index is expressed as affine expressions
of loop indexes and symbolic
Optimization of Basic Blocks
Optimization
to improve speed or reduce code size
Global optimization are performed across basic blocks
Local optimization are only performed on single basic blocks
Optimizations must be safe and preserve the meaning of t
Target Machine Model
Instructions
load and store
Computation
Jump: conditional and unconditional jumps
n general-purpose registers, RO, R1, . . . , Rn 1
Assume that all operands are integers
Most instructions consists of an operator, followed by a
PEEPHOLE
OPTIMIZATION
Introduction
Some compilers generate naive code and then improve the quality of
the target code by applying optimizing transformations to the target
program
But there is no guarantee that the resulting code is optimal under any
mat
Optimizing for Parallelism
and Locality
Goal
How a compiler can enhance
Parallelism
Locality
in computationally intensive programs involving
arrays to speed up target programs running on
multiprocessor systems
Introduction
Parallelism one way to spee
Available Expressions
An expression x + y is available at a point p if
Every path from the entry node to p evaluates x + y
after the last such evaluation prior to reaching p, there are
no sequent assignments to x or y
A block generates expression x +
Basic Blocks & Flow Graphs
Partition the intermediate code into basic blocks to help in
code generation
Useful for
Register allocation
Instruction selection
Basic Blocks
Definition: maximal sequence of consecutive instructions such
that
Control ente
Code generator
Last phase of compiler
Input: intermediate representation + symbol table information
Output: target program
The target program must
preserve the semantic meaning of the source program
be of high quality
the code generator it self mu
The Principal Sources
of Optimization
A compiler optimization must preserve the semantics of the original
program
A compiler cannot replace a program with a substantially different
and more efficient algorithm
A compiler knows only how to apply relativ
Iteration spaces
Shows how we model the individual
iterations in a loop nest
Constructing Iteration Spaces from Loop
Nests
Assumptions
Each loop has a single loop index
The loop index is incremented by 1 at each iteration
The bounds of the loop should
DATA REUSE
shows how to determine which iterations in
a loop refer to the same array location or the
same cache line using standard linear
algebra algorithms
Information useful for locality optimization and
parallelization got from array access functions
Learning DFA from Simple Examples*
RAJESH PAREKH
rpare@allstate.com
Allstate Research and Planning Center, 321 Middlefield Road, Menlo Park CA 94025, USA
VASANT HONAVAR*
honavar@cs.iastate.edu
Department of Computer Science, Iowa State University, Ames IA
Regular
Expressions
Theory and
Jeff Schoolcraft
Practice
MDCFUG 12/13/2005
Who am I?
Jeff Schoolcraft
Senior Architect / Operations
Manager at RGII Technologies.
Speaker at Usergroups
President WinProTeam Vienna
Usergroup (.NET)
TDD Evangelist
Tool guy
Wh
Theory of Computation
Shakir Al Faraji
Computer Science Dept.,
Petra University
Amman - Jordan.
email: shussain@uop.edu.jo
Thank you,
Dr. Shakir Al Faraji
Shakir
IMPORTANT NOTES
Students
This presentation is designed to be used in
class as part of a guide
For Evaluation Only.
Copyright (c) by VeryPDF.com Inc
Edited by VeryPDF PDF Editor Version 2.6
Prepared by: Trupti Kodinariya (AITS)
Example of Deterministic Finite Automata
(abc+)+
Construct a DFA to accept a string containing a zero followed by a one
Co
Notesengine.com
CIS511
Introduction to the Theory of Computation
Formal Languages and Automata
Models of Computation
Jean Gallier
May 25, 2008
Notesengine.com
2
Notesengine.com
Chapter 1
Basics of Formal Language Theory
1.1
Generalities, Motivations, Prob
Regular Expressions
and
Finite State Automata
With thanks to Steve Rowe at CNLP
Introduction
Regular expressions are equivalent to Finite State
Automata in recognizing regular languages, the first
step in the Chomsky hierarchy of formal languages
The te
Solutions to CSE 322 Homework #3
Himanshu Nautiyal
1.
(a) Intuition: As per the hint the machine has 5 states. The logic is that we
number these states by the integers from 0 to 4 inclusive. Then, at any point
of time we attempt to keep the DFA in the sta
Regular expressions
Sipser 1.3 (pages 63-76)
Looks familiar
CS 311
Fall 2008
2
Your turn now!
CS 311
Fall 2008
3
Formally
Definition 1.52:
Say that R is a regular expression if R is
1.
2.
3.
4.
5.
a for some a in the alphabet
(R1R2), where R1 and R2 are
Regular Expressions and Languages
A regular expression is a notation to represent languages, i.e. a
set of strings, where the set is either finite or contains strings that
are generated using simple recursive rules. The languages
represented by regular ex
DFA to Regular Expressions
Proposition: If L is regular then there is a regular expression r such that
L = L(r).
Proof Idea: Let M = (Q, , , q1 , F ) be a DFA recognizing L, with
Q = cfw_q1 , q2 , . . . qn , and F = cfw_qf1 , . . . qfk
Construct regular
Regular Expressions
Regular Expressions
Notation to specify a language
Declarative
Sort of like a programming language.
Fundamental in some languages like perl and applications like
grep or lex
Capable of describing the same thing as a NFA
The two a
2.7. FINITE STATE AUTOMATA WITH OUTPUT: TRANSDUCERS
2.7
61
Finite State Automata With Output: Transducers
So far, we have only considered automata that recognize
languages, i.e., automata that do not produce any output
on any input (except accept or rejec
Regular Expression
A regular expression is a template
that either matches or doesnt
match a given string.
Regular Expression: simple
patterns
$_=yabbadabba;
#patternmatchreturnatrueorfalse
if($_=~/abba/)
cfw_
printItmatched!\n
Regular Expression:
Dot (.)