Commit 10763ce0 authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan

Some more documentation for typePrimRep1 stuff

[skip ci]
parent cff44d86
Pipeline #9681 skipped
......@@ -166,20 +166,27 @@ assertNonVoidStgArgs args = ASSERT(not (any (isVoidTy . stgArgType) args))
-- Why are these here?
-- | Assumes that there is precisely one 'PrimRep' of the type. This assumption
-- holds after unarise.
-- See Note [Post-unarisation invariants]
idPrimRep :: Id -> PrimRep
idPrimRep id = typePrimRep1 (idType id)
-- NB: typePrimRep1 fails on unboxed tuples,
-- but by StgCmm no Ids have unboxed tuple type
-- See also Note [VoidRep] in RepType
-- | Assumes that Ids have one PrimRep, which holds after unarisation.
-- See Note [Post-unarisation invariants]
addIdReps :: [NonVoid Id] -> [NonVoid (PrimRep, Id)]
addIdReps = map (\id -> let id' = fromNonVoid id
in NonVoid (idPrimRep id', id'))
-- | Assumes that arguments have one PrimRep, which holds after unarisation.
-- See Note [Post-unarisation invariants]
addArgReps :: [NonVoid StgArg] -> [NonVoid (PrimRep, StgArg)]
addArgReps = map (\arg -> let arg' = fromNonVoid arg
in NonVoid (argPrimRep arg', arg'))
-- | Assumes that the argument has one PrimRep, which holds after unarisation.
-- See Note [Post-unarisation invariants]
argPrimRep :: StgArg -> PrimRep
argPrimRep arg = typePrimRep1 (stgArgType arg)
......
......@@ -472,7 +472,9 @@ typePrimRep ty = kindPrimRep (text "typePrimRep" <+>
(typeKind ty)
-- | Like 'typePrimRep', but assumes that there is precisely one 'PrimRep' output;
-- an empty list of PrimReps becomes a VoidRep.
-- This assumption holds after unarise, see Note [Post-unarisation invariants].
-- Before unarise it may or may not hold.
-- See also Note [RuntimeRep and PrimRep] and Note [VoidRep]
typePrimRep1 :: HasDebugCallStack => UnaryType -> PrimRep
typePrimRep1 ty = case typePrimRep ty of
......
......@@ -188,6 +188,8 @@ STG programs after unarisation have these invariants:
`StgCmmEnv.NonVoid`, for example.
* Alt binders (binders in patterns) are always non-void.
* Binders always have zero (for void arguments) or one PrimRep.
-}
{-# LANGUAGE CPP, TupleSections #-}
......
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