Dear Idris lovers,
I’m experimenting with a new backend for Idris. It compiles to the Clean programming language (
http://clean.cs.ru.nl/Clean). Preliminary benchmarks show it’s about 3 times faster than Idris’ default C backend! You can find the code on
https://github.com/timjs/idris-clean. Don’t hesitate to test it out and open some issues.
Clean is a general purpose, pure and lazy functional programming language, similar to Haskell. It’s developed at the Radboud University Nijmegen [1,2]. Clean compiles to abstract ABC bytecode instructions. The ABC stack machine is specially developed to support lazy functional languages and has good support for fast primitive types (Int, Char, Real, Bool, String, boxed and unboxed arrays) and strictness optimisations [3]. The code generator shipped in the Clean distribution is able to generate code for Intel (32 and 64 bit) and ARM (currently only 32 bit) on three different operating systems (Linux, macOS and Windows) [4,5]. Both the code generator and the runtime are written in C and some assembly.
For now, the main purpose of this backend is to see if the Clean programming language, but especially the ABC machine are a good fit for Idris. To be able to generate even faster code, we need to unbox primitive values. Therefore we need some type information in the IR of (for example) the form:
data Ty = TyInt | TyDouble | TyChar | … | TyFunc Ty Ty | TyAny
There are two possibilities I can think of to approach this:
1. Take IR_defunc or IR_simpl and infer primitive types from the usage of primitive operations.
2. Hook into the TT-to-IR-generation and use Idris’ own knowledge to annotate function and constructor declarations in the IR.
Can anybody tell me if the second one is possible and, if so, where this kind of type information is stored in the TT tree?
Cheers,
Tim
[1]: Brus, T. H., van Eekelen, M. C., Van Leer, M. O., & Plasmeijer, M. J. (1987, September). Clean—a language for functional graph rewriting. In Conference on Functional Programming Languages and Computer Architecture (pp. 364-384). Springer Berlin Heidelberg.
[3]: Plasmeijer, R. & Van Eekelen, M. (1993). Functional programming and parallel graph rewriting (Vol. 857). Reading: Addison-wesley.
[4]: Smetsers, S., Nöcker, E., Van Groningen, J., & Plasmeijer, R. (1991, August). Generating efficient code for lazy functional languages. In Conference on Functional Programming Languages and Computer Architecture (pp. 592-617). Springer Berlin Heidelberg.
[5]: van Groningen, J. (1990). Implementing the ABC-machine on MC680X0 based architectures. Master's thesis, University of Nijmegen.