-\begin{code}
-opt_AllStrict = lookUp SLIT("-fall-strict")
-opt_AllowOverlappingInstances = lookUp SLIT("-fallow-overlapping-instances")
-opt_AllowUndecidableInstances = lookUp SLIT("-fallow-undecidable-instances")
-opt_AutoSccsOnAllToplevs = lookUp SLIT("-fauto-sccs-on-all-toplevs")
-opt_AutoSccsOnExportedToplevs = lookUp SLIT("-fauto-sccs-on-exported-toplevs")
-opt_AutoSccsOnIndividualCafs = lookUp SLIT("-fauto-sccs-on-individual-cafs")
-opt_D_dump_absC = lookUp SLIT("-ddump-absC")
-opt_D_dump_asm = lookUp SLIT("-ddump-asm")
-opt_D_dump_deriv = lookUp SLIT("-ddump-deriv")
-opt_D_dump_ds = lookUp SLIT("-ddump-ds")
-opt_D_dump_flatC = lookUp SLIT("-ddump-flatC")
-opt_D_dump_inlinings = lookUp SLIT("-ddump-inlinings")
-opt_D_dump_foreign = lookUp SLIT("-ddump-foreign-stubs")
-opt_D_dump_occur_anal = lookUp SLIT("-ddump-occur-anal")
-opt_D_dump_rdr = lookUp SLIT("-ddump-rdr")
-opt_D_dump_realC = lookUp SLIT("-ddump-realC")
-opt_D_dump_rn = lookUp SLIT("-ddump-rn")
-opt_D_dump_simpl = lookUp SLIT("-ddump-simpl")
-opt_D_dump_simpl_iterations = lookUp SLIT("-ddump-simpl-iterations")
-opt_D_dump_spec = lookUp SLIT("-ddump-spec")
-opt_D_dump_stg = lookUp SLIT("-ddump-stg")
-opt_D_dump_stranal = lookUp SLIT("-ddump-stranal")
-opt_D_dump_tc = lookUp SLIT("-ddump-tc")
-opt_D_show_passes = lookUp SLIT("-dshow-passes")
-opt_D_show_rn_trace = lookUp SLIT("-dshow-rn-trace")
-opt_D_show_rn_imports = lookUp SLIT("-dshow-rn-imports")
-opt_D_simplifier_stats = lookUp SLIT("-dsimplifier-stats")
-opt_D_source_stats = lookUp SLIT("-dsource-stats")
-opt_D_verbose_core2core = lookUp SLIT("-dverbose-simpl")
-opt_D_verbose_stg2stg = lookUp SLIT("-dverbose-stg")
-opt_DictsStrict = lookUp SLIT("-fdicts-strict")
-opt_DoCoreLinting = lookUp SLIT("-dcore-lint")
-opt_DoStgLinting = lookUp SLIT("-dstg-lint")
-opt_DoEtaReduction = lookUp SLIT("-fdo-eta-reduction")
-opt_DoSemiTagging = lookUp SLIT("-fsemi-tagging")
-opt_DoTickyProfiling = lookUp SLIT("-fticky-ticky")
-opt_EmitCExternDecls = lookUp SLIT("-femit-extern-decls")
-opt_EnsureSplittableC = lookUp SLIT("-fglobalise-toplev-names")
-opt_FoldrBuildOn = lookUp SLIT("-ffoldr-build-on")
-opt_GranMacros = lookUp SLIT("-fgransim")
-opt_GlasgowExts = lookUp SLIT("-fglasgow-exts")
-opt_HiMap = lookup_str "-himap=" -- file saying where to look for .hi files
-opt_HiVersion = lookup_def_int "-fhi-version=" 0 -- what version we're compiling.
-opt_IgnoreIfacePragmas = lookUp SLIT("-fignore-interface-pragmas")
-opt_IrrefutableTuples = lookUp SLIT("-firrefutable-tuples")
-opt_MaxContextReductionDepth = lookup_def_int "-fcontext-stack" mAX_CONTEXT_REDUCTION_DEPTH
-opt_MultiParamClasses = opt_GlasgowExts
-opt_NoHiCheck = lookUp SLIT("-fno-hi-version-check")
-opt_NoImplicitPrelude = lookUp SLIT("-fno-implicit-prelude")
-opt_NoPreInlining = lookUp SLIT("-fno-pre-inlining")
-opt_NumbersStrict = lookUp SLIT("-fnumbers-strict")
-opt_OmitBlackHoling = lookUp SLIT("-dno-black-holing")
-opt_OmitInterfacePragmas = lookUp SLIT("-fomit-interface-pragmas")
-opt_PprStyle_NoPrags = lookUp SLIT("-dppr-noprags")
-opt_PprStyle_Debug = lookUp SLIT("-dppr-debug")
-opt_PprUserLength = lookup_def_int "-dppr-user-length" 5 --ToDo: give this a name
-opt_ProduceC = lookup_str "-C="
-opt_ProduceS = lookup_str "-S="
-opt_ProduceExportCStubs = lookup_str "-F="
-opt_ProduceExportHStubs = lookup_str "-FH="
-opt_ProduceHi = lookup_str "-hifile=" -- the one to produce this time
-opt_ReportCompile = lookUp SLIT("-freport-compile")
-opt_SccProfilingOn = lookUp SLIT("-fscc-profiling")
-opt_SourceUnchanged = lookUp SLIT("-fsource-unchanged")
-opt_StgDoLetNoEscapes = lookUp SLIT("-flet-no-escape")
-opt_Parallel = lookUp SLIT("-fparallel")
-opt_Static = lookUp SLIT("-static")
-opt_SccGroup = lookup_str "-G="
-opt_Verbose = lookUp SLIT("-v")
-
-opt_UnfoldCasms = lookUp SLIT("-funfold-casms-in-hi-file")
-opt_InterfaceUnfoldThreshold = lookup_def_int "-funfolding-interface-threshold" iNTERFACE_UNFOLD_THRESHOLD
-opt_UnfoldingCreationThreshold = lookup_def_int "-funfolding-creation-threshold" uNFOLDING_CREATION_THRESHOLD
-opt_UnfoldingUseThreshold = lookup_def_int "-funfolding-use-threshold" uNFOLDING_USE_THRESHOLD
-opt_UnfoldingConDiscount = lookup_def_int "-funfolding-con-discount" uNFOLDING_CON_DISCOUNT_WEIGHT
-
-opt_LiberateCaseThreshold = lookup_def_int "-fliberate-case-threshold" lIBERATE_CASE_THRESHOLD
-opt_UnfoldingKeenessFactor = lookup_def_float "-funfolding-keeness-factor" uNFOLDING_KEENESS_FACTOR
-opt_WarnNameShadowing = lookUp SLIT("-fwarn-name-shadowing")
-opt_WarnHiShadows = lookUp SLIT("-fwarn-hi-shadowing")
-opt_WarnIncompletePatterns = lookUp SLIT("-fwarn-incomplete-patterns")
-opt_WarnOverlappingPatterns = lookUp SLIT("-fwarn-overlapping-patterns")
-opt_WarnSimplePatterns = lookUp SLIT("-fwarn-simple-patterns")
-opt_WarnTypeDefaults = lookUp SLIT("-fwarn-type-defaults")
-opt_WarnUnusedMatches = lookUp SLIT("-fwarn-unused-matches")
-opt_WarnUnusedBinds = lookUp SLIT("-fwarn-unused-binds")
-opt_WarnUnusedImports = lookUp SLIT("-fwarn-unused-imports")
-opt_WarnMissingMethods = lookUp SLIT("-fwarn-missing-methods")
-opt_WarnDuplicateExports = lookUp SLIT("-fwarn-duplicate-exports")
-opt_WarnMissingSigs = lookUp SLIT("-fwarn-missing-signatures")
-opt_PruneTyDecls = not (lookUp SLIT("-fno-prune-tydecls"))
-opt_PruneInstDecls = not (lookUp SLIT("-fno-prune-instdecls"))
-opt_D_show_rn_stats = lookUp SLIT("-dshow-rn-stats")
-
--- opt_UnfoldingOverrideThreshold = lookup_int "-funfolding-override-threshold"
-\end{code}
-
-\begin{code}
-classifyOpts :: ([CoreToDo], -- Core-to-Core processing spec
- [StgToDo]) -- STG-to-STG processing spec
-
-classifyOpts = sep argv [] [] -- accumulators...
- where
- sep :: [FAST_STRING] -- cmd-line opts (input)
- -> [CoreToDo] -> [StgToDo] -- to_do accumulators
- -> ([CoreToDo], [StgToDo]) -- result
-
- sep [] core_td stg_td -- all done!
- = (reverse core_td, reverse stg_td)
-
-# define CORE_TD(to_do) sep opts (to_do:core_td) stg_td
-# define STG_TD(to_do) sep opts core_td (to_do:stg_td)
-
- sep (opt1:opts) core_td stg_td
- = case (_UNPK_ opt1) of -- the non-"just match a string" options are at the end...
- ',' : _ -> sep opts core_td stg_td -- it is for the parser
-
- "-fsimplify" -> -- gather up SimplifierSwitches specially...
- simpl_sep opts defaultSimplSwitches core_td stg_td
-
- "-fcalc-inlinings1"-> CORE_TD(CoreDoCalcInlinings1)
- "-fcalc-inlinings2"-> CORE_TD(CoreDoCalcInlinings2)
- "-ffloat-inwards" -> CORE_TD(CoreDoFloatInwards)
- "-ffull-laziness" -> CORE_TD(CoreDoFullLaziness)
- "-fliberate-case" -> CORE_TD(CoreLiberateCase)
- "-fprint-core" -> CORE_TD(CoreDoPrintCore)
- "-fstatic-args" -> CORE_TD(CoreDoStaticArgs)
- "-fstrictness" -> CORE_TD(CoreDoStrictness)
- "-fspecialise" -> CORE_TD(CoreDoSpecialising)
- "-ffoldr-build-worker-wrapper" -> CORE_TD(CoreDoFoldrBuildWorkerWrapper)
- "-ffoldr-build-ww-anal" -> CORE_TD(CoreDoFoldrBuildWWAnal)
-
- "-fstg-static-args" -> STG_TD(StgDoStaticArgs)
- "-fupdate-analysis" -> STG_TD(StgDoUpdateAnalysis)
- "-dstg-stats" -> STG_TD(D_stg_stats)
- "-flambda-lift" -> STG_TD(StgDoLambdaLift)
- "-fmassage-stg-for-profiling" -> STG_TD(StgDoMassageForProfiling)
-
- _ -> -- NB: the driver is really supposed to handle bad options
- sep opts core_td stg_td
-
- ----------------
-
- simpl_sep :: [FAST_STRING] -- cmd-line opts (input)
- -> [SimplifierSwitch] -- simplifier-switch accumulator
- -> [CoreToDo] -> [StgToDo] -- to_do accumulators
- -> ([CoreToDo], [StgToDo]) -- result
-
- -- "simpl_sep" tailcalls "sep" once it's seen one set
- -- of SimplifierSwitches for a CoreDoSimplify.
-
-#ifdef DEBUG
- simpl_sep input@[] simpl_sw core_td stg_td
- = panic "simpl_sep []"
-#endif
-
- -- The SimplifierSwitches should be delimited by "[" and "]".
-
- simpl_sep (opt1:opts) simpl_sw core_td stg_td
- = case (_UNPK_ opt1) of
- "[" -> simpl_sep opts simpl_sw core_td stg_td
- "]" -> let
- this_simpl = CoreDoSimplify (isAmongSimpl simpl_sw)
- in
- sep opts (this_simpl : core_td) stg_td
-
-# define SIMPL_SW(sw) simpl_sep opts (sw:simpl_sw) core_td stg_td
-
- -- the non-"just match a string" options are at the end...
- "-fcode-duplication-ok" -> SIMPL_SW(SimplOkToDupCode)
- "-ffloat-lets-exposing-whnf" -> SIMPL_SW(SimplFloatLetsExposingWHNF)
- "-ffloat-primops-ok" -> SIMPL_SW(SimplOkToFloatPrimOps)
- "-falways-float-lets-from-lets" -> SIMPL_SW(SimplAlwaysFloatLetsFromLets)
- "-fdo-case-elim" -> SIMPL_SW(SimplDoCaseElim)
- "-fdo-lambda-eta-expansion" -> SIMPL_SW(SimplDoLambdaEtaExpansion)
- "-fdo-foldr-build" -> SIMPL_SW(SimplDoFoldrBuild)
- "-fdo-arity-expand" -> SIMPL_SW(SimplDoArityExpand)
- "-fdo-inline-foldr-build" -> SIMPL_SW(SimplDoInlineFoldrBuild)
- "-fcase-of-case" -> SIMPL_SW(SimplCaseOfCase)
- "-fcase-merge" -> SIMPL_SW(SimplCaseMerge)
- "-flet-to-case" -> SIMPL_SW(SimplLetToCase)
- "-fpedantic-bottoms" -> SIMPL_SW(SimplPedanticBottoms)
- "-fmay-delete-conjurable-ids" -> SIMPL_SW(SimplMayDeleteConjurableIds)
- "-fessential-unfoldings-only" -> SIMPL_SW(EssentialUnfoldingsOnly)
- "-fignore-inline-pragma" -> SIMPL_SW(IgnoreINLINEPragma)
- "-fno-let-from-case" -> SIMPL_SW(SimplNoLetFromCase)
- "-fno-let-from-app" -> SIMPL_SW(SimplNoLetFromApp)
- "-fno-let-from-strict-let" -> SIMPL_SW(SimplNoLetFromStrictLet)
- "-fclone-binds" -> SIMPL_SW(SimplPleaseClone)
-
- o | starts_with_msi -> SIMPL_SW(MaxSimplifierIterations (read after_msi))
- where
- maybe_msi = startsWith "-fmax-simplifier-iterations" o
- starts_with_msi = maybeToBool maybe_msi
- (Just after_msi) = maybe_msi
-
- _ -> -- NB: the driver is really supposed to handle bad options
- simpl_sep opts simpl_sw core_td stg_td
-\end{code}
-