GHC Core / STG to supercombinators

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

GHC Core / STG to supercombinators

Csaba Hruska
Hello,

I'd like to use GHC as a haskell frontend in a project.
I wonder what is the easiest way to compile Haskell to supercombinators (top level functions) using GHC as a library.

Is it possible to use the simplifier to transform the parsed Haskell source to supercombinators? i.e. to do
  • eta expansion
  • closure conversion
  • lambda lifting
Regarding the eta expansion and lambda lifting it seems (according the comments in simplifier code) it does not guarantee to make these transformations in every case.
If GHC could transform the Core representation to supercombinators, which transformation should I use from CoreToDo?
https://github.com/ghc/ghc/blob/master/compiler/simplCore/CoreMonad.hs#L107-L135

I'd like to use GHC as a frontend for my custom code generator which can handle (lazy) top level functions only.
Is it better to use GHC as a library or is it better to write a compiler plugin to capture the core representation.
I do not want to optimize the Core at all neither want to use other parts of GHC's backend (i.e. codegen).
Ideally GHC would typecheck and transform everything to top level function and my system would do the rest.

Do you know what would be the easiest way to do this? (i.e. via CoreToDo or custom calls for the simplifying functions)

Or would it be simpler to generate top level (lazy) functions from STG?

Regards,
Csaba Hruska

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: GHC Core / STG to supercombinators

Ben Lippmeier-2


On 10 Apr 2018, at 9:23 am, Csaba Hruska <[hidden email]> wrote:

I'd like to use GHC as a haskell frontend in a project.
I wonder what is the easiest way to compile Haskell to supercombinators (top level functions) using GHC as a library.

Is it possible to use the simplifier to transform the parsed Haskell source to supercombinators? i.e. to do

The Intel Haskell Research Compiler did something similar. 

See: 



Ben.




_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

RE: GHC Core / STG to supercombinators

GHC - devs mailing list
In reply to this post by Csaba Hruska

The FloatOut pass is designed so that it can do lambda lifting for every lambda.  I think if you try

            -ffloat-all-lams

that might do it.   See CoreMonad.FloatOutSwitches, the floatOutLambdas field

 

Simon

 

From: ghc-devs <[hidden email]> On Behalf Of Csaba Hruska
Sent: 10 April 2018 00:23
To: [hidden email]
Subject: GHC Core / STG to supercombinators

 

Hello,

I'd like to use GHC as a haskell frontend in a project.
I wonder what is the easiest way to compile Haskell to supercombinators (top level functions) using GHC as a library.

Is it possible to use the simplifier to transform the parsed Haskell source to supercombinators? i.e. to do

  • eta expansion
  • closure conversion
  • lambda lifting

Regarding the eta expansion and lambda lifting it seems (according the comments in simplifier code) it does not guarantee to make these transformations in every case.

If GHC could transform the Core representation to supercombinators, which transformation should I use from CoreToDo?
https://github.com/ghc/ghc/blob/master/compiler/simplCore/CoreMonad.hs#L107-L135

I'd like to use GHC as a frontend for my custom code generator which can handle (lazy) top level functions only.

Is it better to use GHC as a library or is it better to write a compiler plugin to capture the core representation.

I do not want to optimize the Core at all neither want to use other parts of GHC's backend (i.e. codegen).
Ideally GHC would typecheck and transform everything to top level function and my system would do the rest.

Do you know what would be the easiest way to do this? (i.e. via CoreToDo or custom calls for the simplifying functions)

Or would it be simpler to generate top level (lazy) functions from STG?

 

Regards,

Csaba Hruska


_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs