Skip to main content

Reconceptualizing Bottom-Up Tree Rewriting

  • Chapter
Patterns, Programming and Everything
  • 1152 Accesses

Abstract

Bottom-up tree rewriting is a widely used method for code selection in programming language compilers. The use of dynamic programming allows such rewriters to emit code sequences that are optimal with respect to some prescribed cost metric, at least for tree-structured computations. The semantics of rewriting are specified by the production rules of a tree grammar. In this paper, it is shown that a suitable reinterpretation of the meaning of the non-terminal symbols of such grammars provides a significant increase in the expressivity of the rewriting system. In particular, the generation of instructions for flow of control may be subsumed into the rewriter. Likewise, transformation rules normally associated with peephole optimization are also conveniently expressible.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 109.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Of course, in some cases this constraint may lead to a very small choice. For example, probably nothing but a “literal” node can be put into one of the immediate forms.

  2. 2.

    There are actually some special case exemptions, but we do not treat these here.

  3. 3.

    In the language of attribute grammars, an inherited attribute is one that is passed down the tree from an ancestor node.

  4. 4.

    In the language of attribute grammars, a synthesized attribute is one that is passed up the tree from a descendant node.

References

  1. Aho, A.V., Johnson, S.C.: Optimal code generation for expression trees. J. ACM 23(3) (1976)

    Google Scholar 

  2. Aho, A.V., Johnson, S.C., Ullman, J.D.: Code generation for expressions with common subexpressions. J. ACM 24(1) (1977)

    Google Scholar 

  3. Aho, A.V., Ganapathi, M., Tjiang, S.W.K.: Code generation using tree matching and dynamic programming. ACM Trans. Program. Lang. Syst. 11(4) (1989)

    Google Scholar 

  4. ARM: ARM Architecture Reference Manual. ARM Limited. http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0406b/index.html

  5. Craik, A.J., Kelly, W.A.: Using ownership to reason about inherent parallelism in object-oriented programs. In: Gupta, R. (ed.) CC 2010, 19th International Conference on Compiler Construction, Paphos, Cyprus. LNCS, vol. 6011 (2010)

    Google Scholar 

  6. Fraser, C.W., Hanson, D.R.: A Retargetable C Compiler: Design and Implementation. Benjamin/Cummings, Redwood City (1995)

    MATH  Google Scholar 

  7. Fraser, C.W., Hanson, D.R., Proebsting, T.A.: Engineering a simple, efficient code generator generator. Lett. Program. Lang. Syst. 3, 213–226 (1992)

    Article  Google Scholar 

  8. Fraser, C.W., Henry, R.R., Proebsting, T.A.: BURG—Fast optimal instruction selection and tree parsing. SIGPLAN Not. 27(4) (1992)

    Google Scholar 

  9. Gough, K.J.: Bottom-up tree rewriting tool MBURG. SIGPLAN Not. 31(1) (1996)

    Google Scholar 

  10. Gough, J.: Compiling for the NET Common Language Runtime. Prentice-Hall PTR, Upper Saddle River (2002)

    Google Scholar 

  11. Gough, K.J., Ledermann, J.: Optimal code-selection using MBURG. In: ACSC 20, Australasian Computer Science Conference, Sydney (1997)

    Google Scholar 

  12. Koes, D.R., Goldstein, S.C.: Near-optimal instruction selection on DAGs. In: CGO’08, Boston, Massachusetts, April 2008

    Google Scholar 

  13. Proebsting, T.: Least-cost instructions selection in dags is NP-complete. http://research.microsoft.com/~toddpro/papers/proof.htm

  14. Wulf, W.A., et al.: The Design of an Optimizing Compiler. American Elsevier, New York (1975)

    MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to K. John Gough .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag London

About this chapter

Cite this chapter

Gough, K.J. (2012). Reconceptualizing Bottom-Up Tree Rewriting. In: Breitman, K., Horspool, R. (eds) Patterns, Programming and Everything. Springer, London. https://doi.org/10.1007/978-1-4471-2350-7_4

Download citation

  • DOI: https://doi.org/10.1007/978-1-4471-2350-7_4

  • Publisher Name: Springer, London

  • Print ISBN: 978-1-4471-2349-1

  • Online ISBN: 978-1-4471-2350-7

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics