SimplexHC: Lowering High-Level Haskell to Imperative IR
Simplexhc is a work in progress implementation of an STG to LLVM compiler, which aims to explore which advanced optimizations become possible when directly lowering from a lazy abstract machine with rich semantic information to a modern compiler IR which provides support for the efficient lowering of dynamic languages.
Previous work in GHC has explored the compilation of Haskell to a modern compiler IR such as LLVM, but this work has been integrated after lowering from STG to C–, an untyped variant of C that is semantically a lot closer to the LLVM intermediate representation as STG is. However, as part of the lowering from STG to C– a lot of knowledge about the original high-level functional semantics are lost. The work on the Intel haskell compiler is closer in spirit, but they take a whole-program optimisation approach and have their own strict IR, while we propose to starting the lowering process from STG, a lazy IR/machine model.
We are proposing to compile to LLVM, which provides support for type based analysis, an extensible compiler pass pipeline to encode domain-specific knowledge of STG, and a well tested, well optimised codebase that is the heart of modern compilers such as clang. There has been a very successful use of LLVM as a target for a high level language (Java) by Azul systems, who generate LLVM in their JVM JIT compiler. This suggests that the approach of lowering STG to LLVM could also be profitable from a performance standpoint.
We would like to augment GHC’s current code generation capability with the ability to directly generate LLVM. This should not only improve performance, but also should allow GHC to remove a dependency in the tree on C– as well.
We also explore half baked tangential ideas such as:
-
The possibility to use ideas from polyhedral compilation to analyze and optimise purely functional programs.
-
Extending LLVM to support GRIN, an alternate intermediate representation proposed for haskell whole-program optimisation.
Sat 9 SepDisplayed time zone: Belfast change
10:30 - 11:30 | |||
10:30 25mTalk | Native Support for Explicit Stacks in LLVM HIW | ||
10:55 25mTalk | SimplexHC: Lowering High-Level Haskell to Imperative IR HIW Siddharth Bhat IIT Hyderabad | ||
11:20 10mTalk | Lightning Talk Slot #1 HIW |