Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article
Open access

Code generation using tree matching and dynamic programming

Published: 01 October 1989 Publication History

Abstract

Compiler-component generators, such as lexical analyzer generators and parser generators, have long been used to facilitate the construction of compilers. A tree-manipulation language called twig has been developed to help construct efficient code generators. Twig transforms a tree-translation scheme into a code generator that combines a fast top-down tree-pattern matching algorithm with dynamic programming. Twig has been used to specify and construct code generators for several experimental compilers targeted for different machines.

References

[1]
AHO, A. V., AND CORASICK, M.J. Efficient string matching: An aid to bibliographic search. Commun. ACM 18, 6 (June 1975), 333-340.
[2]
AHO, A. V., AND GANAPATHI, M. Efficient tree pattern matching: An aid to code generation. In Proceedings of the 12th ACM Symposium on Principles of Programming Languages. ACM, New York, 1985, pp. 334-340.
[3]
AHO, A. V., AND JOHNSON, S.C. Optimal code generation for expression trees, J. ACM 23, 3 (1976), 488-501.
[4]
AHO, A. V., JOHNSON, S. C., AND ULLMAN, J.D. Code generation for expressions with common ' subexpressions. J. ACM 24, i (1977), 146-160.
[5]
AHO, A. V., JOHNSON, S. C., AND ULLMAN, J.D. Code generation for machines with multiregister operations. In Proceedings of the 4th ACM Symposium on Principles of Programming Languages. ACM, New York, 1977, pp. 21-28.
[6]
AHO, A. V., JOHNSON, S. C., AND ULLMAN, J.D. Deterministic parsing of ambiguous grammars. Commun. ACM 18, 8 (Aug. 1975), 441-452.
[7]
AHO, A. V., SETHI, R., AND ULLMAN, J. D. Compilers: Principles, Techniques, and Tools. Addison-Wesley, Reading, Mass., 1986.
[8]
AIGRAIN, P., GRAHAM, S., HENRY, R., MCKUSICK, M., AND PELEGRI-LLOPART, E. Experience with a Graham-Glanville style code generator. In Proceedings of the ACM SIGPLAN Symposium on Compiler Construction, ACM SIGPLAN Notices 19, 6 (June 1984), 13-24.
[9]
APPEL, A.W. Concise specifications of locally optimal code generators. Tech. Rep. CS-TR-080- 87, Dept. of Computer Science, Princeton University, Princeton, N.J., Feb. 1987.
[10]
BRUNO, J., AND SETHI, R. Code generation for a one-register machine. J. ACM 23, 3 (1976), 502-510.
[11]
CATTELL, R. G.G. Automatic derivation of code generators from machine descriptions. ACM Trans. Program. Lang. Syst. 2, 2 (April 1980), 173-190.
[12]
CHOW, P., AND HOROWITZ, M. The MIPS-X microprocessor. In Proceedings of Wescon 1985 (San Francisco, Nov. 19-21, 1985). IEEE, New York, sec. 6-1, pp. 1-6.
[13]
DAVIDSON, J. W., AND FRASER, C.W. Code selection through object code optimization. ACM{ Trans. Program. Lang. Syst. 6, 4 (Oct. 1984), 505-526.
[14]
DENCKER, P., DURRE, K., AND HEUFT, J. Optimization of parser tables for portable compilers. ACM Trans. Program. Lang. Syst. 6, 4 (Oct. 1984), 546-572.
[15]
FRASER, C.W. Automatic generation of code generators. Ph.D. dissertation, Yale University, New Haven, Conn., 1977.
[16]
FRASER, C. W., AND WENDT, A. Integrating code generation and optimization. In Proceedings of ACM SIGPLAN Symposium on Compiler Construction, ACM SIGPLAN Notices 21, 6 (June 1986), 242-248.
[17]
GANAPATHI, M., AND FISCHER, C. N. Affix grammar driven code generation. ACM Trans. Program. Lang. Syst. 7, 4 (Oct. 1985), 560-599.
[18]
GANAPATHI, M., AND FISCHER, C.N. Attributed linear intermediate representations for retargetable code generators. Softw. Pract. Exper. 14 (April 1984), 347-364.
[19]
GANAPATHI, M., AND FISCHER, C.N. Description-driven code generation using attribute grammars. In Proceedings of the 9th Annual A CM Symposium on Principles of Programming Languages. ACM, New York, 1982, pp. 108-119.
[20]
GANAPATHI, M., AND FISCHER, C.N., Integrating code generation and peephole optimization. Acta Inf. 25 (Jan. 1988), 85-109.
[21]
GANAPATHI, M., FISCHER, C. N., ANO HENNESSY, J.L. Retargetable compiler code generation. ACM Comput. Surv. 14, 4 (Dec. 1982), 573-592.
[22]
GLANVILLE, R. S. A machine independent algorithm for code generation and its use in retargetable compilers. Ph.D. dissertation, University of California, Berkeley, Dec. 1977.
[23]
GLANVILLE, R. S., AND GRAHAM, S. L. A new method for compiler code generation. In Proceedings of the 5th Annual ACM Symposium on Principles of Programming Languages. ACM, New York, 1978, pp. 231-240.
[24]
GLASNER, I., MONCKE, U., AND WILHELM, R. OPTRAN, a language for the specification of program transformations. Inf. Fach., 1980, 125-142.
[25]
GRAHAM, S.L. Table-driven code generation. IEEE Comput. 13, 8 (Aug. 1980), 25-34.
[26]
GRAHAM, S. L., HENRY, R. R., AND SCHULMAN, R. A. An experiment in table driven code generation. In Proceedings of the ACM SIGPLAN Symposium on Compiler Construction, ACM SIGPLAN Notices 17, 6 (June 1982), 32-43.
[27]
HATCHER, P. J., AND CHRISTOPHER, T.W. High-quality code generation via bottom-up tree pattern matching. In Proceedings of the 11th Annual ACid? Symposium on Principles of Programming Languages. ACM, New York, 1986, pp. 119-130.
[28]
HATCHER, P. J., KUKUCK, R. C., AND CHRISTOPHER, T W. Using dynamic programming to generate optimized code in a Graham-Glanville style cod4~ generator. In Proceedings of the ACM SIGPLAN Symposium on Compiler Construction, ACM SIGPLAN Notices 19, 6 (June 1984), 25-36.
[29]
HENRY, R.R. Graham-Glanville code generators. Ph.D. dissertation, Computer Science Division, Electrical Engineering and Computer Science, Univ,~rsity of California, Berkeley, 1984.
[30]
HOFFMAN, C. W., AND O'DONNELL, M.J. Pattern metching in trees. J. ACM 29, i (1982), 68-95.
[31]
HUET, G., AND LEVY, J.-J. Call by need computations ill non-ambiguous linear term rewriting systems. Tech. Rep. 359, IRIA Laboria, LeChesnay, France, 1979.
[32]
JOHNSON, S. C. A portable compiler: Theory and practice. In Proceedings of the 5th ACM Symposium on Principles of Prograrnming Languages. AC VI, New York, 1978, pp. 97-104.
[33]
KEUTZER, K. Dagon: Technology binding and local optimization by dag matching. In Proceedings of the 24th Design Automation Conference. ACM/IEF, E, New York, 1987, pp. 341-347.
[34]
KEUTZER, K., AND WOLF, W. Anatomy of a hardware compiler. In Proceedings of the ACM SIGPLAN '88 Conference on Programming Language Design and Implementation, ACM SIG- PLAN Notices 23, 7 (July 1988), 95-104.
[35]
KRON, H. Tree templates and subtree transformational grammars. Ph.D. dissertation, University of California, Santa Cruz, 1975.
[36]
LANG, H.-W., SCHIMMLER, M., AND SCHMECK, H. Me tching tree patterns sublinear on the average. Tech. Rep. Dept. of Informatik, University of Kisl, Kiel, West Germany, 1980.
[37]
LUNELL, H. Code Generator Writing Systems. Software Systems Research Center, S-58183, Linkoping, Sweden, 1983.
[38]
PELEGRI-LLOPART, E., AND GRAHAM, S.L. Optimal coJe generation for expression trees: An application of BURS theory. In Proceedings of the 15th zmnual ACM Symposium on Principles of Programming Languages. ACM, New York, 1988, pp. 294-308.
[39]
RIPKEN, K. Formale Beschreibun von Maschinen, Implementierungen und Optimierender Maschinen-codeerzeugung aus Attributierten Programml,~raphe. Tech. Rep. TUM-INFO-7731, Institut fur Informatik, Technische Universitat Munchen, Munich, West Germany, July 1977.
[40]
SETHI, R. AND ULLMAN, J. D. The generation of optimal code for arithmetic expressions. J. ACM 17, 4 (1970), 715-728.
[41]
SNYDER, L. Recognition and selection of idioms for code optimization. Acta Inf. 17 (1982), 327-348.
[42]
TJIANG, S. W. K. Twig reference manual. Computing Science Tech. Rep. 120, AT&T Bell Laboratories, Murray Hill, N.J., 1985.
[43]
WASILEW, S.G. A compiler writing system with optimization capabilities for complex order structures. Ph.D. dissertation, Northwestern University, Evanston, Ill., 1972.
[44]
WEINOART, S. W. An efficient and systematic method of compiler code generation. Ph.D.{ dissertation, Computer Sciences Dept., Yale University, lYew Haven, Com., 1973.
[45]
WULF, W.A. PQCC: A machine-relative compiler technology. In Proceedings of the IEEE 4th International COMPSAC Conference. IEEE, New York, 1980, pp. 24-36.
[46]
WULF, W., LEVERETT, B., CATTELL, R., HOBBS, S., NEV~ COMER, J., REINER, A., AND SCHATZ, B. An overview of the production quality compiler-compiler project. IEEE Comput. 13, 8 (Aug. 1980), 38-49.

Cited By

View all
  • (2024)Automating application-driven customization of ASIPs: A surveyJournal of Systems Architecture10.1016/j.sysarc.2024.103080148(103080)Online publication date: Mar-2024
  • (2024)Forward linearised tree pattern matching using tree pattern border arrayDiscrete Applied Mathematics10.1016/j.dam.2024.03.014352:C(33-43)Online publication date: 31-Jul-2024
  • (2023)Source Matching and Rewriting for MLIR Using String-Based AutomataACM Transactions on Architecture and Code Optimization10.1145/357128320:2(1-26)Online publication date: 1-Mar-2023
  • Show More Cited By

Recommendations

Reviews

Martin Joseph Jourdan

This paper describes a locally optimal code generation technique based on top-down tree pattern matching and dynamic programming, together with its implementation in the form of a language and system called twig. Although both subtechniques have long been recognized as effective aids for code generation, their combination is original and quite attractive; in particular, it is a step toward the purely declarative specification of code generators. The value of this approach is confirmed by practical experiments with twig, which meets its goals with quite acceptable efficiency. The paper is well written and generally convincing, especially the theoretical material, but it suffers from several defects. First, the publication delays were exceptionally long, so the results appear somewhat out-of-date. Second, the approach is only compared with parsing- and attribute-grammar-based approaches, which is unfair since their weaknesses were recognized long ago; comparisons with other tree matching techniques, especially bottom-up approaches, would be more significant. Third, a twig specification loses some declarativeness because many aspects of the code generation process must be performed by hand; in addition, the use of the TOPDOWN modifier, which allows the designer to influence the pattern-matching process, is insufficiently documented and seems a bit dangerous. Fourth, twig does not specify complete code generators but merely instruction selectors: the authors completely overlook other aspects, such as register allocation and instruction scheduling, that are becoming more and more important on today's machines. Nevertheless, the basic idea of paper is valuable, and engineers working on practical problems in retargetable code generation could find a starting point for good solutions.

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Comments

Information & Contributors

Information

Published In

cover image ACM Transactions on Programming Languages and Systems
ACM Transactions on Programming Languages and Systems  Volume 11, Issue 4
Oct. 1989
178 pages
ISSN:0164-0925
EISSN:1558-4593
DOI:10.1145/69558
  • Editor:
  • Susan L. Graham
Issue’s Table of Contents

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 October 1989
Published in TOPLAS Volume 11, Issue 4

Permissions

Request permissions for this article.

Check for updates

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)793
  • Downloads (Last 6 weeks)58
Reflects downloads up to 13 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Automating application-driven customization of ASIPs: A surveyJournal of Systems Architecture10.1016/j.sysarc.2024.103080148(103080)Online publication date: Mar-2024
  • (2024)Forward linearised tree pattern matching using tree pattern border arrayDiscrete Applied Mathematics10.1016/j.dam.2024.03.014352:C(33-43)Online publication date: 31-Jul-2024
  • (2023)Source Matching and Rewriting for MLIR Using String-Based AutomataACM Transactions on Architecture and Code Optimization10.1145/357128320:2(1-26)Online publication date: 1-Mar-2023
  • (2023)BibliographyEngineering a Compiler10.1016/B978-0-12-815412-0.00023-1(793-813)Online publication date: 2023
  • (2023)Instruction SelectionEngineering a Compiler10.1016/B978-0-12-815412-0.00017-6(575-616)Online publication date: 2023
  • (2023)Retargetable CompilationHandbook of Computer Architecture10.1007/978-981-15-6401-7_67-1(1-42)Online publication date: 18-May-2023
  • (2021)LinneaACM Transactions on Mathematical Software10.1145/344663247:3(1-26)Online publication date: 26-Jun-2021
  • (2021)Embedding API dependency graph for neural code generationEmpirical Software Engineering10.1007/s10664-021-09968-226:4Online publication date: 1-Jul-2021
  • (2021)Search Space Complexity of Iteration Domain Based Instruction Embedding for Deep Learning AcceleratorsIoT Streams for Data-Driven Predictive Maintenance and IoT, Edge, and Mobile for Embedded Machine Learning10.1007/978-3-030-66770-2_16(213-228)Online publication date: 10-Jan-2021
  • (2020)Automatic Generation of Efficient Linear Algebra ProgramsProceedings of the Platform for Advanced Scientific Computing Conference10.1145/3394277.3401836(1-11)Online publication date: 29-Jun-2020
  • Show More Cited By

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media