two and three pass compiler architecture, Slides of Compiler Construction

basic concept s of two and three pass compiler architecture.

Typology: Slides

2019/2020

Uploaded on 10/31/2020

daniyal-abbasi
daniyal-abbasi 🇵🇰

5 documents

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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

Partial preview of the text

Download two and three pass compiler architecture and more Slides Compiler Construction in PDF only on Docsity!

Compiler

Construction

Lecture 4

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

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

The Back End

Register Allocation:  Optimal register allocation is NP-Complete. Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR

The Back End

Instruction Scheduling:  Use all functional units productively. Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR

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

Three-pass Compiler

 Analyzes IR and rewrites (or transforms ) IR Front End Source code machine code errors Middle End Back End

IR IR

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

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

Optimizer

 Modern optimizers are structured as a series of passes Opt 1

IR IR

errors Opt 2 Opt n

IR

IR Opt 3

IR

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

Optimizer

Typical transformations

Specialize some computation based on context Opt 1

IR IR

errors Opt 2 Opt n

IR

IR Opt 3

IR

Optimizer

Typical transformations  Remove useless or unreachable code Opt 1

IR IR

errors Opt 2 Opt n

IR

IR Opt 3

IR

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