[project @ 2001-12-20 11:19:05 by simonpj]
[ghc-hetmet.git] / ghc / compiler / main / CmdLineOpts.lhs
1
2 % (c) The University of Glasgow, 1996-2000
3 %
4 \section[CmdLineOpts]{Things to do with command-line options}
5
6 \begin{code}
7
8 module CmdLineOpts (
9         CoreToDo(..), StgToDo(..),
10         SimplifierSwitch(..), 
11         SimplifierMode(..), FloatOutSwitches(..),
12
13         HscLang(..),
14         DynFlag(..),    -- needed non-abstractly by DriverFlags
15         DynFlags(..),
16
17         v_Static_hsc_opts,
18
19         isStaticHscFlag,
20
21         -- Manipulating DynFlags
22         defaultDynFlags,                -- DynFlags
23         dopt,                           -- DynFlag -> DynFlags -> Bool
24         dopt_set, dopt_unset,           -- DynFlags -> DynFlag -> DynFlags
25         dopt_CoreToDo,                  -- DynFlags -> [CoreToDo]
26         dopt_StgToDo,                   -- DynFlags -> [StgToDo]
27         dopt_HscLang,                   -- DynFlags -> HscLang
28         dopt_OutName,                   -- DynFlags -> String
29
30         -- Manipulating the DynFlags state
31         getDynFlags,                    -- IO DynFlags
32         setDynFlags,                    -- DynFlags -> IO ()
33         updDynFlags,                    -- (DynFlags -> DynFlags) -> IO ()
34         dynFlag,                        -- (DynFlags -> a) -> IO a
35         setDynFlag, unSetDynFlag,       -- DynFlag -> IO ()
36         saveDynFlags,                   -- IO ()
37         restoreDynFlags,                -- IO DynFlags
38
39         -- sets of warning opts
40         standardWarnings,
41         minusWOpts,
42         minusWallOpts,
43
44         -- Output style options
45         opt_PprStyle_NoPrags,
46         opt_PprStyle_RawTypes,
47         opt_PprUserLength,
48         opt_PprStyle_Debug,
49
50         -- profiling opts
51         opt_AutoSccsOnAllToplevs,
52         opt_AutoSccsOnExportedToplevs,
53         opt_AutoSccsOnIndividualCafs,
54         opt_AutoSccsOnDicts,
55         opt_SccProfilingOn,
56         opt_DoTickyProfiling,
57
58         -- language opts
59         opt_AllStrict,
60         opt_DictsStrict,
61         opt_MaxContextReductionDepth,
62         opt_IrrefutableTuples,
63         opt_NumbersStrict,
64         opt_Parallel,
65         opt_SMP,
66         opt_NoMonomorphismRestriction,
67         opt_RuntimeTypes,
68
69         -- optimisation opts
70         opt_NoMethodSharing,
71         opt_DoSemiTagging,
72         opt_FoldrBuildOn,
73         opt_LiberateCaseThreshold,
74         opt_StgDoLetNoEscapes,
75         opt_UnfoldCasms,
76         opt_UsageSPOn,
77         opt_UnboxStrictFields,
78         opt_SimplNoPreInlining,
79         opt_SimplDoEtaReduction,
80         opt_SimplDoLambdaEtaExpansion,
81         opt_SimplCaseMerge,
82         opt_SimplExcessPrecision,
83         opt_MaxWorkerArgs,
84
85         -- Unfolding control
86         opt_UF_CreationThreshold,
87         opt_UF_UseThreshold,
88         opt_UF_FunAppDiscount,
89         opt_UF_KeenessFactor,
90         opt_UF_UpdateInPlace,
91         opt_UF_CheapOp,
92         opt_UF_DearOp,
93
94         -- misc opts
95         opt_InPackage,
96         opt_EmitCExternDecls,
97         opt_EnsureSplittableC,
98         opt_GranMacros,
99         opt_HiVersion,
100         opt_HistorySize,
101         opt_IgnoreAsserts,
102         opt_IgnoreIfacePragmas,
103         opt_NoHiCheck,
104         opt_OmitBlackHoling,
105         opt_OmitInterfacePragmas,
106         opt_NoPruneTyDecls,
107         opt_NoPruneDecls,
108         opt_Static,
109         opt_Unregisterised,
110         opt_EmitExternalCore
111     ) where
112
113 #include "HsVersions.h"
114
115 import GlaExts
116 import IOExts   ( IORef, readIORef, writeIORef )
117 import Constants        -- Default values for some flags
118 import Util
119 import FastTypes
120 import Config
121
122 import Maybes           ( firstJust )
123 \end{code}
124
125 %************************************************************************
126 %*                                                                      *
127 \subsection{Command-line options}
128 %*                                                                      *
129 %************************************************************************
130
131 The hsc command-line options are split into two categories:
132
133   - static flags
134   - dynamic flags
135
136 Static flags are represented by top-level values of type Bool or Int,
137 for example.  They therefore have the same value throughout the
138 invocation of hsc.
139
140 Dynamic flags are represented by an abstract type, DynFlags, which is
141 passed into hsc by the compilation manager for every compilation.
142 Dynamic flags are those that change on a per-compilation basis,
143 perhaps because they may be present in the OPTIONS pragma at the top
144 of a module.
145
146 Other flag-related blurb:
147
148 A list of {\em ToDo}s is things to be done in a particular part of
149 processing.  A (fictitious) example for the Core-to-Core simplifier
150 might be: run the simplifier, then run the strictness analyser, then
151 run the simplifier again (three ``todos'').
152
153 There are three ``to-do processing centers'' at the moment.  In the
154 main loop (\tr{main/Main.lhs}), in the Core-to-Core processing loop
155 (\tr{simplCore/SimplCore.lhs), and in the STG-to-STG processing loop
156 (\tr{simplStg/SimplStg.lhs}).
157
158 %************************************************************************
159 %*                                                                      *
160 \subsection{Datatypes associated with command-line options}
161 %*                                                                      *
162 %************************************************************************
163
164 \begin{code}
165 data CoreToDo           -- These are diff core-to-core passes,
166                         -- which may be invoked in any order,
167                         -- as many times as you like.
168
169   = CoreDoSimplify      -- The core-to-core simplifier.
170         SimplifierMode
171         [SimplifierSwitch]
172                         -- Each run of the simplifier can take a different
173                         -- set of simplifier-specific flags.
174   | CoreDoFloatInwards
175   | CoreDoFloatOutwards FloatOutSwitches
176   | CoreLiberateCase
177   | CoreDoPrintCore
178   | CoreDoStaticArgs
179   | CoreDoStrictness
180   | CoreDoWorkerWrapper
181   | CoreDoSpecialising
182   | CoreDoSpecConstr
183   | CoreDoUSPInf
184   | CoreDoCPResult
185   | CoreDoGlomBinds
186   | CoreCSE
187   | CoreDoRuleCheck Int{-CompilerPhase-} String -- Check for non-application of rules 
188                                                 -- matching this string
189
190   | CoreDoNothing        -- useful when building up lists of these things
191 \end{code}
192
193 \begin{code}
194 data StgToDo
195   = StgDoMassageForProfiling  -- should be (next to) last
196   -- There's also setStgVarInfo, but its absolute "lastness"
197   -- is so critical that it is hardwired in (no flag).
198   | D_stg_stats
199 \end{code}
200
201 \begin{code}
202 data SimplifierMode             -- See comments in SimplMonad
203   = SimplGently
204   | SimplPhase Int
205
206 data SimplifierSwitch
207   = MaxSimplifierIterations Int
208   | NoCaseOfCase
209
210 data FloatOutSwitches
211   = FloatOutSw  Bool    -- True <=> float lambdas to top level
212                 Bool    -- True <=> float constants to top level,
213                         --          even if they do not escape a lambda
214 \end{code}
215
216 %************************************************************************
217 %*                                                                      *
218 \subsection{Dynamic command-line options}
219 %*                                                                      *
220 %************************************************************************
221
222 \begin{code}
223 data DynFlag
224
225    -- debugging flags
226    = Opt_D_dump_absC
227    | Opt_D_dump_asm
228    | Opt_D_dump_cpranal
229    | Opt_D_dump_deriv
230    | Opt_D_dump_ds
231    | Opt_D_dump_flatC
232    | Opt_D_dump_foreign
233    | Opt_D_dump_inlinings
234    | Opt_D_dump_occur_anal
235    | Opt_D_dump_parsed
236    | Opt_D_dump_realC
237    | Opt_D_dump_rn
238    | Opt_D_dump_simpl
239    | Opt_D_dump_simpl_iterations
240    | Opt_D_dump_spec
241    | Opt_D_dump_prep
242    | Opt_D_dump_stg
243    | Opt_D_dump_stranal
244    | Opt_D_dump_tc
245    | Opt_D_dump_types
246    | Opt_D_dump_rules
247    | Opt_D_dump_usagesp
248    | Opt_D_dump_cse
249    | Opt_D_dump_worker_wrapper
250    | Opt_D_dump_rn_trace
251    | Opt_D_dump_rn_stats
252    | Opt_D_dump_stix
253    | Opt_D_dump_simpl_stats
254    | Opt_D_dump_tc_trace
255    | Opt_D_dump_BCOs
256    | Opt_D_source_stats
257    | Opt_D_verbose_core2core
258    | Opt_D_verbose_stg2stg
259    | Opt_D_dump_hi
260    | Opt_D_dump_hi_diffs
261    | Opt_D_dump_minimal_imports
262    | Opt_DoCoreLinting
263    | Opt_DoStgLinting
264    | Opt_DoUSPLinting
265
266    | Opt_WarnDuplicateExports
267    | Opt_WarnHiShadows
268    | Opt_WarnIncompletePatterns
269    | Opt_WarnMissingFields
270    | Opt_WarnMissingMethods
271    | Opt_WarnMissingSigs
272    | Opt_WarnNameShadowing
273    | Opt_WarnOverlappingPatterns
274    | Opt_WarnSimplePatterns
275    | Opt_WarnTypeDefaults
276    | Opt_WarnUnusedBinds
277    | Opt_WarnUnusedImports
278    | Opt_WarnUnusedMatches
279    | Opt_WarnDeprecations
280    | Opt_WarnMisc
281
282    -- language opts
283    | Opt_AllowOverlappingInstances
284    | Opt_AllowUndecidableInstances
285    | Opt_AllowIncoherentInstances
286    | Opt_GlasgowExts
287    | Opt_Generics
288    | Opt_NoImplicitPrelude 
289
290    deriving (Eq)
291
292 data DynFlags = DynFlags {
293   coreToDo              :: [CoreToDo],
294   stgToDo               :: [StgToDo],
295   hscLang               :: HscLang,
296   hscOutName            :: String,      -- name of the output file
297   hscStubHOutName       :: String,      -- name of the .stub_h output file
298   hscStubCOutName       :: String,      -- name of the .stub_c output file
299   extCoreName           :: String,      -- name of the .core output file
300   verbosity             :: Int,         -- verbosity level
301   cppFlag               :: Bool,        -- preprocess with cpp?
302   ppFlag                :: Bool,        -- preprocess with a Haskell Pp?
303   stolen_x86_regs       :: Int,         
304   cmdlineHcIncludes     :: [String],    -- -#includes
305
306   -- options for particular phases
307   opt_L                 :: [String],
308   opt_P                 :: [String],
309   opt_F                 :: [String],
310   opt_c                 :: [String],
311   opt_a                 :: [String],
312   opt_m                 :: [String],
313 #ifdef ILX                         
314   opt_I                 :: [String],
315   opt_i                 :: [String],
316 #endif
317
318   -- hsc dynamic flags
319   flags                 :: [DynFlag]
320  }
321
322 data HscLang
323   = HscC
324   | HscAsm
325   | HscJava
326   | HscILX
327   | HscInterpreted
328   | HscNothing
329     deriving (Eq, Show)
330
331 defaultDynFlags = DynFlags {
332   coreToDo = [], stgToDo = [], 
333   hscLang = HscC, 
334   hscOutName = "", 
335   hscStubHOutName = "", hscStubCOutName = "",
336   extCoreName = "",
337   verbosity = 0, 
338   cppFlag               = False,
339   ppFlag                = False,
340   stolen_x86_regs       = 4,
341   cmdlineHcIncludes     = [],
342   opt_L                 = [],
343   opt_P                 = [],
344   opt_F                 = [],
345   opt_c                 = [],
346   opt_a                 = [],
347   opt_m                 = [],
348 #ifdef ILX
349   opt_I                 = [],
350   opt_i                 = [],
351 #endif
352   flags = standardWarnings,
353   }
354
355 {- 
356     Verbosity levels:
357         
358     0   |   print errors & warnings only
359     1   |   minimal verbosity: print "compiling M ... done." for each module.
360     2   |   equivalent to -dshow-passes
361     3   |   equivalent to existing "ghc -v"
362     4   |   "ghc -v -ddump-most"
363     5   |   "ghc -v -ddump-all"
364 -}
365
366 dopt :: DynFlag -> DynFlags -> Bool
367 dopt f dflags  = f `elem` (flags dflags)
368
369 dopt_CoreToDo :: DynFlags -> [CoreToDo]
370 dopt_CoreToDo = coreToDo
371
372 dopt_StgToDo :: DynFlags -> [StgToDo]
373 dopt_StgToDo = stgToDo
374
375 dopt_OutName :: DynFlags -> String
376 dopt_OutName = hscOutName
377
378 dopt_HscLang :: DynFlags -> HscLang
379 dopt_HscLang = hscLang
380
381 dopt_set :: DynFlags -> DynFlag -> DynFlags
382 dopt_set dfs f = dfs{ flags = f : flags dfs }
383
384 dopt_unset :: DynFlags -> DynFlag -> DynFlags
385 dopt_unset dfs f = dfs{ flags = filter (/= f) (flags dfs) }
386 \end{code}
387
388 -----------------------------------------------------------------------------
389 -- Mess about with the mutable variables holding the dynamic arguments
390
391 -- v_InitDynFlags 
392 --      is the "baseline" dynamic flags, initialised from
393 --      the defaults and command line options, and updated by the
394 --      ':s' command in GHCi.
395 --
396 -- v_DynFlags
397 --      is the dynamic flags for the current compilation.  It is reset
398 --      to the value of v_InitDynFlags before each compilation, then
399 --      updated by reading any OPTIONS pragma in the current module.
400
401 \begin{code}
402 GLOBAL_VAR(v_InitDynFlags, defaultDynFlags, DynFlags)
403 GLOBAL_VAR(v_DynFlags,     defaultDynFlags, DynFlags)
404
405 setDynFlags :: DynFlags -> IO ()
406 setDynFlags dfs = writeIORef v_DynFlags dfs
407
408 saveDynFlags :: IO ()
409 saveDynFlags = do dfs <- readIORef v_DynFlags
410                   writeIORef v_InitDynFlags dfs
411
412 restoreDynFlags :: IO DynFlags
413 restoreDynFlags = do dfs <- readIORef v_InitDynFlags
414                      writeIORef v_DynFlags dfs
415                      return dfs
416
417 getDynFlags :: IO DynFlags
418 getDynFlags = readIORef v_DynFlags
419
420 updDynFlags :: (DynFlags -> DynFlags) -> IO ()
421 updDynFlags f = do dfs <- readIORef v_DynFlags
422                    writeIORef v_DynFlags (f dfs)
423
424 dynFlag :: (DynFlags -> a) -> IO a
425 dynFlag f = do dflags <- readIORef v_DynFlags; return (f dflags)
426
427 setDynFlag, unSetDynFlag :: DynFlag -> IO ()
428 setDynFlag f   = updDynFlags (\dfs -> dopt_set dfs f)
429 unSetDynFlag f = updDynFlags (\dfs -> dopt_unset dfs f)
430 \end{code}
431
432
433 %************************************************************************
434 %*                                                                      *
435 \subsection{Warnings}
436 %*                                                                      *
437 %************************************************************************
438
439 \begin{code}
440 standardWarnings
441     = [ Opt_WarnDeprecations,
442         Opt_WarnOverlappingPatterns,
443         Opt_WarnMissingFields,
444         Opt_WarnMissingMethods,
445         Opt_WarnDuplicateExports
446       ]
447
448 minusWOpts
449     = standardWarnings ++ 
450       [ Opt_WarnUnusedBinds,
451         Opt_WarnUnusedMatches,
452         Opt_WarnUnusedImports,
453         Opt_WarnIncompletePatterns,
454         Opt_WarnMisc
455       ]
456
457 minusWallOpts
458     = minusWOpts ++
459       [ Opt_WarnTypeDefaults,
460         Opt_WarnNameShadowing,
461         Opt_WarnMissingSigs,
462         Opt_WarnHiShadows
463       ]
464 \end{code}
465
466 %************************************************************************
467 %*                                                                      *
468 \subsection{Classifying command-line options}
469 %*                                                                      *
470 %************************************************************************
471
472 \begin{code}
473 -- v_Statis_hsc_opts is here to avoid a circular dependency with
474 -- main/DriverState.
475 GLOBAL_VAR(v_Static_hsc_opts, [], [String])
476
477 lookUp           :: FAST_STRING -> Bool
478 lookup_int       :: String -> Maybe Int
479 lookup_def_int   :: String -> Int -> Int
480 lookup_def_float :: String -> Float -> Float
481 lookup_str       :: String -> Maybe String
482
483 unpacked_static_opts = unsafePerformIO (readIORef v_Static_hsc_opts)
484 packed_static_opts   = map _PK_ unpacked_static_opts
485
486 lookUp     sw = sw `elem` packed_static_opts
487         
488 lookup_str sw = firstJust (map (startsWith sw) unpacked_static_opts)
489
490 lookup_int sw = case (lookup_str sw) of
491                   Nothing -> Nothing
492                   Just xx -> Just (read xx)
493
494 lookup_def_int sw def = case (lookup_str sw) of
495                             Nothing -> def              -- Use default
496                             Just xx -> read xx
497
498 lookup_def_float sw def = case (lookup_str sw) of
499                             Nothing -> def              -- Use default
500                             Just xx -> read xx
501
502
503 {-
504  Putting the compiler options into temporary at-files
505  may turn out to be necessary later on if we turn hsc into
506  a pure Win32 application where I think there's a command-line
507  length limit of 255. unpacked_opts understands the @ option.
508
509 unpacked_opts :: [String]
510 unpacked_opts =
511   concat $
512   map (expandAts) $
513   map _UNPK_ argv  -- NOT ARGV any more: v_Static_hsc_opts
514   where
515    expandAts ('@':fname) = words (unsafePerformIO (readFile fname))
516    expandAts l = [l]
517 -}
518 \end{code}
519
520 %************************************************************************
521 %*                                                                      *
522 \subsection{Static options}
523 %*                                                                      *
524 %************************************************************************
525
526 \begin{code}
527 -- debugging opts
528 opt_PprStyle_NoPrags            = lookUp  SLIT("-dppr-noprags")
529 opt_PprStyle_Debug              = lookUp  SLIT("-dppr-debug")
530 opt_PprStyle_RawTypes           = lookUp  SLIT("-dppr-rawtypes")
531 opt_PprUserLength               = lookup_def_int "-dppr-user-length" 5 --ToDo: give this a name
532
533 -- profiling opts
534 opt_AutoSccsOnAllToplevs        = lookUp  SLIT("-fauto-sccs-on-all-toplevs")
535 opt_AutoSccsOnExportedToplevs   = lookUp  SLIT("-fauto-sccs-on-exported-toplevs")
536 opt_AutoSccsOnIndividualCafs    = lookUp  SLIT("-fauto-sccs-on-individual-cafs")
537 opt_AutoSccsOnDicts             = lookUp  SLIT("-fauto-sccs-on-dicts")
538 opt_SccProfilingOn              = lookUp  SLIT("-fscc-profiling")
539 opt_DoTickyProfiling            = lookUp  SLIT("-fticky-ticky")
540
541 -- language opts
542 opt_AllStrict                   = lookUp  SLIT("-fall-strict")
543 opt_NoMonomorphismRestriction   = lookUp  SLIT("-fno-monomorphism-restriction")
544 opt_DictsStrict                 = lookUp  SLIT("-fdicts-strict")
545 opt_IrrefutableTuples           = lookUp  SLIT("-firrefutable-tuples")
546 opt_MaxContextReductionDepth    = lookup_def_int "-fcontext-stack" mAX_CONTEXT_REDUCTION_DEPTH
547 opt_NumbersStrict               = lookUp  SLIT("-fnumbers-strict")
548 opt_Parallel                    = lookUp  SLIT("-fparallel")
549 opt_SMP                         = lookUp  SLIT("-fsmp")
550
551 -- optimisation opts
552 opt_NoMethodSharing             = lookUp  SLIT("-fno-method-sharing")
553 opt_DoSemiTagging               = lookUp  SLIT("-fsemi-tagging")
554 opt_FoldrBuildOn                = lookUp  SLIT("-ffoldr-build-on")
555 opt_LiberateCaseThreshold       = lookup_def_int "-fliberate-case-threshold" (10::Int)
556 opt_StgDoLetNoEscapes           = lookUp  SLIT("-flet-no-escape")
557 opt_UnfoldCasms                 = lookUp  SLIT("-funfold-casms-in-hi-file")
558 opt_UsageSPOn                   = lookUp  SLIT("-fusagesp-on")
559 opt_UnboxStrictFields           = lookUp  SLIT("-funbox-strict-fields")
560 opt_MaxWorkerArgs               = lookup_def_int "-fmax-worker-args" (10::Int)
561
562 {-
563    The optional '-inpackage=P' flag tells what package
564    we are compiling this module for.
565    The Prelude, for example is compiled with '-inpackage std'
566 -}
567 opt_InPackage                   = case lookup_str "-inpackage=" of
568                                     Just p  -> _PK_ p
569                                     Nothing -> SLIT("Main")     -- The package name if none is specified
570
571 opt_EmitCExternDecls            = lookUp  SLIT("-femit-extern-decls")
572 opt_EnsureSplittableC           = lookUp  SLIT("-fglobalise-toplev-names")
573 opt_GranMacros                  = lookUp  SLIT("-fgransim")
574 opt_HiVersion                   = read cProjectVersionInt :: Int
575 opt_HistorySize                 = lookup_def_int "-fhistory-size" 20
576 opt_IgnoreAsserts               = lookUp  SLIT("-fignore-asserts")
577 opt_IgnoreIfacePragmas          = lookUp  SLIT("-fignore-interface-pragmas")
578 opt_NoHiCheck                   = lookUp  SLIT("-fno-hi-version-check")
579 opt_OmitBlackHoling             = lookUp  SLIT("-dno-black-holing")
580 opt_OmitInterfacePragmas        = lookUp  SLIT("-fomit-interface-pragmas")
581 opt_RuntimeTypes                = lookUp  SLIT("-fruntime-types")
582
583 -- Simplifier switches
584 opt_SimplNoPreInlining          = lookUp  SLIT("-fno-pre-inlining")
585         -- NoPreInlining is there just to see how bad things
586         -- get if you don't do it!
587 opt_SimplDoEtaReduction         = lookUp  SLIT("-fdo-eta-reduction")
588 opt_SimplDoLambdaEtaExpansion   = lookUp  SLIT("-fdo-lambda-eta-expansion")
589 opt_SimplCaseMerge              = lookUp  SLIT("-fcase-merge")
590 opt_SimplExcessPrecision        = lookUp  SLIT("-fexcess-precision")
591
592 -- Unfolding control
593 opt_UF_CreationThreshold        = lookup_def_int "-funfolding-creation-threshold"  (45::Int)
594 opt_UF_UseThreshold             = lookup_def_int "-funfolding-use-threshold"       (8::Int)     -- Discounts can be big
595 opt_UF_FunAppDiscount           = lookup_def_int "-funfolding-fun-discount"        (6::Int)     -- It's great to inline a fn
596 opt_UF_KeenessFactor            = lookup_def_float "-funfolding-keeness-factor"    (1.5::Float)
597 opt_UF_UpdateInPlace            = lookUp  SLIT("-funfolding-update-in-place")
598
599 opt_UF_CheapOp  = ( 1 :: Int)   -- Only one instruction; and the args are charged for
600 opt_UF_DearOp   = ( 4 :: Int)
601                         
602 opt_NoPruneDecls                = lookUp  SLIT("-fno-prune-decls")
603 opt_NoPruneTyDecls              = lookUp  SLIT("-fno-prune-tydecls")
604 opt_Static                      = lookUp  SLIT("-static")
605 opt_Unregisterised              = lookUp  SLIT("-funregisterised")
606 opt_EmitExternalCore            = lookUp  SLIT("-fext-core")
607 \end{code}
608
609 %************************************************************************
610 %*                                                                      *
611 \subsection{List of static hsc flags}
612 %*                                                                      *
613 %************************************************************************
614
615 \begin{code}
616 isStaticHscFlag f =
617   f `elem` [
618         "fauto-sccs-on-all-toplevs",
619         "fauto-sccs-on-exported-toplevs",
620         "fauto-sccs-on-individual-cafs",
621         "fauto-sccs-on-dicts",
622         "fscc-profiling",
623         "fticky-ticky",
624         "fall-strict",
625         "fdicts-strict",
626         "firrefutable-tuples",
627         "fnumbers-strict",
628         "fparallel",
629         "fsmp",
630         "fsemi-tagging",
631         "ffoldr-build-on",
632         "flet-no-escape",
633         "funfold-casms-in-hi-file",
634         "fusagesp-on",
635         "funbox-strict-fields",
636         "femit-extern-decls",
637         "fglobalise-toplev-names",
638         "fgransim",
639         "fignore-asserts",
640         "fignore-interface-pragmas",
641         "fno-hi-version-check",
642         "dno-black-holing",
643         "fno-method-sharing",
644         "fno-monomorphism-restriction",
645         "fomit-interface-pragmas",
646         "fruntime-types",
647         "fno-pre-inlining",
648         "fdo-eta-reduction",
649         "fdo-lambda-eta-expansion",
650         "fcase-merge",
651         "fexcess-precision",
652         "funfolding-update-in-place",
653         "fno-prune-decls",
654         "fno-prune-tydecls",
655         "static",
656         "funregisterised",
657         "fext-core",
658         "frule-check"
659         ]
660   || any (flip prefixMatch f) [
661         "fcontext-stack",
662         "fliberate-case-threshold",
663         "fmax-worker-args",
664         "fhistory-size",
665         "funfolding-creation-threshold",
666         "funfolding-use-threshold",
667         "funfolding-fun-discount",
668         "funfolding-keeness-factor"
669      ]
670 \end{code}
671
672 %************************************************************************
673 %*                                                                      *
674 \subsection{Misc functions for command-line options}
675 %*                                                                      *
676 %************************************************************************
677
678
679
680 \begin{code}
681 startsWith :: String -> String -> Maybe String
682 -- startsWith pfx (pfx++rest) = Just rest
683
684 startsWith []     str = Just str
685 startsWith (c:cs) (s:ss)
686   = if c /= s then Nothing else startsWith cs ss
687 startsWith  _     []  = Nothing
688
689 endsWith  :: String -> String -> Maybe String
690 endsWith cs ss
691   = case (startsWith (reverse cs) (reverse ss)) of
692       Nothing -> Nothing
693       Just rs -> Just (reverse rs)
694 \end{code}