import ClosureInfo ( mkClosureLFInfo )
import CmdLineOpts ( DynFlags, DynFlag(..),
opt_SccProfilingOn, opt_EnsureSplittableC )
-import CostCentre ( CostCentre, CostCentreStack )
+import CostCentre ( CollectedCCs )
import Id ( Id, idName, setIdName )
import Name ( nameSrcLoc, nameOccName, nameUnique, isLocalName, mkGlobalName )
import OccName ( mkLocalOcc )
codeGen :: DynFlags
-> Module -- Module name
-> [Module] -- Import names
- -> ([CostCentre], -- Local cost-centres needing declaring/registering
- [CostCentre], -- "extern" cost-centres needing declaring
- [CostCentreStack]) -- Pre-defined "singleton" cost centre stacks
+ -> CollectedCCs -- (Local/global) cost-centres needing declaring/registering.
-> [Id] -- foreign-exported binders
-> [TyCon] -- Local tycons, including ones from classes
-> [(StgBinding,[Id])] -- Bindings to convert, with SRTs
codeGen dflags mod_name imported_modules cost_centre_info fe_binders
tycons stg_binds
= do { showPass dflags "CodeGen"
-
; fl_uniqs <- mkSplitUniqSupply 'f'
- ; let
- datatype_stuff = genStaticConBits cinfo data_tycons
- code_stuff = initC cinfo (mapCs cgTopBinding stg_binds)
- init_stuff = mkModuleInit fe_binders mod_name imported_modules
- cost_centre_info
-
- abstractC = mkAbstractCs [ maybeSplitCode,
- init_stuff,
- code_stuff,
- datatype_stuff]
- -- Put datatype_stuff after code_stuff, because the
- -- datatype closure table (for enumeration types)
- -- to (say) PrelBase_True_closure, which is defined in code_stuff
-
- flat_abstractC = flattenAbsC fl_uniqs abstractC
-
; dumpIfSet_dyn dflags Opt_D_dump_absC "Abstract C" (dumpRealC abstractC)
+ ; let flat_abstractC = flattenAbsC fl_uniqs abstractC
; return flat_abstractC
}
where
- data_tycons = filter isDataTyCon tycons
- cinfo = MkCompInfo mod_name
+ data_tycons = filter isDataTyCon tycons
+ cinfo = MkCompInfo mod_name
+
+ datatype_stuff = genStaticConBits cinfo data_tycons
+ code_stuff = initC cinfo (mapCs cgTopBinding stg_binds)
+ init_stuff = mkModuleInit fe_binders mod_name imported_modules
+ cost_centre_info
+
+ abstractC = mkAbstractCs [ maybeSplitCode,
+ init_stuff,
+ code_stuff,
+ datatype_stuff]
+ -- Put datatype_stuff after code_stuff, because the
+ -- datatype closure table (for enumeration types)
+ -- to (say) PrelBase_True_closure, which is defined in code_stuff
+
\end{code}
%************************************************************************
:: [Id] -- foreign exported functions
-> Module -- module name
-> [Module] -- import names
- -> ([CostCentre], -- cost centre info
- [CostCentre],
- [CostCentreStack])
+ -> CollectedCCs -- cost centre info
-> AbstractC
mkModuleInit fe_binders mod imps cost_centre_info
= let
maybeSplitCode
| opt_EnsureSplittableC = CSplitMarker
| otherwise = AbsCNop
-\end{code}
\ No newline at end of file
+\end{code}
-- All abstract except to friend: ParseIface.y
CostCentreStack,
+ CollectedCCs,
noCCS, subsumedCCS, currentCCS, overheadCCS, dontCareCCS,
noCostCentre, noCCAttached,
noCCSAttached, isCurrentCCS, isSubsumedCCS, currentOrSubsumedCCS,
-- "dupd".
data IsCafCC = CafCC | NotCafCC
+
+-- synonym for triple which describes the cost centre info in the generated
+-- code for a module.
+type CollectedCCs
+ = ( [CostCentre] -- local cost-centres that need to be decl'd
+ , [CostCentre] -- "extern" cost-centres
+ , [CostCentreStack] -- pre-defined "singleton" cost centre stacks
+ )
\end{code}
WILL: Would there be any merit to recording ``I am now using a
import StgSyn
-import CostCentre ( CostCentre, CostCentreStack )
+import CostCentre ( CollectedCCs )
import SCCfinal ( stgMassageForProfiling )
import StgLint ( lintStgBindings )
import StgStats ( showStgStats )
\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])] -- output program...
+ , CollectedCCs) -- cost centre information (declared and used)
stg2stg dflags module_name binds
= do { showPass dflags "Stg2Stg"