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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 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.
There are actually some special case exemptions, but we do not treat these here.
- 3.
In the language of attribute grammars, an inherited attribute is one that is passed down the tree from an ancestor node.
- 4.
In the language of attribute grammars, a synthesized attribute is one that is passed up the tree from a descendant node.
References
Aho, A.V., Johnson, S.C.: Optimal code generation for expression trees. J. ACM 23(3) (1976)
Aho, A.V., Johnson, S.C., Ullman, J.D.: Code generation for expressions with common subexpressions. J. ACM 24(1) (1977)
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)
ARM: ARM Architecture Reference Manual. ARM Limited. http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0406b/index.html
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)
Fraser, C.W., Hanson, D.R.: A Retargetable C Compiler: Design and Implementation. Benjamin/Cummings, Redwood City (1995)
Fraser, C.W., Hanson, D.R., Proebsting, T.A.: Engineering a simple, efficient code generator generator. Lett. Program. Lang. Syst. 3, 213–226 (1992)
Fraser, C.W., Henry, R.R., Proebsting, T.A.: BURG—Fast optimal instruction selection and tree parsing. SIGPLAN Not. 27(4) (1992)
Gough, K.J.: Bottom-up tree rewriting tool MBURG. SIGPLAN Not. 31(1) (1996)
Gough, J.: Compiling for the NET Common Language Runtime. Prentice-Hall PTR, Upper Saddle River (2002)
Gough, K.J., Ledermann, J.: Optimal code-selection using MBURG. In: ACSC 20, Australasian Computer Science Conference, Sydney (1997)
Koes, D.R., Goldstein, S.C.: Near-optimal instruction selection on DAGs. In: CGO’08, Boston, Massachusetts, April 2008
Proebsting, T.: Least-cost instructions selection in dags is NP-complete. http://research.microsoft.com/~toddpro/papers/proof.htm
Wulf, W.A., et al.: The Design of an Optimizing Compiler. American Elsevier, New York (1975)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights 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)