Removing Hoopl dependency?
michal.terepeta at gmail.com
Fri Jun 9 12:26:33 UTC 2017
> On Fri, Jun 9, 2017 at 9:50 AM Simon Peyton Jones <simonpj at microsoft.com>
> > Maybe this is the core of our disagreement - why is it a good idea to
have Hoopl as a separate package in the first place?
> One reason only: because it makes Hoopl usable by compilers other than
GHC. And, dually, efforts by others to improve Hoopl will benefit GHC.
> > If I proposed extracting parts of Core optimizer to a separate package,
wouldn't you expect some really good reasons for doing this?
> A re-usable library should be
> a) a significant chunk of code,
> b) that can plausibly be re-purposed by others
> c) and that has an explicable API
> I think the Core optimiser is so big, and so GHC specific, that (b) and
(c) are unlikely to hold. But we carefully designed Hoopl from the ground
up so that it was agnostic about the node types, and so can be re-used for
control flow graphs of many kinds. It’s designed to be re-usable. Whether
it is actually re-used is another matter, of course. But if it’s part of
GHC, it can’t be.
I agree with your characterization of a re-usable library and that
Core optimizer would not be a good fit. But I do think that Hoopl also
has some problems with b) and c) (although smaller):
- Using an optimizer-as-a-library is not really common (I'm not aware
of any compilers doing this, LLVM is to some degree close but it
exposes the whole language as the interface so it's closer to the
idea of extracting the whole Cmm backend). So I don't think the API
for such a project is well understood.
- The API is pretty wide and does put serious constraints on the IR
(after all it defines blocks and graphs), making reusability
potentially more tricky.
So I think I understand your argument and we just disagree on whether
this is worth the effort of having a separate package.
> > I've pointed multiple reasons why I think it has a significant cost.
> Can you just summarise them again briefly for me? If we are free to
choose nomenclature and API for hoopl2, I’m not yet seeing why making it a
separate package is harder than not doing so. E.g. template-haskell is a
Having even Hoopl2 as a separate package would still entail
- Hoopl2 would still need to duplicate some concepts (eg, `Unique`,
etc. since it needs to be standalone)
- Understanding code (esp. by newcommers) would be harder: the Cmm
backend would be split between GHC and Hoopl2, with the latter
necessarily being far more general/polymorphic than needed by GHC.
- Getting the right performance in the presence of all this additional
generality/polymorphism will likely require fair amount of
- If Hoopl2 is used by other compilers, then we need to be more
careful changing anything in incompatible ways, this will require
more discussions & release coordination.
Considering that Hoopl was never actually picked up by other
compilers, I'm not convinced that this cost is justified. But I
understand that other people might have a different opinion.
So how about a compromise:
- decouple GHC from the current Hoopl (ie, go ahead with my diff),
- keep everything Hoopl related only in `compiler/cmm/Hoopl` with the
long-term intention of creating a separate package,
- experiment with and improve the code,
- once (if?) we're happy with the results, discuss what/how to
extract to a separate package.
That gives us the freedom to try things out and see what works well
(I simply don't have ready solutions for anything, being able to
experiment is IMHO quite important). And once we reach the right
performance/representation/abstraction/API we can work on extracting
What do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs