Apresente o código de três endereços, otimizado pela aplicação do método de construção de um grafo acíclico dirigido para blocos básicos, da seguinte sequência de comandos:
x = x + y * z;
y = z * x + y * z;
z = z * x + y * z;
sobre a gramática livre de contexto apresentada a seguir:
G = ({A, E, T, F, V}, {x, y, z, =, +, -, *, /, (, )}, P, A)
P = {A → V=E
E → E+T | E-T | T
T → T*F | T/F | F
F → (E) | V
V → x | y | z}
oper | arg1 | arg2 | result | |
---|---|---|---|---|
(0) | * | y | z | T1 |
(1) | + | x | T1 | T2 |
(2) | = | T2 | x | |
(3) | * | z | x | T3 |
(4) | * | y | z | T4 |
(5) | + | T3 | T4 | T5 |
(6) | = | T5 | y | |
(7) | * | z | x | T6 |
(8) | * | y | z | T7 |
(9) | + | T6 | T7 | T8 |
(10) | = | T8 | z |
oper | arg1 | arg2 | result | |
---|---|---|---|---|
(0) | * | y | z | T1 |
(1) | + | x | T1 | T2 |
(2) | = | T2 | x | |
(3) | * | z | T2 | T3 |
(4) | + | T3 | T1 | T4 |
(5) | = | T4 | y | |
(6) | * | T4 | z | T5 |
(7) | + | T3 | T5 | T6 |
(8) | = | T6 | z |