













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Code Generation, Requirements, Issues, Memory management, Instruction Selection, Instruction Scheduling, Assembly Language are basic concepts discussed of course.
Typology: Slides
1 / 21
This page cannot be seen from the preview
Don't miss anything!














2
The code generation problem
is the task of mapping intermediate code to machine code.
4
Input language: intermediate
code (optimized or not)
Target: machine code,
assembly language
5
Memory management: mapping names to data objects in the run-time system.
Instruction Selection
Instruction Scheduling
Register allocation
7
Memory management: mapping names to data objects in the run-time system.
Instruction Selection
Instruction Scheduling
Register allocation
8
Memory management: mapping names to data objects in the run-time system.
Instruction Selection
Instruction Scheduling
Register allocation
10
Target: Assembly Language
Operations:
11
MODE FORM ADDRESS ADDED COST absolute M M 1 register R R 0 indexed c(R) c + contents(R) 1 indirect register *R contents(R) 0 indirect indexed *c(R) contents(c+contents(R)) 1 literal #c c 1 stack SP SP 0 indexed stack c(SP) c + contents(SP) 1
13
Define a target code sequence for each intermediate code statement type.
14
Intermediate becomes… a = b MOV b,a
a = b[c] MOV addr(b),R ADD c, R MOV *R0,a
16
Consider the C statement: a[i] = b[c[j]]; t1 := c[j] MOV addr(c), R ADD j, R MOV *R0, t t2 := b[t1] MOV addr(b), R ADD t1, R MOV *R0, t a[i] := t2 MOV address(a), R ADD i, R MOV t2, *R The cost of this code is 18 and we are forced to allocate space for two temporaries.
17
Local decisions do not produce good code. Do not take temporary variables into account
20
MOV addr(c), R ADD j, R MOV addr(a), R ADD i, R MOV *addr(b)(R0), *R
The cost of this code is 10.