import StgSyn
import CgMonad
import AbsCSyn
-import CLabel ( CLabel, mkSRTLabel, mkClosureLabel, mkModuleInitLabel )
+import CLabel ( CLabel, mkSRTLabel, mkClosureLabel,
+ mkModuleInitLabel, labelDynamic )
import PprAbsC ( dumpRealC )
-import AbsCUtils ( mkAbstractCs, mkAbsCStmts, flattenAbsC )
+import AbsCUtils ( mkAbstractCs, flattenAbsC )
import CgBindery ( CgIdInfo, addBindC, addBindsC )
import CgClosure ( cgTopRhsClosure )
import CgCon ( cgTopRhsCon )
import CgConTbls ( genStaticConBits )
import ClosureInfo ( mkClosureLFInfo )
-import CmdLineOpts ( opt_SccProfilingOn, opt_EnsureSplittableC,
- opt_D_dump_absC
- )
+import CmdLineOpts ( DynFlags, DynFlag(..),
+ opt_SccProfilingOn, opt_EnsureSplittableC )
import CostCentre ( CostCentre, CostCentreStack )
-import FiniteMap ( FiniteMap )
import Id ( Id, idName )
import Module ( Module, moduleString, moduleName,
- ModuleName, moduleNameString )
+ ModuleName )
import PrimRep ( getPrimRepSize, PrimRep(..) )
import Type ( Type )
import TyCon ( TyCon, isDataTyCon )
import Class ( Class, classTyCon )
import BasicTypes ( TopLevelFlag(..) )
import UniqSupply ( mkSplitUniqSupply )
-import ErrUtils ( dumpIfSet )
+import ErrUtils ( dumpIfSet_dyn )
import Util
import Panic ( assertPanic )
\end{code}
\begin{code}
-codeGen :: Module -- Module name
- -> [ModuleName] -- Import names
+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
-> [(StgBinding,[Id])] -- Bindings to convert, with SRTs
-> IO AbstractC -- Output
-codeGen mod_name imported_modules cost_centre_info fe_binders
+codeGen dflags mod_name imported_modules cost_centre_info fe_binders
tycons classes stg_binds
= mkSplitUniqSupply 'f' >>= \ fl_uniqs -> -- absC flattener
let
flat_abstractC = flattenAbsC fl_uniqs abstractC
in
- dumpIfSet opt_D_dump_absC "Abstract C" (dumpRealC abstractC) >>
+ dumpIfSet_dyn dflags Opt_D_dump_absC "Abstract C" (dumpRealC abstractC) >>
return flat_abstractC
where
mkModuleInit
:: [Id] -- foreign exported functions
-> Module -- module name
- -> [ModuleName] -- import names
+ -> [Module] -- import names
-> ([CostCentre], -- cost centre info
[CostCentre],
[CostCentreStack])
(cc_decls, cc_regs) = mkCostCentreStuff cost_centre_info
- mk_import_register import_name
- = CMacroStmt REGISTER_IMPORT [
- CLbl (mkModuleInitLabel import_name) AddrRep
+ mk_import_register imp =
+ CMacroStmt REGISTER_IMPORT [
+ CLbl (mkModuleInitLabel imp) AddrRep
]
register_imports = map mk_import_register imps
in
mkAbstractCs [
cc_decls,
- CModuleInitBlock (mkModuleInitLabel (Module.moduleName mod))
+ CModuleInitBlock (mkModuleInitLabel mod)
(mkAbstractCs (register_fes ++
cc_regs :
register_imports))