Compilers written in Haskell that generate assembly

Hi all, Have any of you written compilers or backends that generate assembly? Lots of projects seem to "end" at LLVM. I have a project (https://hackage.haskell.org/package/kempe) where I used something like maximal munch and a linear register allocator, but I was wondering if there was anything more sophisticated out there! So far I've found http://hackage.haskell.org/package/linearscan-hoopl also Cheers, Vanessa McHale

On Mon, 14 Dec 2020, Vanessa McHale wrote:
Have any of you written compilers or backends that generate assembly? Lots of projects seem to "end" at LLVM.
I don't know of compiler backends, but I know of an x86 machine code generator: https://hackage.haskell.org/package/harpy

That I stumbled across! I like it, though I've put off learning about assemblers... On 12/14/20 2:05 PM, Henning Thielemann wrote:
On Mon, 14 Dec 2020, Vanessa McHale wrote:
Have any of you written compilers or backends that generate assembly? Lots of projects seem to "end" at LLVM.
I don't know of compiler backends, but I know of an x86 machine code generator: https://hackage.haskell.org/package/harpy

Not something I've worked on (my answer to your original question is 'no I
haven't'), but GHC has a compiler from 'CMM' to various assemblies written
in Haskell
Code at:
https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/CmmToAsm/
https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/CmmToAsm/X86/C...
(I used to think that LLVM was the last step in GHC. I don't know when or
how I ever got that idea. Last year I learned that it only uses LLVM if you
tell it to and it bypasses it completely with the default `-fasm' option
https://downloads.haskell.org/~ghc/8.10.2/docs/html/users_guide/codegens.htm....
In
any case, my own earlier misconception is why I felt the need to point out
what is perhaps obvious to most.)
Sebastiaan
On Mon, Dec 14, 2020 at 3:09 PM Vanessa McHale
That I stumbled across! I like it, though I've put off learning about assemblers...
On 12/14/20 2:05 PM, Henning Thielemann wrote:
On Mon, 14 Dec 2020, Vanessa McHale wrote:
Have any of you written compilers or backends that generate assembly? Lots of projects seem to "end" at LLVM.
I don't know of compiler backends, but I know of an x86 machine code generator: https://hackage.haskell.org/package/harpy
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

I do genuinely think it’s actually a great piece of code to shamelessly copy out and use for your own needs. It doesn’t even really dictate any RTS assumptions or anything. By and large ;) On Mon, Dec 14, 2020 at 3:55 PM Sebastiaan Joosten < sjcjoosten+haskell@gmail.com> wrote:
Not something I've worked on (my answer to your original question is 'no I haven't'), but GHC has a compiler from 'CMM' to various assemblies written in Haskell Code at: https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/CmmToAsm/
https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/CmmToAsm/X86/C...
(I used to think that LLVM was the last step in GHC. I don't know when or how I ever got that idea. Last year I learned that it only uses LLVM if you tell it to and it bypasses it completely with the default `-fasm' option https://downloads.haskell.org/~ghc/8.10.2/docs/html/users_guide/codegens.htm.... In any case, my own earlier misconception is why I felt the need to point out what is perhaps obvious to most.)
Sebastiaan
On Mon, Dec 14, 2020 at 3:09 PM Vanessa McHale
wrote: That I stumbled across! I like it, though I've put off learning about assemblers...
On 12/14/20 2:05 PM, Henning Thielemann wrote:
On Mon, 14 Dec 2020, Vanessa McHale wrote:
Have any of you written compilers or backends that generate assembly? Lots of projects seem to "end" at LLVM.
I don't know of compiler backends, but I know of an x86 machine code generator: https://hackage.haskell.org/package/harpy
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

This might be of interest: It's a tiny optimizing compiler which generates
MIPS asm. It runs end-to-end, I think: simple programs can be tested using
`nasm`:
https://github.com/bollu/tiny-optimising-compiler
Best,
~Siddharth
On Tue, Dec 15, 2020 at 3:20 AM Carter Schonwald
I do genuinely think it’s actually a great piece of code to shamelessly copy out and use for your own needs. It doesn’t even really dictate any RTS assumptions or anything. By and large ;)
On Mon, Dec 14, 2020 at 3:55 PM Sebastiaan Joosten < sjcjoosten+haskell@gmail.com> wrote:
Not something I've worked on (my answer to your original question is 'no I haven't'), but GHC has a compiler from 'CMM' to various assemblies written in Haskell Code at: https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/CmmToAsm/
https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/CmmToAsm/X86/C...
(I used to think that LLVM was the last step in GHC. I don't know when or how I ever got that idea. Last year I learned that it only uses LLVM if you tell it to and it bypasses it completely with the default `-fasm' option https://downloads.haskell.org/~ghc/8.10.2/docs/html/users_guide/codegens.htm.... In any case, my own earlier misconception is why I felt the need to point out what is perhaps obvious to most.)
Sebastiaan
On Mon, Dec 14, 2020 at 3:09 PM Vanessa McHale
wrote: That I stumbled across! I like it, though I've put off learning about assemblers...
On 12/14/20 2:05 PM, Henning Thielemann wrote:
On Mon, 14 Dec 2020, Vanessa McHale wrote:
Have any of you written compilers or backends that generate assembly? Lots of projects seem to "end" at LLVM.
I don't know of compiler backends, but I know of an x86 machine code generator: https://hackage.haskell.org/package/harpy
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On 12/14/20, Vanessa McHale
Have any of you written compilers or backends that generate assembly? Lots of projects seem to "end" at LLVM.
It's very rough work yet, but a low-level backend IR has been a ongoing project of mine for a while now: https://github.com/strake/esil.hs I am designing a programming language, but LLVM was unfit for my purposes as i need both dynamically-sized stack-allocated values and arbitrary control flow.
I have a project (https://hackage.haskell.org/package/kempe) where I used something like maximal munch and a linear register allocator, but I was wondering if there was anything more sophisticated out there!
I also have a graph-coloring register allocator: https://hub.darcs.net/strake/reg-alloc-graph-color.hs Unfortunately the docs just now are poor, at best. If this seems potentially useful to you, let me know, so i can prioritize that! (Esil uses the register allocator, but thru another interface which is a compiler framework of mine.)
participants (6)
-
Carter Schonwald
-
Henning Thielemann
-
Matthew Farkas-Dyck
-
Sebastiaan Joosten
-
Siddharth Bhat
-
Vanessa McHale