2 % (c) The AQUA Project, Glasgow University, 1996
4 \section[CmdLineOpts]{Things to do with command-line options}
17 maybe_CompilingGhcInternals,
19 opt_AllowOverlappingInstances,
20 opt_AutoSccsOnAllToplevs,
21 opt_AutoSccsOnExportedToplevs,
22 opt_AutoSccsOnIndividualCafs,
23 opt_CompilingGhcInternals,
29 opt_D_dump_occur_anal,
34 opt_D_dump_simpl_iterations,
41 opt_D_show_rn_imports,
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_MultiParamClasses,
62 opt_NoImplicitPrelude,
65 opt_OmitInterfacePragmas,
68 opt_PprStyle_User, -- ToDo: rm
73 opt_ReportWhyUnfoldingsDisallowed,
74 opt_ReturnInRegsThreshold,
81 opt_SpecialiseImports,
82 opt_SpecialiseOverloaded,
84 opt_SpecialiseUnboxed,
85 opt_StgDoLetNoEscapes,
87 opt_InterfaceUnfoldThreshold,
88 opt_UnfoldingCreationThreshold,
89 opt_UnfoldingConDiscount,
90 opt_UnfoldingUseThreshold,
91 opt_UnfoldingKeenessFactor,
94 opt_WarnNameShadowing,
95 opt_WarnUnusedMatches,
97 opt_WarnUnusedImports,
98 opt_WarnIncompletePatterns,
99 opt_WarnOverlappingPatterns,
100 opt_WarnSimplePatterns,
101 opt_WarnMissingMethods,
102 opt_WarnDuplicateExports,
104 opt_PruneTyDecls, opt_PruneInstDecls,
108 #include "HsVersions.h"
110 import Array ( array, (//) )
113 import Constants -- Default values for some flags
115 import Maybes ( assocMaybe, firstJust, maybeToBool )
116 import Util ( startsWith, panic, panic# )
118 #if __GLASGOW_HASKELL__ < 301
119 import ArrBase ( Array(..) )
121 import PrelArr ( Array(..) )
125 A command-line {\em switch} is (generally) either on or off; e.g., the
126 ``verbose'' (-v) switch is either on or off. (The \tr{-G<group>}
127 switch is an exception; it's set to a string, or nothing.)
129 A list of {\em ToDo}s is things to be done in a particular part of
130 processing. A (fictitious) example for the Core-to-Core simplifier
131 might be: run the simplifier, then run the strictness analyser, then
132 run the simplifier again (three ``todos'').
134 There are three ``to-do processing centers'' at the moment. In the
135 main loop (\tr{main/Main.lhs}), in the Core-to-Core processing loop
136 (\tr{simplCore/SimplCore.lhs), and in the STG-to-STG processing loop
137 (\tr{simplStg/SimplStg.lhs}).
139 %************************************************************************
141 \subsection{Datatypes associated with command-line options}
143 %************************************************************************
147 = SwBool Bool -- on/off
148 | SwString FAST_STRING -- nothing or a String
149 | SwInt Int -- nothing or an Int
153 data CoreToDo -- These are diff core-to-core passes,
154 -- which may be invoked in any order,
155 -- as many times as you like.
157 = CoreDoSimplify -- The core-to-core simplifier.
158 (SimplifierSwitch -> SwitchResult)
159 -- Each run of the simplifier can take a different
160 -- set of simplifier-specific flags.
161 | CoreDoCalcInlinings1
162 | CoreDoCalcInlinings2
170 | CoreDoFoldrBuildWorkerWrapper
171 | CoreDoFoldrBuildWWAnal
177 | StgDoUpdateAnalysis
179 | StgDoMassageForProfiling -- should be (next to) last
180 -- There's also setStgVarInfo, but its absolute "lastness"
181 -- is so critical that it is hardwired in (no flag).
186 data SimplifierSwitch
188 | SimplFloatLetsExposingWHNF
189 | SimplOkToFloatPrimOps
190 | SimplAlwaysFloatLetsFromLets
195 | SimplMayDeleteConjurableIds
196 | SimplPedanticBottoms -- see Simplifier for an explanation
197 | SimplDoArityExpand -- expand arity of bindings
198 | SimplDoFoldrBuild -- This is the per-simplification flag;
199 -- see also FoldrBuildOn, used elsewhere
201 | SimplDoInlineFoldrBuild
202 -- inline foldr/build (*after* f/b rule is used)
205 | SimplDoLambdaEtaExpansion
207 | EssentialUnfoldingsOnly -- never mind the thresholds, only
208 -- do unfoldings that *must* be done
209 -- (to saturate constructors and primitives)
211 | ShowSimplifierProgress -- report counts on every interation
213 | MaxSimplifierIterations Int
215 | SimplNoLetFromCase -- used when turning off floating entirely
216 | SimplNoLetFromApp -- (for experimentation only) WDP 95/10
217 | SimplNoLetFromStrictLet
219 | SimplDontFoldBackAppend
220 -- we fold `foldr (:)' back into flip (++),
221 -- but we *don't* want to do it when compiling
222 -- List.hs, otherwise
223 -- xs ++ ys = foldr (:) ys xs
224 -- {- via our loopback -}
225 -- xs ++ ys = xs ++ ys
227 -- So only use this flag inside List.hs
228 -- (Sigh, what a HACK, Andy. WDP 96/01)
231 | SimplCaseScrutinee -- This flag tells that the expression being simplified is
232 -- the scrutinee of a case expression, so we should
233 -- apply the scrutinee discount when considering inlinings.
236 | SimplCloneBinds -- This flag controls whether the simplifier should
237 -- always clone binder ids when creating expression
238 -- copies. The default is NO, but it needs to be turned on
239 -- prior to floating binders outwards.
240 -- (see comment inside SimplVar.simplBinder)
243 %************************************************************************
245 \subsection{Classifying command-line options}
247 %************************************************************************
250 lookUp :: FAST_STRING -> Bool
251 lookup_int :: String -> Maybe Int
252 lookup_def_int :: String -> Int -> Int
253 lookup_def_float :: String -> Float -> Float
254 lookup_str :: String -> Maybe String
256 lookUp sw = maybeToBool (assoc_opts sw)
258 lookup_str sw = firstJust (map (startsWith sw) unpacked_opts)
260 lookup_int sw = case (lookup_str sw) of
262 Just xx -> Just (read xx)
264 lookup_def_int sw def = case (lookup_str sw) of
265 Nothing -> def -- Use default
268 lookup_def_float sw def = case (lookup_str sw) of
269 Nothing -> def -- Use default
272 assoc_opts = assocMaybe [ (a, True) | a <- argv ]
273 unpacked_opts = map _UNPK_ argv
276 Putting the compiler options into temporary at-files
277 may turn out to be necessary later on if we turn hsc into
278 a pure Win32 application where I think there's a command-line
279 length limit of 255. unpacked_opts understands the @ option.
281 assoc_opts = assocMaybe [ (_PK_ a, True) | a <- unpacked_opts ]
283 unpacked_opts :: [String]
289 expandAts ('@':fname) = words (unsafePerformIO (readFile fname))
295 opt_AllStrict = lookUp SLIT("-fall-strict")
296 opt_AllowOverlappingInstances = lookUp SLIT("-fallow-overlapping-instances")
297 opt_AutoSccsOnAllToplevs = lookUp SLIT("-fauto-sccs-on-all-toplevs")
298 opt_AutoSccsOnExportedToplevs = lookUp SLIT("-fauto-sccs-on-exported-toplevs")
299 opt_AutoSccsOnIndividualCafs = lookUp SLIT("-fauto-sccs-on-individual-cafs")
300 opt_CompilingGhcInternals = maybeToBool maybe_CompilingGhcInternals
301 maybe_CompilingGhcInternals = lookup_str "-fcompiling-ghc-internals="
302 opt_D_dump_absC = lookUp SLIT("-ddump-absC")
303 opt_D_dump_asm = lookUp SLIT("-ddump-asm")
304 opt_D_dump_deriv = lookUp SLIT("-ddump-deriv")
305 opt_D_dump_ds = lookUp SLIT("-ddump-ds")
306 opt_D_dump_flatC = lookUp SLIT("-ddump-flatC")
307 opt_D_dump_occur_anal = lookUp SLIT("-ddump-occur-anal")
308 opt_D_dump_rdr = lookUp SLIT("-ddump-rdr")
309 opt_D_dump_realC = lookUp SLIT("-ddump-realC")
310 opt_D_dump_rn = lookUp SLIT("-ddump-rn")
311 opt_D_dump_simpl = lookUp SLIT("-ddump-simpl")
312 opt_D_dump_simpl_iterations = lookUp SLIT("-ddump-simpl-iterations")
313 opt_D_dump_spec = lookUp SLIT("-ddump-spec")
314 opt_D_dump_stg = lookUp SLIT("-ddump-stg")
315 opt_D_dump_stranal = lookUp SLIT("-ddump-stranal")
316 opt_D_dump_tc = lookUp SLIT("-ddump-tc")
317 opt_D_show_passes = lookUp SLIT("-dshow-passes")
318 opt_D_show_rn_trace = lookUp SLIT("-dshow-rn-trace")
319 opt_D_show_rn_imports = lookUp SLIT("-dshow-rn-imports")
320 opt_D_simplifier_stats = lookUp SLIT("-dsimplifier-stats")
321 opt_D_source_stats = lookUp SLIT("-dsource-stats")
322 opt_D_verbose_core2core = lookUp SLIT("-dverbose-simpl")
323 opt_D_verbose_stg2stg = lookUp SLIT("-dverbose-stg")
324 opt_DoCoreLinting = lookUp SLIT("-dcore-lint")
325 opt_DoStgLinting = lookUp SLIT("-dstg-lint")
326 opt_DoSemiTagging = lookUp SLIT("-fsemi-tagging")
327 opt_DoTickyProfiling = lookUp SLIT("-fticky-ticky")
328 opt_DoEtaReduction = lookUp SLIT("-fdo-eta-reduction")
329 opt_EnsureSplittableC = lookUp SLIT("-fglobalise-toplev-names")
330 opt_FoldrBuildOn = lookUp SLIT("-ffoldr-build-on")
331 opt_ForConcurrent = lookUp SLIT("-fconcurrent")
332 opt_GranMacros = lookUp SLIT("-fgransim")
333 opt_GlasgowExts = lookUp SLIT("-fglasgow-exts")
334 opt_HiMap = lookup_str "-himap=" -- file saying where to look for .hi files
335 opt_IgnoreIfacePragmas = lookUp SLIT("-fignore-interface-pragmas")
336 opt_IrrefutableTuples = lookUp SLIT("-firrefutable-tuples")
337 opt_MultiParamClasses = opt_GlasgowExts
338 opt_NoImplicitPrelude = lookUp SLIT("-fno-implicit-prelude")
339 opt_NoHiCheck = lookUp SLIT("-fno-hi-version-check")
340 opt_NumbersStrict = lookUp SLIT("-fnumbers-strict")
341 opt_OmitBlackHoling = lookUp SLIT("-dno-black-holing")
342 opt_OmitInterfacePragmas = lookUp SLIT("-fomit-interface-pragmas")
343 opt_PprStyle_All = lookUp SLIT("-dppr-all")
344 opt_PprStyle_Debug = lookUp SLIT("-dppr-debug")
345 opt_PprStyle_User = lookUp SLIT("-dppr-user")
346 opt_PprUserLength = lookup_def_int "-dppr-user-length" 5 --ToDo: give this a name
347 opt_ProduceC = lookup_str "-C="
348 opt_ProduceS = lookup_str "-S="
349 opt_ProduceHi = lookup_str "-hifile=" -- the one to produce this time
350 opt_ReportWhyUnfoldingsDisallowed= lookUp SLIT("-freport-disallowed-unfoldings")
351 opt_SccProfilingOn = lookUp SLIT("-fscc-profiling")
352 opt_ShowImportSpecs = lookUp SLIT("-fshow-import-specs")
353 opt_SigsRequired = lookUp SLIT("-fsignatures-required")
354 opt_SourceUnchanged = lookUp SLIT("-fsource-unchanged")
355 opt_SpecialiseAll = lookUp SLIT("-fspecialise-all")
356 opt_SpecialiseImports = lookUp SLIT("-fspecialise-imports")
357 opt_SpecialiseOverloaded = lookUp SLIT("-fspecialise-overloaded")
358 opt_SpecialiseTrace = lookUp SLIT("-ftrace-specialisation")
359 opt_SpecialiseUnboxed = lookUp SLIT("-fspecialise-unboxed")
360 opt_StgDoLetNoEscapes = lookUp SLIT("-flet-no-escape")
361 opt_ReturnInRegsThreshold = lookup_int "-freturn-in-regs-threshold"
362 opt_SccGroup = lookup_str "-G="
363 opt_Verbose = lookUp SLIT("-v")
365 opt_InterfaceUnfoldThreshold = lookup_def_int "-funfolding-interface-threshold" iNTERFACE_UNFOLD_THRESHOLD
366 opt_UnfoldingCreationThreshold = lookup_def_int "-funfolding-creation-threshold" uNFOLDING_CREATION_THRESHOLD
367 opt_UnfoldingUseThreshold = lookup_def_int "-funfolding-use-threshold" uNFOLDING_USE_THRESHOLD
368 opt_UnfoldingConDiscount = lookup_def_int "-funfolding-con-discount" uNFOLDING_CON_DISCOUNT_WEIGHT
370 opt_LiberateCaseThreshold = lookup_def_int "-fliberate-case-threshold" lIBERATE_CASE_THRESHOLD
371 opt_UnfoldingKeenessFactor = lookup_def_float "-funfolding-keeness-factor" uNFOLDING_KEENESS_FACTOR
372 opt_WarnNameShadowing = lookUp SLIT("-fwarn-name-shadowing")
373 opt_WarnHiShadows = lookUp SLIT("-fwarn-hi-shadowing")
374 opt_WarnIncompletePatterns = lookUp SLIT("-fwarn-incomplete-patterns")
375 opt_WarnOverlappingPatterns = lookUp SLIT("-fwarn-overlapping-patterns")
376 opt_WarnSimplePatterns = lookUp SLIT("-fwarn-simple-patterns")
377 opt_WarnUnusedMatches = lookUp SLIT("-fwarn-unused-matches")
378 opt_WarnUnusedBinds = lookUp SLIT("-fwarn-unused-binds")
379 opt_WarnUnusedImports = lookUp SLIT("-fwarn-unused-imports")
380 opt_WarnMissingMethods = lookUp SLIT("-fwarn-missing-methods")
381 opt_WarnDuplicateExports = lookUp SLIT("-fwarn-duplicate-exports")
382 opt_PruneTyDecls = not (lookUp SLIT("-fno-prune-tydecls"))
383 opt_PruneInstDecls = not (lookUp SLIT("-fno-prune-instdecls"))
384 opt_D_show_rn_stats = lookUp SLIT("-dshow-rn-stats")
386 -- opt_UnfoldingOverrideThreshold = lookup_int "-funfolding-override-threshold"
390 classifyOpts :: ([CoreToDo], -- Core-to-Core processing spec
391 [StgToDo]) -- STG-to-STG processing spec
393 classifyOpts = sep argv [] [] -- accumulators...
395 sep :: [FAST_STRING] -- cmd-line opts (input)
396 -> [CoreToDo] -> [StgToDo] -- to_do accumulators
397 -> ([CoreToDo], [StgToDo]) -- result
399 sep [] core_td stg_td -- all done!
400 = (reverse core_td, reverse stg_td)
402 # define CORE_TD(to_do) sep opts (to_do:core_td) stg_td
403 # define STG_TD(to_do) sep opts core_td (to_do:stg_td)
405 sep (opt1:opts) core_td stg_td
406 = case (_UNPK_ opt1) of -- the non-"just match a string" options are at the end...
407 ',' : _ -> sep opts core_td stg_td -- it is for the parser
409 "-fsimplify" -> -- gather up SimplifierSwitches specially...
410 simpl_sep opts defaultSimplSwitches core_td stg_td
412 "-fcalc-inlinings1"-> CORE_TD(CoreDoCalcInlinings1)
413 "-fcalc-inlinings2"-> CORE_TD(CoreDoCalcInlinings2)
414 "-ffloat-inwards" -> CORE_TD(CoreDoFloatInwards)
415 "-ffull-laziness" -> CORE_TD(CoreDoFullLaziness)
416 "-fliberate-case" -> CORE_TD(CoreLiberateCase)
417 "-fprint-core" -> CORE_TD(CoreDoPrintCore)
418 "-fstatic-args" -> CORE_TD(CoreDoStaticArgs)
419 "-fstrictness" -> CORE_TD(CoreDoStrictness)
420 "-fspecialise" -> CORE_TD(CoreDoSpecialising)
421 "-ffoldr-build-worker-wrapper" -> CORE_TD(CoreDoFoldrBuildWorkerWrapper)
422 "-ffoldr-build-ww-anal" -> CORE_TD(CoreDoFoldrBuildWWAnal)
424 "-fstg-static-args" -> STG_TD(StgDoStaticArgs)
425 "-fupdate-analysis" -> STG_TD(StgDoUpdateAnalysis)
426 "-dstg-stats" -> STG_TD(D_stg_stats)
427 "-flambda-lift" -> STG_TD(StgDoLambdaLift)
428 "-fmassage-stg-for-profiling" -> STG_TD(StgDoMassageForProfiling)
430 _ -> -- NB: the driver is really supposed to handle bad options
431 sep opts core_td stg_td
435 simpl_sep :: [FAST_STRING] -- cmd-line opts (input)
436 -> [SimplifierSwitch] -- simplifier-switch accumulator
437 -> [CoreToDo] -> [StgToDo] -- to_do accumulators
438 -> ([CoreToDo], [StgToDo]) -- result
440 -- "simpl_sep" tailcalls "sep" once it's seen one set
441 -- of SimplifierSwitches for a CoreDoSimplify.
444 simpl_sep input@[] simpl_sw core_td stg_td
445 = panic "simpl_sep []"
448 -- The SimplifierSwitches should be delimited by "[" and "]".
450 simpl_sep (opt1:opts) simpl_sw core_td stg_td
451 = case (_UNPK_ opt1) of
452 "[" -> simpl_sep opts simpl_sw core_td stg_td
454 this_simpl = CoreDoSimplify (isAmongSimpl simpl_sw)
456 sep opts (this_simpl : core_td) stg_td
458 # define SIMPL_SW(sw) simpl_sep opts (sw:simpl_sw) core_td stg_td
460 -- the non-"just match a string" options are at the end...
461 "-fshow-simplifier-progress" -> SIMPL_SW(ShowSimplifierProgress)
462 "-fcode-duplication-ok" -> SIMPL_SW(SimplOkToDupCode)
463 "-ffloat-lets-exposing-whnf" -> SIMPL_SW(SimplFloatLetsExposingWHNF)
464 "-ffloat-primops-ok" -> SIMPL_SW(SimplOkToFloatPrimOps)
465 "-falways-float-lets-from-lets" -> SIMPL_SW(SimplAlwaysFloatLetsFromLets)
466 "-fdo-case-elim" -> SIMPL_SW(SimplDoCaseElim)
467 "-fdo-lambda-eta-expansion" -> SIMPL_SW(SimplDoLambdaEtaExpansion)
468 "-fdo-foldr-build" -> SIMPL_SW(SimplDoFoldrBuild)
469 "-fdo-not-fold-back-append" -> SIMPL_SW(SimplDontFoldBackAppend)
470 "-fdo-arity-expand" -> SIMPL_SW(SimplDoArityExpand)
471 "-fdo-inline-foldr-build" -> SIMPL_SW(SimplDoInlineFoldrBuild)
472 "-freuse-con" -> SIMPL_SW(SimplReuseCon)
473 "-fcase-of-case" -> SIMPL_SW(SimplCaseOfCase)
474 "-fcase-merge" -> SIMPL_SW(SimplCaseMerge)
475 "-flet-to-case" -> SIMPL_SW(SimplLetToCase)
476 "-fpedantic-bottoms" -> SIMPL_SW(SimplPedanticBottoms)
477 "-fmay-delete-conjurable-ids" -> SIMPL_SW(SimplMayDeleteConjurableIds)
478 "-fessential-unfoldings-only" -> SIMPL_SW(EssentialUnfoldingsOnly)
479 "-fignore-inline-pragma" -> SIMPL_SW(IgnoreINLINEPragma)
480 "-fno-let-from-case" -> SIMPL_SW(SimplNoLetFromCase)
481 "-fno-let-from-app" -> SIMPL_SW(SimplNoLetFromApp)
482 "-fno-let-from-strict-let" -> SIMPL_SW(SimplNoLetFromStrictLet)
483 "-fclone-binds" -> SIMPL_SW(SimplCloneBinds)
485 o | starts_with_msi -> SIMPL_SW(MaxSimplifierIterations (read after_msi))
487 maybe_msi = startsWith "-fmax-simplifier-iterations" o
488 starts_with_msi = maybeToBool maybe_msi
489 (Just after_msi) = maybe_msi
491 _ -> -- NB: the driver is really supposed to handle bad options
492 simpl_sep opts simpl_sw core_td stg_td
495 %************************************************************************
497 \subsection{Switch ordering}
499 %************************************************************************
501 In spite of the @Produce*@ and @SccGroup@ constructors, these things
502 behave just like enumeration types.
505 instance Eq SimplifierSwitch where
506 a == b = tagOf_SimplSwitch a _EQ_ tagOf_SimplSwitch b
508 instance Ord SimplifierSwitch where
509 a < b = tagOf_SimplSwitch a _LT_ tagOf_SimplSwitch b
510 a <= b = tagOf_SimplSwitch a _LE_ tagOf_SimplSwitch b
512 tagOf_SimplSwitch SimplOkToDupCode =(ILIT(0) :: FAST_INT)
513 tagOf_SimplSwitch SimplFloatLetsExposingWHNF = ILIT(1)
514 tagOf_SimplSwitch SimplOkToFloatPrimOps = ILIT(2)
515 tagOf_SimplSwitch SimplAlwaysFloatLetsFromLets = ILIT(3)
516 tagOf_SimplSwitch SimplDoCaseElim = ILIT(4)
517 tagOf_SimplSwitch SimplReuseCon = ILIT(5)
518 tagOf_SimplSwitch SimplCaseOfCase = ILIT(6)
519 tagOf_SimplSwitch SimplLetToCase = ILIT(7)
520 tagOf_SimplSwitch SimplMayDeleteConjurableIds = ILIT(9)
521 tagOf_SimplSwitch SimplPedanticBottoms = ILIT(10)
522 tagOf_SimplSwitch SimplDoArityExpand = ILIT(11)
523 tagOf_SimplSwitch SimplDoFoldrBuild = ILIT(12)
524 tagOf_SimplSwitch SimplDoInlineFoldrBuild = ILIT(14)
525 tagOf_SimplSwitch IgnoreINLINEPragma = ILIT(15)
526 tagOf_SimplSwitch SimplDoLambdaEtaExpansion = ILIT(16)
527 tagOf_SimplSwitch EssentialUnfoldingsOnly = ILIT(19)
528 tagOf_SimplSwitch ShowSimplifierProgress = ILIT(20)
529 tagOf_SimplSwitch (MaxSimplifierIterations _) = ILIT(21)
530 tagOf_SimplSwitch SimplNoLetFromCase = ILIT(27)
531 tagOf_SimplSwitch SimplNoLetFromApp = ILIT(28)
532 tagOf_SimplSwitch SimplNoLetFromStrictLet = ILIT(29)
533 tagOf_SimplSwitch SimplDontFoldBackAppend = ILIT(30)
534 tagOf_SimplSwitch SimplCaseMerge = ILIT(31)
535 tagOf_SimplSwitch SimplCaseScrutinee = ILIT(32)
536 tagOf_SimplSwitch SimplCloneBinds = ILIT(33)
538 -- If you add anything here, be sure to change lAST_SIMPL_SWITCH_TAG, too!
540 tagOf_SimplSwitch _ = panic# "tagOf_SimplSwitch"
542 lAST_SIMPL_SWITCH_TAG = IBOX(tagOf_SimplSwitch SimplCloneBinds)
545 %************************************************************************
547 \subsection{Switch lookup}
549 %************************************************************************
552 isAmongSimpl :: [SimplifierSwitch] -> SimplifierSwitch -> SwitchResult
554 isAmongSimpl on_switches -- Switches mentioned later occur *earlier*
555 -- in the list; defaults right at the end.
557 tidied_on_switches = foldl rm_dups [] on_switches
558 -- The fold*l* ensures that we keep the latest switches;
559 -- ie the ones that occur earliest in the list.
561 sw_tbl :: Array Int SwitchResult
563 sw_tbl = (array (0, lAST_SIMPL_SWITCH_TAG) -- bounds...
567 all_undefined = [ (i, SwBool False) | i <- [0 .. lAST_SIMPL_SWITCH_TAG ] ]
569 defined_elems = map mk_assoc_elem tidied_on_switches
571 -- (avoid some unboxing, bounds checking, and other horrible things:)
572 case sw_tbl of { Array bounds_who_needs_'em stuff ->
574 case (indexArray# stuff (tagOf_SimplSwitch switch)) of
578 mk_assoc_elem k@(MaxSimplifierIterations lvl) = (IBOX(tagOf_SimplSwitch k), SwInt lvl)
580 mk_assoc_elem k = (IBOX(tagOf_SimplSwitch k), SwBool True) -- I'm here, Mom!
582 -- cannot have duplicates if we are going to use the array thing
583 rm_dups switches_so_far switch
584 = if switch `is_elem` switches_so_far
586 else switch : switches_so_far
588 sw `is_elem` [] = False
589 sw `is_elem` (s:ss) = (tagOf_SimplSwitch sw) _EQ_ (tagOf_SimplSwitch s)
593 Default settings for simplifier switches
596 defaultSimplSwitches = [MaxSimplifierIterations 1
600 %************************************************************************
602 \subsection{Misc functions for command-line options}
604 %************************************************************************
608 switchIsOn :: (switch -> SwitchResult) -> switch -> Bool
610 switchIsOn lookup_fn switch
611 = case (lookup_fn switch) of
612 SwBool False -> False
615 intSwitchSet :: (switch -> SwitchResult)
619 intSwitchSet lookup_fn switch
620 = case (lookup_fn (switch (panic "intSwitchSet"))) of
621 SwInt int -> Just int