Abstract
The code generator in a compiler attempts to match a subject tree against a collection of tree-shaped patterns for generating instructions. Tree-pattern matching may be considered as a generalization of string parsing. We propose a new generalized LR (GLR) parser, which extends the LR parser stack with a parser cactus. GLR explores all plausible parsing steps to find the least-cost matching. GLR is fast due to two properties: (1) duplicate parsing steps are eliminated and (2) partial parse trees that will not lead to a least-cost matching are discarded as early as possible.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Aho, A.V., Ganapathi, M., Tjian, S.W.K.: Code Generation Using Tree Matching and Dynamic Programming. ACM Transactions on Programming Languages and Systems 11(4), 491–516 (1989)
Aho, A.V., Lam, M.S., Sethi, R., Ullman, J.D.: Compilers, Principles, Techniques, and Tools, 2nd edn. Addison-Wesley, New York (2007)
Christopher, T.W., Hatcher, P.J., Kukuk, R.C.: Using Dynamic Programming to Generate Optimized Code in a Graham-Glanville-Style Code Generator. In: Proceedings of the 1984 SIGPLAN symposium on Compiler construction, ACM SIGPLAN Notices, vol. 84, pp. 25–36. ACM, New York (1984)
Earley, J.: An efficient context-free parsing algorithm. ACM Comm. 13(2), 94–102 (1970)
Fischer, C.N., LeBlanc Jr., R.J.: Crafting a Compiler with C. Benjamin/Cummings, Reading (1991)
Fraser, C.W., Hanson, D.R., Proebsting, T.A.: Engineering a Simple, Efficient Code Generator Generator. ACM Letters on Programming Languages and Systems 1(3), 213–226 (1992)
Glanville, R.S.: A machine independent algorithm for code generation and its use in retargetable compilers. Ph.D. dissertation, University of California, Berkeley (December 1977)
Steven Glanville, R., Graham, S.L.: A new method for compiler code generation. In: Proceedings of 5th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, Tucson, Arizona, pp. 231–254 (1978)
Nigel Horspool, R.: An Alternative to the Graham-Glanville Code-Generation Method. IEEE Computers 20, 33–39 (1987)
Madhavan, M., Shankar, P.: Optimal regular tree pattern matching using pushdown automata. In: Arvind, V., Sarukkai, S. (eds.) FST TCS 1998. LNCS, vol. 1530, pp. 122–133. Springer, Heidelberg (1998)
Madhavan, M., Shankar, P., Rai, S., Ramakrishna, U.: Extending Graham-Glanville Techniques for Optimal Code Generation. ACM Transactions on Programming Languages and Systems 22(6), 973–1001 (2000)
Sun Microsystems, Connected, Limited Device Configuration, Specification Version 1.0a, Java 2 Platform Micro Edition 1.0a, CA, USA (May 19, 2000)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2010 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Yang, W. (2010). A Fast General Parser for Automatic Code Generation. In: Hsu, CH., Malyshkin, V. (eds) Methods and Tools of Parallel Programming Multicomputers. MTPP 2010. Lecture Notes in Computer Science, vol 6083. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-14822-4_4
Download citation
DOI: https://doi.org/10.1007/978-3-642-14822-4_4
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-14821-7
Online ISBN: 978-3-642-14822-4
eBook Packages: Computer ScienceComputer Science (R0)