




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





Prof. Su ECS 142 Lecture 15 1
Prof. Su ECS 142 Lecture 15 2
Prof. Su ECS 142 Lecture 15 3
Prof. Su ECS 142 Lecture 15 4
Prof. Su ECS 142 Lecture 15 5
Prof. Su ECS 142 Lecture 15 7
Prof. Su ECS 142 Lecture 15 9
igen(e 1 + e 2 , t) = igen(e 1 , t 1 ) (t 1 is a fresh register) igen(e 2 , t 2 ) (t 2 is a fresh register) t := t 1 + t (^2)
⇒ simple code generation
Prof. Su ECS 142 Lecture 15 10
Prof. Su ECS 142 Lecture 15 11
Prof. Su ECS 142 Lecture 15 12
P → S P | ε S → id := id op id | id := op id | id := id | push id | id := pop | if id relop id goto L | L: | jump L
Prof. Su ECS 142 Lecture 15 19
Prof. Su ECS 142 Lecture 15 20
Prof. Su ECS 142 Lecture 15 21
Prof. Su ECS 142 Lecture 15 22
Prof. Su ECS 142 Lecture 15 23
x := y op z
Prof. Su ECS 142 Lecture 15 24
Prof. Su ECS 142 Lecture 15 25
x := z + y b := z + y a := x ⇒ a := b x := 2 * x x := 2 * b (b is a fresh register)
Prof. Su ECS 142 Lecture 15 27
Prof. Su ECS 142 Lecture 15 28
Prof. Su ECS 142 Lecture 15 29
w := rhs appears in a basic block w does not appear anywhere else in the program
the statement w := rhs is dead and can be eliminated
x := z + y b := z + y b := z + y a := x ⇒ a := b ⇒ x := 2 * b x := 2 * a x := 2 * b Prof. Su ECS 142 Lecture 15 30
Prof. Su ECS 142 Lecture 15 37
Prof. Su ECS 142 Lecture 15 38
Prof. Su ECS 142 Lecture 15 39
Prof. Su ECS 142 Lecture 15 40
Prof. Su ECS 142 Lecture 15 41
Prof. Su ECS 142 Lecture 15 42
Prof. Su ECS 142 Lecture 15 43
f := a + a g := 6 * f
Prof. Su ECS 142 Lecture 15 44
Prof. Su ECS 142 Lecture 15 45
i 1 , …, in → j 1 , …, j (^) m where the rhs is the improved version of the lhs
move $a $b, move $b $a → move $a $b
addiu $a $a i, addiu $a $a j → addiu $a $a i+j
Prof. Su ECS 142 Lecture 15 46
Prof. Su ECS 142 Lecture 15 47