diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-11-15 23:22:06 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-17 05:10:27 -0500 |
commit | 083a7583d70c190b090fedcf9f955eff65d4baeb (patch) | |
tree | 8706cc9ee591bf2a05c23efcaa7251a0489e4c24 /libraries/ghc-prim | |
parent | 3e94b5a7ebddf156f00599c6bd2e9ba1af437a6c (diff) | |
download | haskell-083a7583d70c190b090fedcf9f955eff65d4baeb.tar.gz |
Increase type sharing
Fixes #20541 by making mkTyConApp do more sharing of types.
In particular, replace
* BoxedRep Lifted ==> LiftedRep
* BoxedRep Unlifted ==> UnliftedRep
* TupleRep '[] ==> ZeroBitRep
* TYPE ZeroBitRep ==> ZeroBitType
In each case, the thing on the right is a type synonym
for the thing on the left, declared in ghc-prim:GHC.Types.
See Note [Using synonyms to compress types] in GHC.Core.Type.
The synonyms for ZeroBitRep and ZeroBitType are new, but absolutely
in the same spirit as the other ones. (These synonyms are mainly
for internal use, though the programmer can use them too.)
I also renamed GHC.Core.Ty.Rep.isVoidTy to isZeroBitTy, to be
compatible with the "zero-bit" nomenclature above. See discussion
on !6806.
There is a tricky wrinkle: see GHC.Core.Types
Note [Care using synonyms to compress types]
Compiler allocation decreases by up to 0.8%.
Diffstat (limited to 'libraries/ghc-prim')
-rw-r--r-- | libraries/ghc-prim/GHC/Types.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libraries/ghc-prim/GHC/Types.hs b/libraries/ghc-prim/GHC/Types.hs index 45f14e7691..d40e7a8f38 100644 --- a/libraries/ghc-prim/GHC/Types.hs +++ b/libraries/ghc-prim/GHC/Types.hs @@ -41,6 +41,7 @@ module GHC.Types ( -- The historical type * should ideally be written as -- `type *`, without the parentheses. But that's a true -- pain to parse, and for little gain. + ZeroBitRep, ZeroBitType, VecCount(..), VecElem(..), Void#, @@ -95,6 +96,11 @@ type LiftedRep = 'BoxedRep 'Lifted -- | The runtime representation of unlifted types. type UnliftedRep = 'BoxedRep 'Unlifted +-- | The runtime representation of a zero-width tuple, +-- represented by no bits at all +type ZeroBitRep = 'TupleRep '[] + +------------------------- -- | The kind of types with lifted values. For example @Int :: Type@. type Type = TYPE LiftedRep @@ -102,6 +108,10 @@ type Type = TYPE LiftedRep -- unlifted data type, using @-XUnliftedDataTypes@. type UnliftedType = TYPE UnliftedRep +-- | The kind of the empty unboxed tuple type (# #) +type ZeroBitType = TYPE ZeroBitRep + +------------------------- data Multiplicity = Many | One type family MultMul (a :: Multiplicity) (b :: Multiplicity) :: Multiplicity where |