Regular Expressions
A regular expression is a pattern that defines a
string or portion thereof. When comparing this
pattern against a string, it'll either be true or
false. If true, it'll return something.
The return value will depend on the specific
fu

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

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

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 +

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

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

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

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

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

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

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

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

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,

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

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

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 (.)

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 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

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 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

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

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
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

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

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

Theory of Computation
Shakir Al Faraji
Computer Science Dept.,
Petra University
Amman - Jordan.
email: [email protected]
Thank you,
Dr. Shakir Al Faraji
Shakir
IMPORTANT NOTES
Students
This presentation is designed to be used in
class as part of a guide

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

Learning DFA from Simple Examples*
RAJESH PAREKH
[email protected]
Allstate Research and Planning Center, 321 Middlefield Road, Menlo Park CA 94025, USA
VASANT HONAVAR*
[email protected]
Department of Computer Science, Iowa State University, Ames IA