5.6 Intermediate Representation Output for miniC

Though it is possible to include actions in the yacc grammar of a language to either directly execute a program written in that language (as is done in hoc6) or directly generate a target code, we have taken the option of generating Intermediate Representation (IR) (Chapter 8) in anticipation of discussion of various optimization methods.

Any reasonable IR can be obtained by including proper action terms in the yacc grammar. Here we illustrate a small part of the final grammar with action terms for generating two kinds of IR – reverse polish notation (RPN) and 4-tuple notation. The full grammar with IR generating actions is given in Chapters 8 and 12. Here, we show IR for arithmetic expressions ...

Get Compilers: Principles and Practice now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.