Compilers written in Haskell that generate assembly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Compilers written in Haskell that generate assembly

Vanessa McHale-2
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

_______________________________________________
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.
Reply | Threaded
Open this post in threaded view
|

Re: Compilers written in Haskell that generate assembly

Henning Thielemann

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.
Reply | Threaded
Open this post in threaded view
|

Re: Compilers written in Haskell that generate assembly

Vanessa McHale-2
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.
Reply | Threaded
Open this post in threaded view
|

Re: Compilers written in Haskell that generate assembly

Sebastiaan Joosten-3
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:

(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. 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 <[hidden email]> 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.
Reply | Threaded
Open this post in threaded view
|

Re: Compilers written in Haskell that generate assembly

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 <[hidden email]> 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:

(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. 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 <[hidden email]> 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.
Reply | Threaded
Open this post in threaded view
|

Re: Compilers written in Haskell that generate assembly

Siddharth Bhat
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 <[hidden email]> 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 <[hidden email]> 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:

(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. 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 <[hidden email]> 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.


--

_______________________________________________
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.
Reply | Threaded
Open this post in threaded view
|

Re: Compilers written in Haskell that generate assembly

M Farkas-Dyck
In reply to this post by Vanessa McHale-2
On 12/14/20, Vanessa McHale <[hidden email]> wrote:
> 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.)
_______________________________________________
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.