module StrictAnal ( saWwTopBinds, saTopBinds ) where
-import Ubiq{-uitous-}
+IMP_Ubiq(){-uitous-}
import CmdLineOpts ( opt_AllStrict, opt_NumbersStrict,
opt_D_dump_stranal, opt_D_simplifier_stats
)
import CoreSyn
-import Id ( idType, addIdStrictness,
+import Id ( idType, addIdStrictness, isWrapperId,
getIdDemandInfo, addIdDemandInfo,
- GenId{-instance Outputable-}
+ GenId{-instance Outputable-}, SYN_IE(Id)
)
import IdInfo ( mkStrictnessInfo, mkBottomStrictnessInfo,
mkDemandInfo, willBeDemanded, DemandInfo
import PprCore ( pprCoreBinding, pprBigCoreBinder )
import PprStyle ( PprStyle(..) )
import PprType ( GenType{-instance Outputable-}, GenTyVar{-ditto-} )
-import Pretty ( ppBesides, ppStr, ppInt, ppChar, ppAboves )
+import Pretty ( Doc, hcat, ptext, int, char, vcat )
import SaAbsInt
import SaLib
import TyVar ( GenTyVar{-instance Eq-} )
import WorkWrap -- "back-end" of strictness analyser
import Unique ( Unique{-instance Eq -} )
-import Util ( zipWith4Equal, pprTrace, panic{-ToDo:rm-} )
-
-isWrapperId = panic "StrictAnal.isWrapperId (ToDo)"
+import UniqSupply ( UniqSupply )
+import Util ( zipWith4Equal, pprTrace, panic )
\end{code}
-
%************************************************************************
%* *
\subsection[Thoughts]{Random thoughts}
in
-- possibly show what we decided about strictness...
(if opt_D_dump_stranal
- then pprTrace "Strictness:\n" (ppAboves (
+ then pprTrace "Strictness:\n" (vcat (
map (pprCoreBinding PprDebug) binds_w_strictness))
else id
)
where
pp_stats (SaStats tlam dlam tc dc tlet dlet)
= pprTrace "Binders marked demanded: "
- (ppBesides [ppStr "Lambda vars: ", ppInt IBOX(dlam), ppChar '/', ppInt IBOX(tlam),
- ppStr "; Case vars: ", ppInt IBOX(dc), ppChar '/', ppInt IBOX(tc),
- ppStr "; Let vars: ", ppInt IBOX(dlet), ppChar '/', ppInt IBOX(tlet)
+ (hcat [ptext SLIT("Lambda vars: "), int IBOX(dlam), char '/', int IBOX(tlam),
+ ptext SLIT("; Case vars: "), int IBOX(dc), char '/', int IBOX(tc),
+ ptext SLIT("; Let vars: "), int IBOX(dlet), char '/', int IBOX(tlet)
])
#endif
\end{code}
-> Id -- Augmented with strictness
addStrictnessInfoToId strflags str_val abs_val binder body
- = if isWrapperId binder then
- binder -- Avoid clobbering existing strictness info
- -- (and, more importantly, worker info).
- -- Deeply suspicious (SLPJ)
- else
- if (isBot str_val) then
- binder `addIdStrictness` mkBottomStrictnessInfo
- else
- case (collectBinders body) of { (_, _, lambda_bounds, rhs) ->
- let
- tys = map idType lambda_bounds
- strictness = findStrictness strflags tys str_val abs_val
- in
- binder `addIdStrictness` mkStrictnessInfo strictness Nothing
- }
+
+ | isBot str_val
+ = binder `addIdStrictness` mkBottomStrictnessInfo
+
+ | otherwise
+ = case (collectBinders body) of
+ (_, _, [], rhs) -> binder
+ (_, _, lambda_bounds, rhs) -> binder `addIdStrictness`
+ mkStrictnessInfo strictness Nothing
+ where
+ tys = map idType lambda_bounds
+ strictness = findStrictness strflags tys str_val abs_val
\end{code}
\begin{code}