[Haskell-cafe] Compilers written in Haskell that generate assembly

Siddharth Bhat siddu.druid at gmail.com
Tue Dec 15 16:56:32 UTC 2020


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 <carter.schonwald at gmail.com>
wrote:

> 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 at 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/CodeGen.hs
>>
>> (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.html>. 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 <vamchale at gmail.com>
>> 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.



-- 
https://bollu.github.io/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20201215/ae661bf9/attachment.html>


More information about the Haskell-Cafe mailing list