%
-% (c) The GRASP/AQUA Project, Glasgow University, 1992-1994
+% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
\section[StgStats]{Gathers statistical information about programs}
\end{enumerate}
\begin{code}
-#include "HsVersions.h"
-
module StgStats ( showStgStats ) where
-import StgSyn
+#include "HsVersions.h"
-import FiniteMap
+import StgSyn
-import Util
+import FiniteMap ( emptyFM, plusFM_C, unitFM, fmToList, FiniteMap )
+import Id (Id)
\end{code}
\begin{code}
combineSEs = foldr combineSE emptySE
countOne :: CounterType -> StatEnv
-countOne c = singletonFM c 1
+countOne c = unitFM c 1
countN :: CounterType -> Int -> StatEnv
-countN = singletonFM
+countN = unitFM
\end{code}
%************************************************************************
-> StgBinding
-> StatEnv
-statBinding top (StgNonRec b rhs)
+statBinding top (StgNonRec _srt b rhs)
= statRhs top (b, rhs)
-statBinding top (StgRec pairs)
+statBinding top (StgRec _srt pairs)
= combineSEs (map (statRhs top) pairs)
statRhs :: Bool -> (Id, StgRhs) -> StatEnv
\begin{code}
statExpr :: StgExpr -> StatEnv
-statExpr (StgApp _ [] lvs)
- = countOne Literals
-statExpr (StgApp _ _ lvs)
- = countOne Applications
-
-statExpr (StgCon con as lvs)
- = countOne ConstructorApps
-
-statExpr (StgPrim op as lvs)
- = countOne PrimitiveApps
-
-statExpr (StgSCC ty l e)
- = statExpr e
+statExpr (StgApp _ _) = countOne Applications
+statExpr (StgLit _) = countOne Literals
+statExpr (StgConApp _ _) = countOne ConstructorApps
+statExpr (StgOpApp _ _ _) = countOne PrimitiveApps
+statExpr (StgSCC l e) = statExpr e
statExpr (StgLetNoEscape lvs_whole lvs_rhss binds body)
= statBinding False{-not top-level-} binds `combineSE`
= statBinding False{-not top-level-} binds `combineSE`
statExpr body
-statExpr (StgCase expr lve lva uniq alts)
+statExpr (StgCase expr lve lva bndr srt alts)
= statExpr expr `combineSE`
stat_alts alts
where
stat_deflt StgNoDefault = emptySE
- stat_deflt (StgBindDefault b u expr) = statExpr expr
+ stat_deflt (StgBindDefault expr) = statExpr expr
\end{code}