Advertisement

Target code generation from G-machine code

  • Thomas Johnsson
Graph Reduction On Existing Architectures
Part of the Lecture Notes in Computer Science book series (LNCS, volume 279)

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.

Keywords

Move popS Runtime System Register Allocation Graph Reduction Attribute Grammar 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [Aug84]
    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. [Aug85]
    L. Augustsson. Compiling pattern matching. In Proceedings 1985 Conference on Functional Programming Languages and Computer Architecture, Nancy, France, 1985.Google Scholar
  3. [CCM85]
    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. [CH84]
    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. [Fri76]
    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. [Hen80]
    P. Henderson. Functional Programming. Prentice-Hall, 1980.Google Scholar
  7. [HM76]
    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. [Hug82]
    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. [Joh84]
    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. [Joh85]
    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. [Joh86]
    T. Johnsson. Attribute grammars and functional programming. Draft paper, Programming Methodology Group, Chalmers University of Technology, 1986.Google Scholar
  12. [Knu68]
    Donald E. Knuth. Semantics of context-free languages. Math. Systems Theory, 2:127–145, 1968.CrossRefGoogle Scholar
  13. [Lan64]
    P.J.Landin. The mechanical evaluation of expressions. Computer Journal, (6):308–320, 1964.Google Scholar
  14. [LS78]
    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. [Pey87]
    S. Peyton-Jones. The Implementation of Functional Languages. Prentice Hall, 1987.Google Scholar
  16. [Tur79]
    D. A. Turner. A new implementation technique for applicative languages. Software — Practice and Experience, 9:31–49, 1979.Google Scholar
  17. [Tur81]
    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. [WJW*75]
    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

Copyright information

© Springer-Verlag Berlin Heidelberg 1987

Authors and Affiliations

  • Thomas Johnsson
    • 1
  1. 1.Chalmers University of TechnologyGöteborgSweden

Personalised recommendations