Chapter 8: Intermediate Code Generation

Code Generation

. Generate three address code needed to evaluate arguments which are expressions

. Generate a list of param three address statements

. Store arguments in a list

S call id ( Elist )

for each item p on queue do emit('param' p)

emit('call' id.place)

Elist Elist , E

append E.place to the end of queue

Elist E

initialize queue to contain E.place

For code generation, we generate three address code which is needed to evaluate arguments that are in fact expressions. As a result a list of param three address statements are generated. This is a syntax-directed translation and gives: param p 1 ; param p2 ; param pn ; call id.place Note that each of the expression will also generate 3ac code