05.10.2013 Views

1 Code Generation Code generator phase ... - VTU e-Learning

1 Code Generation Code generator phase ... - VTU e-Learning

1 Code Generation Code generator phase ... - VTU e-Learning

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

After topological sorting<br />

t2 = b – 1<br />

t1 = a + b<br />

a = t1<br />

t3 = b + 5<br />

b = t2<br />

Fig 9.8 DAG for the intermediate code<br />

Reordering of code helps in eliminating unnecessary use of temporaries. Hence the code would be as<br />

follows.<br />

a = a + b<br />

b = b – 1<br />

t3 = b + 5<br />

DAG gives the information of how many references exists for node. This helps in good register<br />

allocation. If a value has many references then it can be retained in registers for long time. If the<br />

value has no reference it can be removed from the register.<br />

19

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!