Skip to main content

Target code generation from G-machine code

  • Graph Reduction On Existing Architectures
  • Conference paper
  • First Online:
Graph Reduction (GR 1986)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 279))

Included in the following conference series:

Abstract

The G-machine is a stack machine for von-Neumann-like execution of lazy functional languages, using graph reduction. This paper describes how target code generation from G-machine code is performed in a compiler for Lazy ML. We briefly review the G-machine, and the compiler phases preceding the target code generation. Two different target code generation methods are described, as well as essential parts of the run-time system. The first target code generator is very simple, generating naïve code by means of ‘macro expansion’. This code explicitly manipulates the stacks exactly as prescribed by the G-machine instructions. A simple peep-hole code improver can remove a fair amount of the most glaring inefficiencies of the naïve code. The second target code generator is less naïve, and takes a more systematic approach to avoid redundant operations in the resulting target code. This code generator can be neatly expressed as an attribute grammar over the G-machine code sequence.

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

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. L. Augustsson. A compiler for lazy ML. In Proceedings of the 1984 ACM Symposium on Lisp and Functional Programming, pages 218–227, Austin, 1984.

    Google Scholar 

  2. L. Augustsson. Compiling pattern matching. In Proceedings 1985 Conference on Functional Programming Languages and Computer Architecture, Nancy, France, 1985.

    Google Scholar 

  3. G. Cousineau, P.L. Curien, and M. Mauny. The categorical abstract machine. In Proceedings 1985 Conference on Functional Programming Languages and Computer Architecture, pages 50–64, Nancy, France, 1985.

    Google Scholar 

  4. F. Chow and J. Hennessy. Register allocation by priority-based coloring. In Proceedings of the SIGPLAN '84 Symposium on Compiler Construction, pages 222–232, Montreal, 1984.

    Google Scholar 

  5. D. P. Friedman. Cons should not evaluate its arguments, pages 257–284. Edinburgh University Press, 1976. In the book Automata, languages and Programming.

    Google Scholar 

  6. P. Henderson. Functional Programming. Prentice-Hall, 1980.

    Google Scholar 

  7. P. Henderson and J. H. Morris. A lazy evaluator. In 3'rd conference on The Principles of Programming Languages, pages 95–103, Atlanta, Georgia, January 1976.

    Google Scholar 

  8. J. Hughes. Super combinators — a new implementation method for applicative languages. In Proceedings of the 1982 ACM Symposium on Lisp and Functional Programming, pages 1–10, Pittsburgh, 1982.

    Google Scholar 

  9. T. Johnsson. Efficient compilation of lazy evaluation. In Proceedings of the SIGPLAN '84 Symposium on Compiler Construction, pages 58–69, Montreal, 1984.

    Google Scholar 

  10. T. Johnsson. Lambda lifting: transforming programs to recursive equations. In Proceedings 1985 Conference on Functional Programming Languages and Computer Architecture, Nancy, France, 1985.

    Google Scholar 

  11. T. Johnsson. Attribute grammars and functional programming. Draft paper, Programming Methodology Group, Chalmers University of Technology, 1986.

    Google Scholar 

  12. Donald E. Knuth. Semantics of context-free languages. Math. Systems Theory, 2:127–145, 1968.

    Article  Google Scholar 

  13. P.J.Landin. The mechanical evaluation of expressions. Computer Journal, (6):308–320, 1964.

    Google Scholar 

  14. H. Lindström and J. Skansholm. Code Generation in the MARY compiler for the IBM 360. Technical Report 78.1, Department of Computer Science, Chalmers University of Technology, Göteborg, Sweden, 1978.

    Google Scholar 

  15. S. Peyton-Jones. The Implementation of Functional Languages. Prentice Hall, 1987.

    Google Scholar 

  16. D. A. Turner. A new implementation technique for applicative languages. Software — Practice and Experience, 9:31–49, 1979.

    Google Scholar 

  17. D. A. Turner. The semantic elegance of applicative languages. In Proceedings 1981 Conference on Functional Languages and Computer Architecture, Wentworth-by-the-Sea, Portsmouth, New Hampshire, 1981.

    Google Scholar 

  18. W. Wulf, R.K. Johnsson, C.B. Weinstock, S.O. Hobbs, and C.M. Geschke. The Design of an Optimizing Compiler. Elsevier Computer Science Library, New York, 1975.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Joseph H. Fasel Robert M. Keller

Rights and permissions

Reprints and permissions

Copyright information

© 1987 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Johnsson, T. (1987). Target code generation from G-machine code. In: Fasel, J.H., Keller, R.M. (eds) Graph Reduction. GR 1986. Lecture Notes in Computer Science, vol 279. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-18420-1_53

Download citation

  • DOI: https://doi.org/10.1007/3-540-18420-1_53

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-18420-1

  • Online ISBN: 978-3-540-47963-5

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics