
250 Compilers – Principles and Practice
On the other hand, for 4-tuple IR, we generate an entry by popping the top two tcount from the
stack and assigning next tcount to the result. Then we should push the result tcount on the
tstack.
expr: INT { $$ = $1; fprintf(fout1,"%s\n", name($1));
fprintf(fout2,"%d: LD %s T%d --\n",++mcount,name($1),
++tcount);tpush(tcount);}
| NUMBER { $$ = $1; fprintf(fout1,"%s\n", name($1));
fprintf(fout2,"%d: LD %s T%d --\n",++mcount,name($1),
++tcount);tpush(tcount);}
| VAR { $$ = $1; fprintf(fout1,"%s\n", name($1));
fprintf(fout2,"%d: LD %s T%d --\n",++mcount,name($1),
++tcount);tpush(tcount);}
| IVAR { $$ = ...