import StgSyn
-import CostCentre ( CostCentre, CostCentreStack )
+import CostCentre ( CollectedCCs )
import SCCfinal ( stgMassageForProfiling )
import StgLint ( lintStgBindings )
import StgStats ( showStgStats )
import SRT ( computeSRTs )
import CmdLineOpts ( DynFlags, DynFlag(..), dopt,
- opt_StgDoLetNoEscapes,
StgToDo(..), dopt_StgToDo
)
import Id ( Id )
import Module ( Module )
import ErrUtils ( doIfSet_dyn, dumpIfSet_dyn, showPass )
-import UniqSupply ( mkSplitUniqSupply, splitUniqSupply, UniqSupply )
-import IO ( hPutStr, stdout )
+import UniqSupply ( mkSplitUniqSupply, splitUniqSupply )
import Outputable
\end{code}
\begin{code}
-stg2stg :: DynFlags -- includes spec of what stg-to-stg passes to do
- -> Module -- module name (profiling only)
- -> [StgBinding] -- input...
- -> IO
- ([(StgBinding,[Id])], -- output program...
- ([CostCentre], -- local cost-centres that need to be decl'd
- [CostCentre], -- "extern" cost-centres
- [CostCentreStack])) -- pre-defined "singleton" cost centre stacks
+stg2stg :: DynFlags -- includes spec of what stg-to-stg passes to do
+ -> Module -- module name (profiling only)
+ -> [StgBinding] -- input...
+ -> IO ( [(StgBinding,[(Id,[Id])])] -- output program...
+ , CollectedCCs) -- cost centre information (declared and used)
stg2stg dflags module_name binds
= do { showPass dflags "Stg2Stg"
end_pass us2 "ProfMassage" collected_CCs binds3
end_pass us2 what ccs binds2
- = -- report verbosely, if required
- (if dopt Opt_D_verbose_stg2stg dflags then
- hPutStr stdout (showSDoc
- (text ("*** "++what++":") $$ vcat (map ppr binds2)
- ))
- else return ()) >>
- let
- linted_binds = stg_linter what binds2
- in
- return (linted_binds, us2, ccs)
+ = do -- report verbosely, if required
+ dumpIfSet_dyn dflags Opt_D_verbose_stg2stg what
+ (vcat (map ppr binds2))
+ let linted_binds = stg_linter what binds2
+ return (linted_binds, us2, ccs)
-- return: processed binds
-- UniqueSupply for the next guy to use
-- cost-centres to be declared/registered (specialised)