Specialization plugin

Christiaan Baaij christiaan.baaij at gmail.com
Sun Oct 30 12:23:00 UTC 2016


One small question: what's the difference between adding INLINABLE
everywhere, and just compiling with -fexpose-all-unfoldings,
https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/using-optimisation.html#ghc-flag--fexpose-all-unfoldings?
Is there any reason you couldn't use that flag as opposed to writing a
plugin that adds INLINEABLE pragmas to all bindings?

On 28 October 2016 at 00:05, Ryan Trinkle <ryan.trinkle at gmail.com> wrote:

> Hi everyone,
>
> I'm trying my hand at writing a GHC plugin to generate specializations for
> all uses of a particular typeclass, and I've run into some trouble.  I'd
> appreciate it if someone could point me in the right direction!  I'm new to
> GHC development, so I may just be overlooking some simple stuff.
>
> The original problem:
> Reflex's interface is presented as a typeclass, which allows the
> underlying FRP engine to be selected by instance resolution.  Although some
> programs make use of this (particularly the semantics test suite), most
> only ever use one implementation.  However, since their code is typically
> written polymorphically, the implementation cannot be inlined and its
> rewrite rules cannot fire.  This means that the typeclass
>
> My attempted solutions:
>  * Initially, I wrote a plugin that adds INLINABLE pragmas to everything.
> This helped; small programs now generally see the inlining/rule-firings I
> was hoping for.  However, in large programs, this does not occur.  I'm
> looking into this, but also trying another approach:
>  * Now, I am attempting to write a plugin that adds a SPECIALIZE pragma to
> every binding whose type mentions Reflex.
>
> The trouble:
> Since SPECIALIZE pragmas seem to be removed during typechecking
> (DsBinds.dsSpec), I can't directly add them.  I would like to, perhaps,
> invoke Specialise.specBind; however, I'm not sure how to obtain the
> necessary instance - as mentioned here
> <https://github.com/ghc/ghc/blob/c36904d66f30d4386a231ce365a056962a881767/compiler/specialise/Specialise.hs#L288>,
> "only the type checker can conjure [dictionaries] up".  Perhaps it's
> possible to explicitly create that dictionary somewhere and extract it for
> use during the plugin pass?
>
>
> Thanks,
> Ryan
>
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20161030/6be1b84f/attachment.html>


More information about the ghc-devs mailing list