... | ... | @@ -94,7 +94,7 @@ The `integer-gmp` package now uses this method for all the primops that deal wit |
|
|
|
|
|
The first step is to extend this syntax to allow PrimOp attributes to be specified. Then external-only (some PrimOps have external fallbacks and internal special-cases!) primops can be converted to use `foreign import prim`, bypassing the Compiler for interactions strictly between `base` and the `rts`.
|
|
|
|
|
|
In https://gitlab.haskell.org/ghc/ghc/blob/581cbc28e143a4ed8e7f794ed1618161222a5646/compiler/deSugar/DsForeign.hs#L289-302 there is a tech debt note that `foreign import prim` is currently a hacked up foreign call. But maybe this is actually good. If they support both support all the same strictness and other metadata, maybe primops, even internal ones, are "just" another type of foreign function. This seems good for decoupling core from the backend, and insuring there are no regressions between "true" primop and `foreign import prim` functionality.
|
|
|
In https://gitlab.haskell.org/ghc/ghc/blob/581cbc28e143a4ed8e7f794ed1618161222a5646/compiler/GHC/HsToCore/Foreign/Decl.hs#L289-302 there is a tech debt note that `foreign import prim` is currently a hacked up foreign call. But maybe this is actually good. If they support both support all the same strictness and other metadata, maybe primops, even internal ones, are "just" another type of foreign function. This seems good for decoupling core from the backend, and insuring there are no regressions between "true" primop and `foreign import prim` functionality.
|
|
|
|
|
|
Another direction is the calling convention for primops and ordinary compiled Haskell functions may be unified in future and at that time it the restriction on using only unlifted types may be lifted. [This sounds weird to @Ericson2314. Aren't primops definitionally inlined? Both they and foreign calls have wrappers that deal with lifted types. I'd want be sure when writing a primop whether I was getting an implicit wrapper, otherwise it's hard to reason about the cost and ABI.]
|
|
|
|
... | ... | |