-- Arity
ArityInfo(..),
- exactArity, atLeastArity, unknownArity, hasArity,
+ exactArity, unknownArity, hasArity,
arityInfo, setArityInfo, ppArityInfo, arityLowerBound,
-- New demand and strictness info
= info { unfoldingInfo = uf }
setDemandInfo info dd = info { demandInfo = dd }
-setArityInfo info ar = info { arityInfo = ar }
+setArityInfo info ar = info { arityInfo = Just ar }
setCgInfo info cg = info { cgInfo = cg }
setCprInfo info cp = info { cprInfo = cp }
setLBVarInfo info lb = info { lbvarInfo = lb }
vanillaIdInfo
= IdInfo {
cgInfo = noCgInfo,
- arityInfo = UnknownArity,
+ arityInfo = unknownArity,
demandInfo = wwLazy,
specInfo = emptyCoreRules,
tyGenInfo = noTyGenInfo,
besides the code-generator need arity info!)
\begin{code}
-data ArityInfo
- = UnknownArity -- No idea
+type ArityInfo = Maybe Arity
+ -- A partial application of this Id to up to n-1 value arguments
+ -- does essentially no work. That is not necessarily the
+ -- same as saying that it has n leading lambdas, because coerces
+ -- may get in the way.
- | ArityExactly Arity -- Arity is exactly this. We use this when importing a
- -- function; it's already been compiled and we know its
- -- arity for sure.
-
- | ArityAtLeast Arity -- A partial application of this Id to up to n-1 value arguments
- -- does essentially no work. That is not necessarily the
- -- same as saying that it has n leading lambdas, because coerces
- -- may get in the way.
-
- -- functions in the module being compiled. Their arity
- -- might increase later in the compilation process, if
- -- an extra lambda floats up to the binding site.
- deriving( Eq )
+ -- The arity might increase later in the compilation process, if
+ -- an extra lambda floats up to the binding site.
seqArity :: ArityInfo -> ()
seqArity a = arityLowerBound a `seq` ()
-exactArity = ArityExactly
-atLeastArity = ArityAtLeast
-unknownArity = UnknownArity
+exactArity = Just
+unknownArity = Nothing
arityLowerBound :: ArityInfo -> Arity
-arityLowerBound UnknownArity = 0
-arityLowerBound (ArityAtLeast n) = n
-arityLowerBound (ArityExactly n) = n
+arityLowerBound Nothing = 0
+arityLowerBound (Just n) = n
hasArity :: ArityInfo -> Bool
-hasArity UnknownArity = False
-hasArity other = True
+hasArity Nothing = False
+hasArity other = True
-ppArityInfo UnknownArity = empty
-ppArityInfo (ArityExactly arity) = hsep [ptext SLIT("ArityExactly"), int arity]
-ppArityInfo (ArityAtLeast arity) = hsep [ptext SLIT("ArityAtLeast"), int arity]
+ppArityInfo Nothing = empty
+ppArityInfo (Just arity) = hsep [ptext SLIT("Arity"), int arity]
\end{code}
%************************************************************************
id = mkGlobalId (DataConId data_con) work_name (dataConRepType data_con) info
info = noCafNoTyGenIdInfo
`setCgArity` arity
- `setArityInfo` exactArity arity
+ `setArityInfo` arity
`setCprInfo` cpr_info
`setStrictnessInfo` strict_info
`setNewStrictnessInfo` mkNewStrictnessInfo id arity strict_info cpr_info
-- wrapper constructor isn't inlined
`setCgArity` arity
-- The NoCaf-ness is set by noCafNoTyGenIdInfo
- `setArityInfo` exactArity arity
+ `setArityInfo` arity
-- It's important to specify the arity, so that partial
-- applications are treated as values
`setNewStrictnessInfo` mkNewStrictnessInfo wrap_id arity noStrictnessInfo cpr_info
arity = 1 + n_dict_tys + n_field_dict_tys
info = noCafNoTyGenIdInfo
`setCgInfo` (CgInfo arity caf_info)
- `setArityInfo` exactArity arity
+ `setArityInfo` arity
`setUnfoldingInfo` unfolding
-- ToDo: consider adding further IdInfo
info = noCafNoTyGenIdInfo
`setCgArity` 1
- `setArityInfo` exactArity 1
+ `setArityInfo` 1
`setUnfoldingInfo` unfolding
-- We no longer use 'must-inline' on record selectors. They'll
info = noCafNoTyGenIdInfo
`setSpecInfo` rules
`setCgArity` arity
- `setArityInfo` exactArity arity
+ `setArityInfo` arity
`setStrictnessInfo` strict_info
`setNewStrictnessInfo` mkNewStrictnessInfo id arity strict_info NoCPRInfo
info = noCafNoTyGenIdInfo
`setCgArity` arity
- `setArityInfo` exactArity arity
+ `setArityInfo` arity
`setStrictnessInfo` strict_info
`setNewStrictnessInfo` mkNewStrictnessInfo id arity strict_info NoCPRInfo
)
import IdInfo ( OccInfo(..), isDeadOcc, isLoopBreaker,
setArityInfo,
- setUnfoldingInfo, atLeastArity,
+ setUnfoldingInfo,
occInfo
)
import Demand ( isStrict )
-- We make new IdInfo for the new binder by starting from the old binder,
-- doing appropriate substitutions.
-- Then we add arity and unfolding info to get the new binder
- new_bndr_info = idInfo new_bndr `setArityInfo` arity_info
+ new_bndr_info = idInfo new_bndr `setArityInfo` arity
-- Add the unfolding *only* for non-loop-breakers
-- Making loop breakers not have an unfolding at all
loop_breaker = isLoopBreaker occ_info
trivial_rhs = exprIsTrivial new_rhs
must_keep_binding = black_listed || loop_breaker || isExportedId old_bndr
- arity_info = atLeastArity (exprArity new_rhs)
+ arity = exprArity new_rhs
\end{code}