Advertisement

Two tree pattern matchers for code selection

  • Beatrix Weisgerber
  • Reinhard Wilhelm
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 371)

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].

6. References

  1. [AhCo75]
    A.V. Aho, M.J.Corasick, Efficient String Matching: An Aid to Bibliographic Search, CACM, June 1975, Vol. 18, Nr. 6Google Scholar
  2. [AhJo76]
    A.V. Aho, S.C. Johnson, Optimal Code Generation for Expression Trees, JACM, Vol. 23, No 3, July 1976Google Scholar
  3. [AhGa84]
    A.V. Aho, M. Ganapathi, Efficient Tree Pattern Matching: An Aid to Code Generation, POPL 1985Google Scholar
  4. [GaFi82]
    M. Ganapathi, C.N. Fischer, Description-Driven Code Generation Using Attribute Grammars, POPL 1982Google Scholar
  5. [GiSc88]
    R. Giegerich, K. Schmal, Code Selection Techniques: Pattern Matching, Tree Parsing, and Inversion of Derivors, Proceedings of ESOP'88, LNCS 300, Springer Verlag 1988Google Scholar
  6. [Gieg88]
    R. Giegerich, Code Selection by Inversion of Order-Sorted Derivors, to appear in Theoretical Computer Science, North HollandGoogle Scholar
  7. [Glan77]
    R.S. Glanville, A Machine Independent Algorithm for Code Generation and its Use in Retargetable Compilers, PhD Dissertation, University of California, Berkley, December 1977Google Scholar
  8. [GlGr78]
    R.S. Glanville, S.L. Graham, A New Method for Compiler Code Generation, POPL 1978Google Scholar
  9. [Henr84]
    R.R. Henry, Graham Glanville Code Generators, PhD Dissertation, University of California, Berkley, 1984Google Scholar
  10. [HoDo82]
    D.M. Hoffman, M.J. O'Donnell, Pattern Matching in Trees, JACM 29,1, 1982Google Scholar
  11. [Kron75]
    H. Kron, Tree Templates and Subtree Transformational Grammars, PhD Dissertation, University of California, Santa Cruz, 1975Google Scholar
  12. [Lune83]
    H. Lunell, Code Generator Writing Systems, Software System Research Center, Linköping, Sweden, 1983Google Scholar
  13. [Moen85]
    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, 1985Google Scholar
  14. [MWW85]
    U. Möncke, B. Weisgerber, R. Wilhelm, Generative Support for Transformational Programming, ESPRIT Technical Week, 1985Google Scholar
  15. [Weis83]
    B. Weisgerber, Attributierte Transformationsgrammatiken: Die Baumanalyse und Untersuchungen zu Transformationsstrategien, Diplomarbeit, Universität des Saarlandes, Saarbrücken, 1983Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1989

Authors and Affiliations

  • Beatrix Weisgerber
    • 1
  • Reinhard Wilhelm
    • 1
  1. 1.FB 10 - InformatikUniversität des SaarlandesSaarbrückenFederal Republic of Germany

Personalised recommendations