Skip to main content

Compiling Three-Address Code for C Programs

01 February 1981

New Image

The portable C compiler1 is an effective tool for quickly constructing a C compiler2 for a general purpose digital computer. With reasonable effort the resulting compiler generates correct code, and the quality of the translation into assembly language is acceptable. However, users frequently demand better code if they anticipate prolonged or extensive use of programs written for a particular application. A post processor that reads the assembly language generated by the compiler and writes better assembly language having the equivalent effect can satisfy much of the demand. (Here "better" code requires fewer bytes for instructions or less time to execute, or both.) This paper describes a program that improves code generated for the Digital Equipment Corporation VAX-11® computer, paying particular attention to the technique used to transform two-address codes into three-address codes. One reason why a code improver can be effective is that the portable C compiler often generates code in the easiest possible correct manner, even if such a code is suboptimal over a wide range of machines. The COMPILING THREE-ADDRESS CODE 159