Abstract
A bottom up- and a top down pattern matching algorithm for code selection are presented. The setting is the same as in [AhGa84]. First all covers of the intermediate representation (IR) are computed, and cheapest ones are determined by dynamic programming. Then code selection proper is performed. While Graham-Glanville-like code generators ([GlGr78],[Glan77]) use dynamic targeting, i.e. by selecting appropriate productions at reduction time, and while Aho- Ganapathi shift the targeting task to the semantic attributes and functions, the two algorithms presented in this paper use static targeting. Targeting rules, i.e. rules with patterns of depth 1, are simulated in the states of the recognizing automata. Therefore, all covers found for an IR are adequate as far as no semantic constraints are concerned. The bottom up approach suffers from the theoretical worst case complexity, i.e. the (static) size of the automata may grow exponentially with the size of the machine description. The top down approach has a linear (static) size of the automaton, but a dynamic size, i.e. the size of additional data structures, of |IR| * |machine description|. The bottom up approach has been implemented as a modification of the OPTRAN bottom up pattern matcher generator [Weis83].
Chapter PDF
Similar content being viewed by others
6. References
A.V. Aho, M.J.Corasick, Efficient String Matching: An Aid to Bibliographic Search, CACM, June 1975, Vol. 18, Nr. 6
A.V. Aho, S.C. Johnson, Optimal Code Generation for Expression Trees, JACM, Vol. 23, No 3, July 1976
A.V. Aho, M. Ganapathi, Efficient Tree Pattern Matching: An Aid to Code Generation, POPL 1985
M. Ganapathi, C.N. Fischer, Description-Driven Code Generation Using Attribute Grammars, POPL 1982
R. Giegerich, K. Schmal, Code Selection Techniques: Pattern Matching, Tree Parsing, and Inversion of Derivors, Proceedings of ESOP'88, LNCS 300, Springer Verlag 1988
R. Giegerich, Code Selection by Inversion of Order-Sorted Derivors, to appear in Theoretical Computer Science, North Holland
R.S. Glanville, A Machine Independent Algorithm for Code Generation and its Use in Retargetable Compilers, PhD Dissertation, University of California, Berkley, December 1977
R.S. Glanville, S.L. Graham, A New Method for Compiler Code Generation, POPL 1978
R.R. Henry, Graham Glanville Code Generators, PhD Dissertation, University of California, Berkley, 1984
D.M. Hoffman, M.J. O'Donnell, Pattern Matching in Trees, JACM 29,1, 1982
H. Kron, Tree Templates and Subtree Transformational Grammars, PhD Dissertation, University of California, Santa Cruz, 1975
H. Lunell, Code Generator Writing Systems, Software System Research Center, Linköping, Sweden, 1983
U. Möncke, Generierung von Systemen zur Transformation attributiertern Operatorbäume: Komponenten des Systems und Mechanismen der Generierung, Dissertation, Universität des Saarlandes, Saarbrücken, 1985
U. Möncke, B. Weisgerber, R. Wilhelm, Generative Support for Transformational Programming, ESPRIT Technical Week, 1985
B. Weisgerber, Attributierte Transformationsgrammatiken: Die Baumanalyse und Untersuchungen zu Transformationsstrategien, Diplomarbeit, Universität des Saarlandes, Saarbrücken, 1983
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1989 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Weisgerber, B., Wilhelm, R. (1989). Two tree pattern matchers for code selection. In: Hammer, D. (eds) Compiler Compilers and High Speed Compilation. CCHSC 1988. Lecture Notes in Computer Science, vol 371. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-51364-7_17
Download citation
DOI: https://doi.org/10.1007/3-540-51364-7_17
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-51364-3
Online ISBN: 978-3-540-46200-2
eBook Packages: Springer Book Archive