04-03localOptimizations

04-03localOptimizations - Administrivia Code generation...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CSE 450: Compilers K. Stirewalt Code generation Local optimizations Topics: – Forms of optimization – Local optimizations Readings: Dragon Book 8.4 – 8.5 CSE 450: Compilers K. Stirewalt Administrivia Project 5 deadline extended by one week to Friday, April 18 th – involves changes to scope of project #6, which will be due Friday, April 25 th – there will be no Quiz #9 Quiz #8 rescheduled to Wednesday, April 16 th Final exam: Friday, May 2 nd from 10:00-12:00 noon in this room CSE 450: Compilers K. Stirewalt Project #6 Involves a hand translation of 3-address code generated by your compiler into target code We will provide two small SpartanAda programs as source You must use your compiler to generate the IR from these programs; then translate each statement in sequence into the target code Deliverable will be a written document and may include any explanatory text you deem appropriate Due Friday, April 25 th CSE 450: Compilers K. Stirewalt Questions??? CSE 450: Compilers K. Stirewalt Recall. .. If efficiency is not of concern, then we can translate 3-address instructions one by one, in isolation, to generate target code However, this strategy leads to terribly inefficient code More efficient strategies consider more context during translation Several key ideas and algorithms: – Liveness analysis based on control-flow graph – Local vs. global optimizations – Register-allocation strategies/algorithms CSE 450: Compilers K. Stirewalt Control flow graph Directed-graph model of a subprogram: – Nodes represent three-address instructions (or straight line sequences of instructions) – Edges represent branches from one instruction to another Used to model how values flow from definitions to uses Central to reasoning about the context in which decisions, such as register allocation, must be made
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 CSE 450: Compilers K. Stirewalt Example control flow graph a = b + c d = -a e = d + f if e > 3 goto B1 f = 2 * e b = d + e e = e - 1 b = f + c if b > 2 goto B0 Nodes contain basic blocks of 3-address code B0 B1 B2 B4 CSE 450: Compilers K. Stirewalt Good intermediate representation. .. Should be: • easily generated from syntax trees • easy to then convert it to assembly language This entails: - simple interface with as few commands as needed - designed to support common optimizations - flexible commands that can be retargeted to just about any assembly language CSE 450: Compilers K. Stirewalt Issues Intermediate code translations are straightforward, but inefficient ! – Lots of temporaries – Lots of labels – Lots of instructions Can we do this more intelligently? – Should we worry about it? CSE 450: Compilers K. Stirewalt Optimization Overview Optimization seeks to improve a program’s utilization of some resource – Execution time (most often) – Memory footprint – Code size Must not alter what the program computes - all outputs must remain the same. CSE 450: Compilers
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/25/2008 for the course CSE 450 taught by Professor Stirewalt during the Spring '08 term at Michigan State University.

Page1 / 12

04-03localOptimizations - Administrivia Code generation...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online