Compiling Embedded Languages

  • Conal Elliott
  • Sigbjørn Finne
  • Oege de Moor
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1924)

Abstract

Functional languages are particularly well-suited to the im- plementation of interpreters for domain-specific embedded languages (DSELs). We describe an implemented technique for producing optimiz- ing compilers for DSELs, based on Kamin’s idea of DSELs for program generation. The technique uses a data type of syntax for basic types, a set of smart constructors that perform rewriting over those types, some code motion transformations, and a back-end code generator. Domain- specific optimization results from chains of rewrites on basic types. New DSELs are defined directly in terms of the basic syntactic types, plus host language functions and tuples. This definition style makes compil- ers easy to write and, in fact, almost identical to the simplest embedded interpreters. We illustrate this technique with a language Pan for the computationally intensive domain of image synthesis and manipulation.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Oege de Moor and Ganesh Sittampalam. Generic program transformation. In Proceedings of the third International Summer School on Advanced Functional Programming, Springer Lecture Notes in Computer Science, 1999. http://users.comlab.ox.ac.uk/oege.demoor/papers/braga.ps.gz.Google Scholar
  2. 2.
    Conal Elliott. A Pan image gallery. http://research.microsoft.com/~conal/pan/Gallery.
  3. 3.
    Conal Elliott. An embedded modeling language approach to interactive 3D and multimedia animation. IEEE Transactions on Software Engineering, 25(3):291–308, May/June 1999. Special Section: Domain-Specific Languages (DSL). http://research.microsoft.com/~conal/papers/tse-modeled-animation.CrossRefGoogle Scholar
  4. 4.
    Conal Elliott. Functional images, unpublished, March 2000. http://research.microsoft.com/~conal/papers/fip.
  5. 5.
    Conal Elliott, Sigbjørn Finne, and Oege de Moor. Compiling embedded languages (extended version). Technical report, Microsoft Research, May 2000. http://-research.microsoft.com/scripts/pubs/view.asp?TR ID=MSR-TR-2000-52.
  6. 6.
    Matteo Frigo. A fast Fourier transform compiler. In Proceedings of the ACM SIGPLAN’99 Conference on Programming Language Design and Implementation, pages 169–180, 1999. http://www.acm.org/pubs/articles/proceedings/pldi/301618/p169-frigo/p169-frigo.pdf.
  7. 7.
    John Hatcliff, Torben Mogensen, and Peter Thiemann, editors. Partial Evaluation: Practice and Theory, volume 1706. Springer-Verlag, 1999.Google Scholar
  8. 8.
    Paul Hudak. Modular domain specific languages and tools. In P. Devanbu and J. Poulin,editors, Proceedings: Fifth International Conference on Software Reuse, pages 134–142. IEEE Computer Society Press, 1998.Google Scholar
  9. 9.
    Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice Hall In-ternational, International Series in Computer Science, June 1993. http://www.dina.kvl.dk/~sestoft/pebook/pebook.html.
  10. 10.
    Samuel Kamin. Standard ML as a meta-programming language. Technical report, University of Illinois at Urbana-Champaign, September 1996. http://www-sal.cs.uiuc.edu/~kamin/pubs/ml-meta.ps.Google Scholar
  11. 11.
    Samuel Kamin and David Hyatt. A special-purpose language for picture-drawing. In USENIX, editor, Proceedings of the Conference on Domain-Specific Lan-guages, October 15–17, 1997, Santa Barbara, California, pages 297–310, 1997. http://www-sal.cs.uiuc.edu/~kamin/fpic/doc/fpic-paper.ps.
  12. 12.
    Peter J. Landin. The next 700 programming languages. Communications of the ACM, 9(3):157–164, March 1966. Originally presented at the Proceedings of the ACM Programming Language and Pragmatics Conference, August 8–12, 1965.MATHCrossRefGoogle Scholar
  13. 13.
    Daan Leijen and Erik Meijer. Domain specific embedded compilers. In 2nd Conference on Domain-Specific Languages (DSL), Austin TX, USA, October 1999. USENIX. http://www.cs.uu.nl/people/daan/papers/dsec.ps.
  14. 14.
    Walid Taha and Tim Sheard. MetaML and multi-stage programming with explicit annotations. Journal of Theoretical Computer Science, 2000. To appear. http://www.cs.chalmers.se/~taha/publications/journal/tcs00.ps.
  15. 15.
    GHC Team. The Glasgow Haskell compiler. http://haskell.org/ghc.
  16. 16.
    Todd Veldhuizen. Expression templates. C++ Report, 7(5):26–31, June 1995. http://extreme.indiana.edu/~tveldhui/papers/pepm99.ps. Reprinted in C++ Gems, ed. Stanley Lippman.
  17. 17.
    Todd Veldhuizen. C++ templates as partial evaluation. In Workshop on Partial Evaluation and Semantics-Based Program Manipulation (PEPM’99). ACM Sigplan, 1999. http://extreme.indiana.edu/~tveldhui/papers/pepm99.ps.

Copyright information

© Springer-Verlag Berlin Heidelberg 2000

Authors and Affiliations

  • Conal Elliott
    • 1
  • Sigbjørn Finne
    • 1
  • Oege de Moor
    • 2
  1. 1.Microsoft ResearchRedmondUSA
  2. 2.Oxford University Computing Laboratory Wolfson BuildingOxfordEngland

Personalised recommendations