Commit 0f0b002c authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Comments only

...about unarisation and unboxed tuples
parent 6905ce26
...@@ -50,6 +50,22 @@ Of course all this applies recursively, so that we flatten out nested tuples. ...@@ -50,6 +50,22 @@ Of course all this applies recursively, so that we flatten out nested tuples.
Note [Unarisation and nullary tuples] Note [Unarisation and nullary tuples]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The above scheme has a special cases for nullary unboxed tuples, x :: (# #) The above scheme has a special cases for nullary unboxed tuples, x :: (# #)
To see why, consider
f2 :: (# Int, Int #) -> Int
f1 :: (# Int #) -> Int
f0 :: (# #) -> Int
When we "unarise" to eliminate unboxed tuples (this is done at the STG level),
we'll transform to
f2 :: Int -> Int -> Int
f1 :: Int -> Int
f0 :: ??
We do not want to give f0 zero arguments, otherwise a lambda will
turn into a thunk! So we want to get
f0 :: Void# -> Int
So here is what we do for nullary tuples
* Extend the UnariseEnv with x :-> [voidPrimId] * Extend the UnariseEnv with x :-> [voidPrimId]
......
...@@ -451,7 +451,7 @@ mkStgAltType bndr alts = case repType (idType bndr) of ...@@ -451,7 +451,7 @@ mkStgAltType bndr alts = case repType (idType bndr) of
PolyAlt PolyAlt
Nothing -> PolyAlt Nothing -> PolyAlt
UbxTupleRep rep_tys -> UbxTupAlt (length rep_tys) UbxTupleRep rep_tys -> UbxTupAlt (length rep_tys)
-- NB Nullary unboxed tuples have UnaryRep, and generate a PrimAlt -- UbxTupAlt includes nullary and and singleton unboxed tuples
where where
_is_poly_alt_tycon tc _is_poly_alt_tycon tc
= isFunTyCon tc = isFunTyCon tc
......
...@@ -1714,33 +1714,11 @@ typeSize (CoercionTy co) = coercionSize co ...@@ -1714,33 +1714,11 @@ typeSize (CoercionTy co) = coercionSize co
* * * *
********************************************************************** -} ********************************************************************** -}
{- Note [Nullary unboxed tuple]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At runtime we represent the nullary unboxed tuple as the type Void#.
To see why, consider
f2 :: (# Int, Int #) -> Int
f1 :: (# Int #) -> Int
f0 :: (# #) -> Int
When we "unarise" to eliminate unboxed tuples (this is done at the STG level),
we'll transform to
f2 :: Int -> Int -> Int
f1 :: Int -> Int
f0 :: ??
We do not want to give f0 zero arguments, otherwise a lambda will
turn into a thunk! So we want to get
f0 :: Void# -> Int
See Note [Unarisation and nullary tuples] in UnariseStg for more detail.
-}
type UnaryType = Type type UnaryType = Type
data RepType data RepType
= UbxTupleRep [UnaryType] -- Represented by multiple values = UbxTupleRep [UnaryType] -- Represented by multiple values
-- INVARIANT: never an empty list -- Can be zero, one, or more
-- (see Note [Nullary unboxed tuple])
| UnaryRep UnaryType -- Represented by a single value | UnaryRep UnaryType -- Represented by a single value
instance Outputable RepType where instance Outputable RepType where
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment