Unlifted primop types

Ben Gamari ben at smart-cactus.org
Tue Aug 21 15:07:55 UTC 2018


David Feuer <david at well-typed.com> writes:

> On Monday, August 20, 2018 12:11:14 PM EDT Simon Peyton Jones via ghc-devs wrote:
>> I don’t quite know how primops.txt.pp is processed, but perhaps by utils/genprimopcode.   You may need to update the syntax a bit?
>
> The whole thing is a mystery to me. Whatever it's doing seems to
> generate code that puts things in TysPrim.hs together, and that module
> also looks rather murky to the uninitiated.

primops.txt.pp is processed by genprimopcode, as suggested by Simon.
genprimopcode has several modes, each of which produces a different
output. These are listed in compiler/ghc.mk; grep for
preprocessCompilerFiles. They broadly fall into three categories:

 * A set of headers which define the `PrimOp` type and functions defining
   primops' various properties (e.g. out-of-line-ness)

 * The GHC.PrimopWrappers module of `ghc-prim`, which defines functions
   wrapping each of the primops; these are used by GHCi (see Note
   [Primop Wrappers]

 * The `GHC.Prim`module of `ghc-prim`, which has no code but rather
   merely serves as a documented source file to be used by Haddock.

genprimopcode's notion of non-Type kinded tyvars is very limited. It
provides a few tyvars of kind Type (namely a, b, and c) and an
"open-kinded" tyvar of any runtime rep (namely o). I believe you would
need to add an additional binder to the genopcode parser to get what you
want. I suspect this would only require a few lines, however.

Cheers,

- Ben

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20180821/876d381b/attachment.sig>


More information about the ghc-devs mailing list