2 % (c) The AQUA Project, Glasgow University, 1996
4 \section[CmdLineOpts]{Things to do with command-line options}
7 #include "HsVersions.h"
19 maybe_CompilingGhcInternals,
21 opt_AutoSccsOnAllToplevs,
22 opt_AutoSccsOnExportedToplevs,
23 opt_AutoSccsOnIndividualCafs,
24 opt_CompilingGhcInternals,
30 opt_D_dump_occur_anal,
35 opt_D_dump_simpl_iterations,
42 opt_D_simplifier_stats,
44 opt_D_verbose_core2core,
45 opt_D_verbose_stg2stg,
51 opt_EnsureSplittableC,
57 opt_IgnoreIfacePragmas,
58 opt_IrrefutableTuples,
59 opt_LiberateCaseThreshold,
60 opt_NoImplicitPrelude,
63 opt_OmitInterfacePragmas,
66 opt_PprStyle_User, -- ToDo: rm
71 opt_ReportWhyUnfoldingsDisallowed,
72 opt_ReturnInRegsThreshold,
79 opt_SpecialiseImports,
80 opt_SpecialiseOverloaded,
82 opt_SpecialiseUnboxed,
83 opt_StgDoLetNoEscapes,
85 opt_InterfaceUnfoldThreshold,
86 opt_UnfoldingCreationThreshold,
87 opt_UnfoldingConDiscount,
88 opt_UnfoldingUseThreshold,
89 opt_UnfoldingKeenessFactor,
92 opt_WarnNameShadowing,
94 opt_WarnIncompletePatterns, opt_WarnOverlappedPatterns,
95 opt_WarnMissingMethods,
96 opt_PruneTyDecls, opt_PruneInstDecls,
97 opt_D_show_unused_imports,
100 all_toplev_ids_visible
103 IMPORT_1_3(Array(array, (//)))
104 #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ <= 201
105 import PreludeGlaST -- bad bad bad boy, Will (_Array internals)
109 #if __GLASGOW_HASKELL__ >= 209
112 -- 2.04 and later exports Lift from GlaExts
113 #if __GLASGOW_HASKELL__ < 204
114 import PrelBase (Lift(..))
118 CHK_Ubiq() -- debugging consistency check
121 import Constants -- Default values for some flags
122 import Maybes ( assocMaybe, firstJust, maybeToBool )
123 import Util ( startsWith, panic, panic#, assertPanic )
126 A command-line {\em switch} is (generally) either on or off; e.g., the
127 ``verbose'' (-v) switch is either on or off. (The \tr{-G<group>}
128 switch is an exception; it's set to a string, or nothing.)
130 A list of {\em ToDo}s is things to be done in a particular part of
131 processing. A (fictitious) example for the Core-to-Core simplifier
132 might be: run the simplifier, then run the strictness analyser, then
133 run the simplifier again (three ``todos'').
135 There are three ``to-do processing centers'' at the moment. In the
136 main loop (\tr{main/Main.lhs}), in the Core-to-Core processing loop
137 (\tr{simplCore/SimplCore.lhs), and in the STG-to-STG processing loop
138 (\tr{simplStg/SimplStg.lhs}).
140 %************************************************************************
142 \subsection{Datatypes associated with command-line options}
144 %************************************************************************
148 = SwBool Bool -- on/off
149 | SwString FAST_STRING -- nothing or a String
150 | SwInt Int -- nothing or an Int
154 data CoreToDo -- These are diff core-to-core passes,
155 -- which may be invoked in any order,
156 -- as many times as you like.
158 = CoreDoSimplify -- The core-to-core simplifier.
159 (SimplifierSwitch -> SwitchResult)
160 -- Each run of the simplifier can take a different
161 -- set of simplifier-specific flags.
162 | CoreDoCalcInlinings1
163 | CoreDoCalcInlinings2
171 | CoreDoFoldrBuildWorkerWrapper
172 | CoreDoFoldrBuildWWAnal
178 | StgDoUpdateAnalysis
180 | StgDoMassageForProfiling -- should be (next to) last
181 -- There's also setStgVarInfo, but its absolute "lastness"
182 -- is so critical that it is hardwired in (no flag).
187 data SimplifierSwitch
189 | SimplFloatLetsExposingWHNF
190 | SimplOkToFloatPrimOps
191 | SimplAlwaysFloatLetsFromLets
196 | SimplMayDeleteConjurableIds
197 | SimplPedanticBottoms -- see Simplifier for an explanation
198 | SimplDoArityExpand -- expand arity of bindings
199 | SimplDoFoldrBuild -- This is the per-simplification flag;
200 -- see also FoldrBuildOn, used elsewhere
202 | SimplDoInlineFoldrBuild
203 -- inline foldr/build (*after* f/b rule is used)
206 | SimplDoLambdaEtaExpansion
208 | EssentialUnfoldingsOnly -- never mind the thresholds, only
209 -- do unfoldings that *must* be done
210 -- (to saturate constructors and primitives)
212 | ShowSimplifierProgress -- report counts on every interation
214 | MaxSimplifierIterations Int
216 | KeepSpecPragmaIds -- We normally *toss* Ids we can do without
219 | SimplNoLetFromCase -- used when turning off floating entirely
220 | SimplNoLetFromApp -- (for experimentation only) WDP 95/10
221 | SimplNoLetFromStrictLet
223 | SimplDontFoldBackAppend
224 -- we fold `foldr (:)' back into flip (++),
225 -- but we *don't* want to do it when compiling
226 -- List.hs, otherwise
227 -- xs ++ ys = foldr (:) ys xs
228 -- {- via our loopback -}
229 -- xs ++ ys = xs ++ ys
231 -- So only use this flag inside List.hs
232 -- (Sigh, what a HACK, Andy. WDP 96/01)
235 | SimplCaseScrutinee -- This flag tells that the expression being simplified is
236 -- the scrutinee of a case expression, so we should
237 -- apply the scrutinee discount when considering inlinings.
241 %************************************************************************
243 \subsection{Classifying command-line options}
245 %************************************************************************
248 lookUp :: FAST_STRING -> Bool
249 lookup_int :: String -> Maybe Int
250 lookup_def_int :: String -> Int -> Int
251 lookup_def_float :: String -> Float -> Float
252 lookup_str :: String -> Maybe String
254 lookUp sw = maybeToBool (assoc_opts sw)
256 lookup_str sw = firstJust (map (startsWith sw) unpacked_opts)
258 lookup_int sw = case (lookup_str sw) of
260 Just xx -> Just (read xx)
262 lookup_def_int sw def = case (lookup_str sw) of
263 Nothing -> def -- Use default
266 lookup_def_float sw def = case (lookup_str sw) of
267 Nothing -> def -- Use default
270 assoc_opts = assocMaybe [ (a, True) | a <- argv ]
271 unpacked_opts = map _UNPK_ argv
275 opt_AllStrict = lookUp SLIT("-fall-strict")
276 opt_AutoSccsOnAllToplevs = lookUp SLIT("-fauto-sccs-on-all-toplevs")
277 opt_AutoSccsOnExportedToplevs = lookUp SLIT("-fauto-sccs-on-exported-toplevs")
278 opt_AutoSccsOnIndividualCafs = lookUp SLIT("-fauto-sccs-on-individual-cafs")
279 opt_CompilingGhcInternals = maybeToBool maybe_CompilingGhcInternals
280 maybe_CompilingGhcInternals = lookup_str "-fcompiling-ghc-internals="
281 opt_D_dump_absC = lookUp SLIT("-ddump-absC")
282 opt_D_dump_asm = lookUp SLIT("-ddump-asm")
283 opt_D_dump_deriv = lookUp SLIT("-ddump-deriv")
284 opt_D_dump_ds = lookUp SLIT("-ddump-ds")
285 opt_D_dump_flatC = lookUp SLIT("-ddump-flatC")
286 opt_D_dump_occur_anal = lookUp SLIT("-ddump-occur-anal")
287 opt_D_dump_rdr = lookUp SLIT("-ddump-rdr")
288 opt_D_dump_realC = lookUp SLIT("-ddump-realC")
289 opt_D_dump_rn = lookUp SLIT("-ddump-rn")
290 opt_D_dump_simpl = lookUp SLIT("-ddump-simpl")
291 opt_D_dump_simpl_iterations = lookUp SLIT("-ddump-simpl-iterations")
292 opt_D_dump_spec = lookUp SLIT("-ddump-spec")
293 opt_D_dump_stg = lookUp SLIT("-ddump-stg")
294 opt_D_dump_stranal = lookUp SLIT("-ddump-stranal")
295 opt_D_dump_tc = lookUp SLIT("-ddump-tc")
296 opt_D_show_passes = lookUp SLIT("-dshow-passes")
297 opt_D_show_rn_trace = lookUp SLIT("-dshow-rn-trace")
298 opt_D_simplifier_stats = lookUp SLIT("-dsimplifier-stats")
299 opt_D_source_stats = lookUp SLIT("-dsource-stats")
300 opt_D_verbose_core2core = lookUp SLIT("-dverbose-simpl")
301 opt_D_verbose_stg2stg = lookUp SLIT("-dverbose-stg")
302 opt_DoCoreLinting = lookUp SLIT("-dcore-lint")
303 opt_DoStgLinting = lookUp SLIT("-dstg-lint")
304 opt_DoSemiTagging = lookUp SLIT("-fsemi-tagging")
305 opt_DoTickyProfiling = lookUp SLIT("-fticky-ticky")
306 opt_DoEtaReduction = lookUp SLIT("-fdo-eta-reduction")
307 opt_EnsureSplittableC = lookUp SLIT("-fglobalise-toplev-names")
308 opt_FoldrBuildOn = lookUp SLIT("-ffoldr-build-on")
309 opt_ForConcurrent = lookUp SLIT("-fconcurrent")
310 opt_GranMacros = lookUp SLIT("-fgransim")
311 opt_GlasgowExts = lookUp SLIT("-fglasgow-exts")
312 --UNUSED:opt_Haskell_1_3 = lookUp SLIT("-fhaskell-1.3")
313 opt_HiMap = lookup_str "-himap=" -- file saying where to look for .hi files
314 opt_IgnoreIfacePragmas = lookUp SLIT("-fignore-interface-pragmas")
315 opt_IrrefutableTuples = lookUp SLIT("-firrefutable-tuples")
316 opt_NoImplicitPrelude = lookUp SLIT("-fno-implicit-prelude")
317 opt_NumbersStrict = lookUp SLIT("-fnumbers-strict")
318 opt_OmitBlackHoling = lookUp SLIT("-dno-black-holing")
319 opt_OmitInterfacePragmas = lookUp SLIT("-fomit-interface-pragmas")
320 opt_PprStyle_All = lookUp SLIT("-dppr-all")
321 opt_PprStyle_Debug = lookUp SLIT("-dppr-debug")
322 opt_PprStyle_User = lookUp SLIT("-dppr-user")
323 opt_PprUserLength = lookup_def_int "-dppr-user-length" 5 --ToDo: give this a name
324 opt_ProduceC = lookup_str "-C="
325 opt_ProduceS = lookup_str "-S="
326 opt_ProduceHi = lookup_str "-hifile=" -- the one to produce this time
327 opt_ReportWhyUnfoldingsDisallowed= lookUp SLIT("-freport-disallowed-unfoldings")
328 opt_SccProfilingOn = lookUp SLIT("-fscc-profiling")
329 opt_ShowImportSpecs = lookUp SLIT("-fshow-import-specs")
330 opt_SigsRequired = lookUp SLIT("-fsignatures-required")
331 opt_SourceUnchanged = lookUp SLIT("-fsource-unchanged")
332 opt_SpecialiseAll = lookUp SLIT("-fspecialise-all")
333 opt_SpecialiseImports = lookUp SLIT("-fspecialise-imports")
334 opt_SpecialiseOverloaded = lookUp SLIT("-fspecialise-overloaded")
335 opt_SpecialiseTrace = lookUp SLIT("-ftrace-specialisation")
336 opt_SpecialiseUnboxed = lookUp SLIT("-fspecialise-unboxed")
337 opt_StgDoLetNoEscapes = lookUp SLIT("-flet-no-escape")
338 opt_ReturnInRegsThreshold = lookup_int "-freturn-in-regs-threshold"
339 opt_SccGroup = lookup_str "-G="
340 opt_Verbose = lookUp SLIT("-v")
342 opt_InterfaceUnfoldThreshold = lookup_def_int "-funfolding-interface-threshold" iNTERFACE_UNFOLD_THRESHOLD
343 opt_UnfoldingCreationThreshold = lookup_def_int "-funfolding-creation-threshold" uNFOLDING_CREATION_THRESHOLD
344 opt_UnfoldingUseThreshold = lookup_def_int "-funfolding-use-threshold" uNFOLDING_USE_THRESHOLD
345 opt_UnfoldingConDiscount = lookup_def_int "-funfolding-con-discount" uNFOLDING_CON_DISCOUNT_WEIGHT
347 opt_LiberateCaseThreshold = lookup_def_int "-fliberate-case-threshold" lIBERATE_CASE_THRESHOLD
348 opt_UnfoldingKeenessFactor = lookup_def_float "-funfolding-keeness-factor" uNFOLDING_KEENESS_FACTOR
349 opt_WarnNameShadowing = lookUp SLIT("-fwarn-name-shadowing")
350 opt_WarnIncompletePatterns = lookUp SLIT("-fwarn-incomplete-patterns")
351 opt_WarnOverlappedPatterns = lookUp SLIT("-fwarn-overlapped-patterns")
352 opt_WarnUnusedNames = lookUp SLIT("-fwarn-unused-names")
353 opt_WarnMissingMethods = lookUp SLIT("-fwarn-missing-methods")
354 opt_PruneTyDecls = not (lookUp SLIT("-fno-prune-tydecls"))
355 opt_PruneInstDecls = not (lookUp SLIT("-fno-prune-instdecls"))
356 opt_D_show_unused_imports = lookUp SLIT("-dshow-unused-imports")
357 opt_D_show_rn_stats = lookUp SLIT("-dshow-rn-stats")
359 -- opt_UnfoldingOverrideThreshold = lookup_int "-funfolding-override-threshold"
364 all_toplev_ids_visible :: Bool
365 all_toplev_ids_visible =
366 not opt_OmitInterfacePragmas || -- Pragmas can make them visible
367 opt_EnsureSplittableC || -- Splitting requires visiblilty
368 opt_AutoSccsOnAllToplevs -- ditto for profiling
369 -- (ToDo: fix up the auto-annotation
370 -- pass in the desugarer to avoid having
378 classifyOpts :: ([CoreToDo], -- Core-to-Core processing spec
379 [StgToDo]) -- STG-to-STG processing spec
381 classifyOpts = sep argv [] [] -- accumulators...
383 sep :: [FAST_STRING] -- cmd-line opts (input)
384 -> [CoreToDo] -> [StgToDo] -- to_do accumulators
385 -> ([CoreToDo], [StgToDo]) -- result
387 sep [] core_td stg_td -- all done!
388 = (reverse core_td, reverse stg_td)
390 # define CORE_TD(to_do) sep opts (to_do:core_td) stg_td
391 # define STG_TD(to_do) sep opts core_td (to_do:stg_td)
392 # define IGNORE_ARG() sep opts core_td stg_td
394 sep (opt1:opts) core_td stg_td
396 case (_UNPK_ opt1) of -- the non-"just match a string" options are at the end...
398 ',' : _ -> IGNORE_ARG() -- it is for the parser
400 "-fsimplify" -> -- gather up SimplifierSwitches specially...
401 simpl_sep opts defaultSimplSwitches core_td stg_td
403 "-fcalc-inlinings1"-> CORE_TD(CoreDoCalcInlinings1)
404 "-fcalc-inlinings2"-> CORE_TD(CoreDoCalcInlinings2)
405 "-ffloat-inwards" -> CORE_TD(CoreDoFloatInwards)
406 "-ffull-laziness" -> CORE_TD(CoreDoFullLaziness)
407 "-fliberate-case" -> CORE_TD(CoreLiberateCase)
408 "-fprint-core" -> CORE_TD(CoreDoPrintCore)
409 "-fstatic-args" -> CORE_TD(CoreDoStaticArgs)
410 "-fstrictness" -> CORE_TD(CoreDoStrictness)
411 "-fspecialise" -> CORE_TD(CoreDoSpecialising)
412 "-ffoldr-build-worker-wrapper" -> CORE_TD(CoreDoFoldrBuildWorkerWrapper)
413 "-ffoldr-build-ww-anal" -> CORE_TD(CoreDoFoldrBuildWWAnal)
415 "-fstg-static-args" -> STG_TD(StgDoStaticArgs)
416 "-fupdate-analysis" -> STG_TD(StgDoUpdateAnalysis)
417 "-dstg-stats" -> STG_TD(D_stg_stats)
418 "-flambda-lift" -> STG_TD(StgDoLambdaLift)
419 "-fmassage-stg-for-profiling" -> STG_TD(StgDoMassageForProfiling)
421 _ -> -- NB: the driver is really supposed to handle bad options
426 simpl_sep :: [FAST_STRING] -- cmd-line opts (input)
427 -> [SimplifierSwitch] -- simplifier-switch accumulator
428 -> [CoreToDo] -> [StgToDo] -- to_do accumulators
429 -> ([CoreToDo], [StgToDo]) -- result
431 -- "simpl_sep" tailcalls "sep" once it's seen one set
432 -- of SimplifierSwitches for a CoreDoSimplify.
435 simpl_sep input@[] simpl_sw core_td stg_td
436 = panic "simpl_sep []"
439 -- The SimplifierSwitches should be delimited by "[" and "]".
441 simpl_sep (opt1:opts) simpl_sw core_td stg_td
442 = case (_UNPK_ opt1) of
443 "[" -> simpl_sep opts simpl_sw core_td stg_td
445 this_simpl = CoreDoSimplify (isAmongSimpl simpl_sw)
447 sep opts (this_simpl : core_td) stg_td
449 # define SIMPL_SW(sw) simpl_sep opts (sw:simpl_sw) core_td stg_td
451 -- the non-"just match a string" options are at the end...
452 "-fshow-simplifier-progress" -> SIMPL_SW(ShowSimplifierProgress)
453 "-fcode-duplication-ok" -> SIMPL_SW(SimplOkToDupCode)
454 "-ffloat-lets-exposing-whnf" -> SIMPL_SW(SimplFloatLetsExposingWHNF)
455 "-ffloat-primops-ok" -> SIMPL_SW(SimplOkToFloatPrimOps)
456 "-falways-float-lets-from-lets" -> SIMPL_SW(SimplAlwaysFloatLetsFromLets)
457 "-fdo-case-elim" -> SIMPL_SW(SimplDoCaseElim)
458 "-fdo-lambda-eta-expansion" -> SIMPL_SW(SimplDoLambdaEtaExpansion)
459 "-fdo-foldr-build" -> SIMPL_SW(SimplDoFoldrBuild)
460 "-fdo-not-fold-back-append" -> SIMPL_SW(SimplDontFoldBackAppend)
461 "-fdo-arity-expand" -> SIMPL_SW(SimplDoArityExpand)
462 "-fdo-inline-foldr-build" -> SIMPL_SW(SimplDoInlineFoldrBuild)
463 "-freuse-con" -> SIMPL_SW(SimplReuseCon)
464 "-fcase-of-case" -> SIMPL_SW(SimplCaseOfCase)
465 "-fcase-merge" -> SIMPL_SW(SimplCaseMerge)
466 "-flet-to-case" -> SIMPL_SW(SimplLetToCase)
467 "-fpedantic-bottoms" -> SIMPL_SW(SimplPedanticBottoms)
468 "-fkeep-spec-pragma-ids" -> SIMPL_SW(KeepSpecPragmaIds)
469 "-fkeep-unused-bindings" -> SIMPL_SW(KeepUnusedBindings)
470 "-fmay-delete-conjurable-ids" -> SIMPL_SW(SimplMayDeleteConjurableIds)
471 "-fessential-unfoldings-only" -> SIMPL_SW(EssentialUnfoldingsOnly)
472 "-fignore-inline-pragma" -> SIMPL_SW(IgnoreINLINEPragma)
473 "-fno-let-from-case" -> SIMPL_SW(SimplNoLetFromCase)
474 "-fno-let-from-app" -> SIMPL_SW(SimplNoLetFromApp)
475 "-fno-let-from-strict-let" -> SIMPL_SW(SimplNoLetFromStrictLet)
477 o | starts_with_msi -> SIMPL_SW(MaxSimplifierIterations (read after_msi))
479 maybe_msi = startsWith "-fmax-simplifier-iterations" o
480 starts_with_msi = maybeToBool maybe_msi
481 (Just after_msi) = maybe_msi
483 _ -> -- NB: the driver is really supposed to handle bad options
484 simpl_sep opts simpl_sw core_td stg_td
487 %************************************************************************
489 \subsection{Switch ordering}
491 %************************************************************************
493 In spite of the @Produce*@ and @SccGroup@ constructors, these things
494 behave just like enumeration types.
497 instance Eq SimplifierSwitch where
498 a == b = tagOf_SimplSwitch a _EQ_ tagOf_SimplSwitch b
500 instance Ord SimplifierSwitch where
501 a < b = tagOf_SimplSwitch a _LT_ tagOf_SimplSwitch b
502 a <= b = tagOf_SimplSwitch a _LE_ tagOf_SimplSwitch b
504 tagOf_SimplSwitch SimplOkToDupCode =(ILIT(0) :: FAST_INT)
505 tagOf_SimplSwitch SimplFloatLetsExposingWHNF = ILIT(1)
506 tagOf_SimplSwitch SimplOkToFloatPrimOps = ILIT(2)
507 tagOf_SimplSwitch SimplAlwaysFloatLetsFromLets = ILIT(3)
508 tagOf_SimplSwitch SimplDoCaseElim = ILIT(4)
509 tagOf_SimplSwitch SimplReuseCon = ILIT(5)
510 tagOf_SimplSwitch SimplCaseOfCase = ILIT(6)
511 tagOf_SimplSwitch SimplLetToCase = ILIT(7)
512 tagOf_SimplSwitch SimplMayDeleteConjurableIds = ILIT(9)
513 tagOf_SimplSwitch SimplPedanticBottoms = ILIT(10)
514 tagOf_SimplSwitch SimplDoArityExpand = ILIT(11)
515 tagOf_SimplSwitch SimplDoFoldrBuild = ILIT(12)
516 tagOf_SimplSwitch SimplDoInlineFoldrBuild = ILIT(14)
517 tagOf_SimplSwitch IgnoreINLINEPragma = ILIT(15)
518 tagOf_SimplSwitch SimplDoLambdaEtaExpansion = ILIT(16)
519 tagOf_SimplSwitch EssentialUnfoldingsOnly = ILIT(19)
520 tagOf_SimplSwitch ShowSimplifierProgress = ILIT(20)
521 tagOf_SimplSwitch (MaxSimplifierIterations _) = ILIT(21)
522 tagOf_SimplSwitch KeepSpecPragmaIds = ILIT(25)
523 tagOf_SimplSwitch KeepUnusedBindings = ILIT(26)
524 tagOf_SimplSwitch SimplNoLetFromCase = ILIT(27)
525 tagOf_SimplSwitch SimplNoLetFromApp = ILIT(28)
526 tagOf_SimplSwitch SimplNoLetFromStrictLet = ILIT(29)
527 tagOf_SimplSwitch SimplDontFoldBackAppend = ILIT(30)
528 tagOf_SimplSwitch SimplCaseMerge = ILIT(31)
529 tagOf_SimplSwitch SimplCaseScrutinee = ILIT(32)
531 -- If you add anything here, be sure to change lAST_SIMPL_SWITCH_TAG, too!
533 tagOf_SimplSwitch _ = panic# "tagOf_SimplSwitch"
535 lAST_SIMPL_SWITCH_TAG = IBOX(tagOf_SimplSwitch SimplCaseScrutinee)
538 %************************************************************************
540 \subsection{Switch lookup}
542 %************************************************************************
545 #if __GLASGOW_HASKELL__ == 201
547 # define LIFT GHCbase.Lift
550 #elif __GLASGOW_HASKELL__ >= 202
556 # define ARRAY _Array
561 isAmongSimpl :: [SimplifierSwitch] -> SimplifierSwitch -> SwitchResult
563 isAmongSimpl on_switches -- Switches mentioned later occur *earlier*
564 -- in the list; defaults right at the end.
566 tidied_on_switches = foldl rm_dups [] on_switches
567 -- The fold*l* ensures that we keep the latest switches;
568 -- ie the ones that occur earliest in the list.
570 sw_tbl :: Array Int SwitchResult
572 sw_tbl = (array (0, lAST_SIMPL_SWITCH_TAG) -- bounds...
576 all_undefined = [ i SET_TO SwBool False | i <- [0 .. lAST_SIMPL_SWITCH_TAG ] ]
578 defined_elems = map mk_assoc_elem tidied_on_switches
580 -- (avoid some unboxing, bounds checking, and other horrible things:)
581 case sw_tbl of { ARRAY bounds_who_needs_'em stuff ->
583 case (indexArray# stuff (tagOf_SimplSwitch switch)) of
587 mk_assoc_elem k@(MaxSimplifierIterations lvl) = IBOX(tagOf_SimplSwitch k) SET_TO SwInt lvl
589 mk_assoc_elem k = IBOX(tagOf_SimplSwitch k) SET_TO SwBool True -- I'm here, Mom!
591 -- cannot have duplicates if we are going to use the array thing
592 rm_dups switches_so_far switch
593 = if switch `is_elem` switches_so_far
595 else switch : switches_so_far
597 sw `is_elem` [] = False
598 sw `is_elem` (s:ss) = (tagOf_SimplSwitch sw) _EQ_ (tagOf_SimplSwitch s)
602 Default settings for simplifier switches
605 defaultSimplSwitches = [MaxSimplifierIterations 1
609 %************************************************************************
611 \subsection{Misc functions for command-line options}
613 %************************************************************************
617 switchIsOn :: (switch -> SwitchResult) -> switch -> Bool
619 switchIsOn lookup_fn switch
620 = case (lookup_fn switch) of
621 SwBool False -> False
624 stringSwitchSet :: (switch -> SwitchResult)
625 -> (FAST_STRING -> switch)
628 stringSwitchSet lookup_fn switch
629 = case (lookup_fn (switch (panic "stringSwitchSet"))) of
630 SwString str -> Just str
633 intSwitchSet :: (switch -> SwitchResult)
637 intSwitchSet lookup_fn switch
638 = case (lookup_fn (switch (panic "intSwitchSet"))) of
639 SwInt int -> Just int