-stg2stg :: [StgToDo] -- spec of what stg-to-stg passes to do
- -> Module -- module name (profiling only)
- -> UniqSupply -- a name supply
- -> [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 stg_todos module_name us binds
- = case (splitUniqSupply us) of { (us4now, us4later) ->
-
- doIfSet do_verbose_stg2stg
- (printErrs (text "VERBOSE STG-TO-STG:" $$
- text "*** Core2Stg:" $$
- vcat (map ppr (setStgVarInfo False binds)))) >>
-
- -- Do the main business!
- foldl_mn do_stg_pass (binds, us4now, ([],[],[])) stg_todos
- >>= \ (processed_binds, _, cost_centres) ->
-
- -- Do essential wind-up
-
- -- Essential wind-up: part (b), do setStgVarInfo. It has to
- -- happen regardless, because the code generator uses its
- -- decorations.
- --
- -- Why does it have to happen last? Because earlier passes
- -- may move things around, which would change the live-var
- -- info. Also, setStgVarInfo decides about let-no-escape
- -- things, which in turn do a better job if arities are
- -- correct, which is done by satStgRhs.
- --
-
- let
- annotated_binds = setStgVarInfo do_let_no_escapes processed_binds
- srt_binds = computeSRTs annotated_binds
- in
-
- return (srt_binds, cost_centres)
- }
- where
- do_let_no_escapes = opt_StgDoLetNoEscapes
- do_verbose_stg2stg = opt_D_verbose_stg2stg
+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"
+ ; us <- mkSplitUniqSupply 'g'
+
+ ; doIfSet_dyn dflags Opt_D_verbose_stg2stg
+ (printDump (text "VERBOSE STG-TO-STG:"))
+
+ ; (binds', us', ccs) <- end_pass us "Stg2Stg" ([],[],[]) binds
+
+ -- Do the main business!
+ ; (processed_binds, _, cost_centres)
+ <- foldl_mn do_stg_pass (binds', us', ccs)
+ (dopt_StgToDo dflags)
+
+ ; let srt_binds = computeSRTs processed_binds
+
+ ; dumpIfSet_dyn dflags Opt_D_dump_stg "STG syntax:"
+ (pprStgBindingsWithSRTs srt_binds)