ABSTRACT
In the presence of ever-changing computer architectures, high-quality optimising compiler backends are moving targets that require specialist knowledge and sophisticated algorithms. In this paper, we explore a new backend for the Glasgow Haskell Compiler (GHC) that leverages the Low Level Virtual Machine (LLVM), a new breed of compiler written explicitly for use by other compiler writers, not high-level programmers, that promises to enable outsourcing of low-level and architecture-dependent aspects of code generation. We discuss the conceptual challenges and our backend design. We also provide an extensive quantitative evaluation of the performance of the backend and of the code it produces.
Supplemental Material
- }}clang: A C language family frontend for LLVM. http://clang.llvm.org/, 2010.Google Scholar
- }}LDC: LLVM D Compiler. http://www.dsource.org/projects/ldc, 2010.Google Scholar
- }}llvm-lua, jit/static compiler for lua using llvm on the backend. http: //code.google.com/p/llvm- lua/, 2010.Google Scholar
- }}Openjdk - zero-assembler project.http://openjdk.java.net/projects/zero/, 2010.Google Scholar
- }}Unladen Swallow: A faster implementation of Python.http://code.google.com/p/unladen-swallow/, 2010.Google Scholar
- }}A. W. Appel.SSA is functional programming.ACM SIGPLAN Notices, 33(4):17--20, 1998. Google ScholarDigital Library
- }}P. Codognet and D. Diaz. wamcc: compiling Prolog to C. In Proceedings of the Twelfth International Conference on Logic Programming, pages 317--331, 1995.Google Scholar
- }}D. Coutts, R. Leshchinskiy, and D. Stewart. Stream fusion: From lists to streams to nothing at all. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP 2007, Apr. 2007. Google ScholarDigital Library
- }}R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems, 13(4):451--490, October 1991. Google ScholarDigital Library
- }}D. Dhurjati, S. Kowshik, and V. Adve. Safecode: enforcing alias analysis for weakly typed languages. In PLDI '06: Proceedings of the 2006 ACM SIGPLAN conference on Programming language design and implementation, pages 144--157, New York, NY, USA, 2006. ACM. ISBN 1-59593-320-4. Google ScholarDigital Library
- }}A. Dijkstra, J. Fokker, and S. D. Swierstra. The structure of the Essential Haskell Compiler or coping with compiler complexity. IFL '07: Proceedings of the 19th International Symposium on Implementation and Application of Functional Languages, pages 107--122, 2007.Google Scholar
- }}C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The essence of compiling with continuations. In Proceedings ACM SIGPLAN 1993 Conf. on Programming Language Design and Implementation, PLDI'93, volume 28(6), pages 237--247. ACM Press, 1993. Google ScholarDigital Library
- }}A. Gräf. The Pure programming language. http://code.google.com/p/pure-lang/, 2009.Google Scholar
- }}F. Henderson, Z. Somogyi, and T. Conway. Compiling logic programs to C using GNU C as a portable assembler. In Proceedings of the ILPS'95 Postconference Workshop on Sequential Implementation Technologies for Logic Programming Languages, 1995.Google Scholar
- }}R. Hickey. The Clojure programming language. In DLS '08: Proceedings of the 2008 symposium on Dynamic languages, pages 1--1, New York, NY, USA, 2008. ACM. ISBN 978-1-60558-270-2. doi: http://doi.acm.org/10.1145/1408681.1408682. Google ScholarDigital Library
- }}E. International. Standard ECMA-355 - Common Language Infrastructure (CLI). Technical Report 4th Edition. ECMA International, June 2006.Google Scholar
- }}G. Keller, M. M. T. Chakravarty, R. Leshchinskiy, S. Peyton Jones, and B. Lippmeier. Regular, shape-polymorphic, parallel arrays in Haskell. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP 2010, Sept. 2010. Google ScholarDigital Library
- }}C. Lattner. LLVM: An Infrastructure for Multi-Stage Optimization. Master's thesis, Computer Science Dept., University of Illinois at Urbana-Champaign, December 2002.Google Scholar
- }}C. Lattner and V. Adve. Llvm: A compilation framework for lifelong program analysis & transformation. In CGO '04: Proceedings of the International Symposium on Code Generation and Optimization, page 75. IEEE Computer Society, 2004. ISBN 0-7695-2102-9. Google ScholarDigital Library
- }}T. Lindholm and F. Yellin. Java Virtual Machine Specification. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, April 1999. ISBN 0201432943. Google ScholarDigital Library
- }}B. O'Sullivan. criterion: Robust, reliable performance measurement and analysis. http://hackage.haskell.org/package/criterion, 2010.Google Scholar
- }}W. Partain. The nofib benchmark suite of haskell programs. pages 195--202, London, UK, 1993. Springer-Verlag.Google Scholar
- }}S. L. Peyton Jones. Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine. Journal of Functional Programming, 2(2), 1992.Google Scholar
- }}S. L. Peyton Jones, N. Ramsey, and F. Reig. C--: A portable assembly language that supports garbage collection. In PPDP '99: Proceedings of the International Conference PPDP'99 on Principles and Practice of Declarative Programming, pages 1--28. Springer-Verlag, 1999. ISBN 3-540-66540-4. Google ScholarDigital Library
- }}N. Ramsey, J. Dias, and S. Peyton Jones. Hoopl: Dataflow optimization made simple. In ACM SIGPLAN Haskell Symposium 2010. ACM Press, 2010.Google Scholar
- }}M. Sulzmann, M. Chakravarty, S. Peyton Jones, and K. Donnelly. System F with type equality coercions. In ACM SIGPLAN International Workshop on Types in Language Design and Implementation (TLDI'07). ACM, 2007. Google ScholarDigital Library
- }}D. Tarditi, P. Lee, and A. Acharya. No assembly required: compiling Standard ML to C. ACM Lett. Program. Lang. Syst., 1(2):161--177, 1992. ISSN 1057-4514. Google ScholarDigital Library
- }}The LLVM Team. The LLVM compiler infastructure: LLVM users. http://llvm.org/Users.html.Google Scholar
- }}J. van Schie. Compiling Haskell to LLVM. Master's thesis, Department of Information and Computing Sciences, Utrecht University, 2008.Google Scholar
Index Terms
- An llVM backend for GHC
Recommendations
Bringing low-level languages to the JVM: efficient execution of LLVM IR on Truffle
VMIL 2016: Proceedings of the 8th International Workshop on Virtual Machines and Intermediate LanguagesAlthough the Java platform has been used as a multi-language platform, most of the low-level languages (such as C, Fortran, and C++) cannot be executed efficiently on the JVM. We propose Sulong, a system that can execute LLVM-based languages on the ...
An llVM backend for GHC
HASKELL '10In the presence of ever-changing computer architectures, high-quality optimising compiler backends are moving targets that require specialist knowledge and sophisticated algorithms. In this paper, we explore a new backend for the Glasgow Haskell ...
Rewriting a shallow DSL using a GHC compiler extension
GPCE 2017: Proceedings of the 16th ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesEmbedded Domain Specific Languages are a powerful tool for developing customized languages to fit specific problem domains. Shallow EDSLs allow a programmer to program using many of the features of a host language and its syntax, but sacrifice ...
Comments