High-quality code generation via bottom-up tree pattern matching

High-quality local code generation is one of the most difficult tasks the compiler-writer faces. Even if register allocation decisions are postponed and common subexpressions are ignored, instruction selection on machines with complex addressing can be quite difficult. Efficient and general algorithms have been developed to do instruction selection, but these algorithms fail to always find optimal solutions. Instruction selection algorithms based on dynamic programming or complete enumeration always find optimal solutions, but seem to be too costly to be practical. This paper describes a new instruction selection algorithm, and its prototype implementation, based on bottom-up tree pattern-matching. This algorithm is both time and space efficient, and is capable of doing optimal instruction selection for the DEC VAX-11 with its rich set of addressing modes.

[1]  Alfred V. Aho,et al.  Efficient Tree Pattern Matching: An Aid to Code Generation. , 1985 .

[2]  Bruce R. Schatz,et al.  An Overview of the Production-Quality Compiler-Compiler Project , 1980, Computer.

[3]  Christoph M. Hoffmann,et al.  Pattern Matching in Trees , 1982, JACM.

[4]  R. Nigel Horspool,et al.  Automating the selection of code templates , 1985, Softw. Pract. Exp..

[5]  Philippe Aigrain,et al.  Experience with a Graham-Glanville style code generator , 1984, SIGPLAN '84.

[6]  David W. Krumme,et al.  A practical method for code generation based on exhaustive search , 1982, SIGPLAN '82.

[7]  Andrew S. Tanenbaum,et al.  A practical tool kit for making portable compilers , 1983, Commun. ACM.

[8]  Susan L. Graham,et al.  An experiment in table driven code generation , 1982, SIGPLAN '82.

[9]  Mahadevan Ganapathi Retargetable code generation and optimization using attribute grammars , 1980 .

[10]  R. G. G. Cattell,et al.  Automatic Derivation of Code Generators from Machine Descriptions , 1980, TOPL.

[11]  Roderic Geoffrey Galton Cattell,et al.  Formalization and Automatic Derivation of Code Generators , 1982 .

[12]  Uwe Schmidt,et al.  A multi-language compiler system with automatically generated codegenerators , 1984, SIGPLAN '84.

[13]  Thomas W. Christopher,et al.  Using dynamic programming to generate optimized code in a Graham-Glanville style code generator , 1984, SIGPLAN '84.

[14]  Philip John Hatcher A tool for high-quality code generation (compiling) , 1985 .

[15]  Charles N. Fischer,et al.  Retargetable Compiler Code Generation , 1982, CSUR.

[16]  Ralph E. Griswold,et al.  The Icon programming language , 1983 .

[17]  Stephen C. Johnson A portable compiler: theory and practice , 1978, POPL.

[18]  Alfred V. Aho,et al.  Efficient tree pattern matching (extended abstract): an aid to code generation , 1985, POPL '85.

[19]  Robert Steven Glanville,et al.  A Machine Independent Algorithm for Code Generation and Its Use in Retargetable Compilers , 1977 .

[20]  Robert Rettig Henry Graham/glanville code generators (compiler, parser, programming language) , 1984 .

[21]  L HennessyJohn,et al.  Retargetable Compiler Code Generation , 1982 .