Three pass Compiler, Optimizer - Compiler Construction - Lecture Slides, Slides of Compiler Construction

Three pass Compiler, Optimization, Intermediate stage, Transforms, Series of passes, Typical transformations, Role of Run time System are basic concepts discussed of course.

Typology: Slides

2011/2012

Uploaded on 11/03/2012

ekavia
ekavia 🇮🇳

4.3

(58)

241 documents

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Compiler
Construction
Lecture 4
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Three pass Compiler, Optimizer - Compiler Construction - Lecture Slides and more Slides Compiler Construction in PDF only on Docsity!

Compiler

Construction

Lecture 4

2

The Back End

Register Allocation:

 Have each value in a register

when it is used.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

4

The Back End

Register Allocation:

 Can change instruction choices

and insert LOADs and STOREs.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

5

The Back End

Register Allocation:

 Optimal register allocation is

NP-Complete.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

7

The Back End

Instruction Scheduling:

 Use all functional units

productively.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

8

The Back End

Instruction Scheduling:

 Optimal scheduling is

NP-Complete in nearly all cases.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

10

Three-pass Compiler

 Analyzes IR and rewrites (or

transforms ) IR

Front End

Source code

machine code

errors

Middle End

Back End

IR IR

11

Three-pass Compiler

 Primary goal is to reduce

running time of the compiled

code

Front End

Source code

machine code

errors

Middle End

Back End

IR IR

13

Three-pass Compiler

 Must preserve “meaning” of the

code.

 Measured by values of named

variables

Front End

Source code

machine code

errors

Middle End

Back End

IR IR

14

Optimizer

 Modern optimizers are

structured as a series of

passes

Opt 1

IR IR

errors

Opt 2

Opt n

IR (^) IR Opt 3

IR

16

Optimizer

Typical transformations

 Move a computation to a less

frequently executed place

Opt 1

IR IR

errors

Opt 2

Opt n

IR (^) IR Opt 3

IR

17

Optimizer

Typical transformations

 Specialize some computation

based on context

Opt 1

IR IR

errors

Opt 2

Opt n

IR (^) IR Opt 3

IR

19

Optimizer

Typical transformations

 Remove useless or

unreachable code

Opt 1

IR IR

errors

Opt 2

Opt n

IR (^) IR Opt 3

IR

20

Optimizer

Typical transformations

 Encode an idiom in some

particularly efficient form

Opt 1

IR IR

errors

Opt 2

Opt n

IR (^) IR Opt 3

IR