[project @ 2001-10-26 00:53:27 by sof]
[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(..),
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 Bool    -- True <=> float lambdas to top level
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 \end{code}
210
211 %************************************************************************
212 %*                                                                      *
213 \subsection{Dynamic command-line options}
214 %*                                                                      *
215 %************************************************************************
216
217 \begin{code}
218 data DynFlag
219
220    -- debugging flags
221    = Opt_D_dump_absC
222    | Opt_D_dump_asm
223    | Opt_D_dump_cpranal
224    | Opt_D_dump_deriv
225    | Opt_D_dump_ds
226    | Opt_D_dump_flatC
227    | Opt_D_dump_foreign
228    | Opt_D_dump_inlinings
229    | Opt_D_dump_occur_anal
230    | Opt_D_dump_parsed
231    | Opt_D_dump_realC
232    | Opt_D_dump_rn
233    | Opt_D_dump_simpl
234    | Opt_D_dump_simpl_iterations
235    | Opt_D_dump_spec
236    | Opt_D_dump_prep
237    | Opt_D_dump_stg
238    | Opt_D_dump_stranal
239    | Opt_D_dump_tc
240    | Opt_D_dump_types
241    | Opt_D_dump_rules
242    | Opt_D_dump_usagesp
243    | Opt_D_dump_cse
244    | Opt_D_dump_worker_wrapper
245    | Opt_D_dump_rn_trace
246    | Opt_D_dump_rn_stats
247    | Opt_D_dump_stix
248    | Opt_D_dump_simpl_stats
249    | Opt_D_dump_tc_trace
250    | Opt_D_dump_BCOs
251    | Opt_D_source_stats
252    | Opt_D_verbose_core2core
253    | Opt_D_verbose_stg2stg
254    | Opt_D_dump_hi
255    | Opt_D_dump_hi_diffs
256    | Opt_D_dump_minimal_imports
257    | Opt_DoCoreLinting
258    | Opt_DoStgLinting
259    | Opt_DoUSPLinting
260
261    | Opt_WarnDuplicateExports
262    | Opt_WarnHiShadows
263    | Opt_WarnIncompletePatterns
264    | Opt_WarnMissingFields
265    | Opt_WarnMissingMethods
266    | Opt_WarnMissingSigs
267    | Opt_WarnNameShadowing
268    | Opt_WarnOverlappingPatterns
269    | Opt_WarnSimplePatterns
270    | Opt_WarnTypeDefaults
271    | Opt_WarnUnusedBinds
272    | Opt_WarnUnusedImports
273    | Opt_WarnUnusedMatches
274    | Opt_WarnDeprecations
275    | Opt_WarnMisc
276
277    -- language opts
278    | Opt_AllowOverlappingInstances
279    | Opt_AllowUndecidableInstances
280    | Opt_GlasgowExts
281    | Opt_Generics
282    | Opt_NoImplicitPrelude 
283
284    deriving (Eq)
285
286 data DynFlags = DynFlags {
287   coreToDo              :: [CoreToDo],
288   stgToDo               :: [StgToDo],
289   hscLang               :: HscLang,
290   hscOutName            :: String,      -- name of the output file
291   hscStubHOutName       :: String,      -- name of the .stub_h output file
292   hscStubCOutName       :: String,      -- name of the .stub_c output file
293   extCoreName           :: String,      -- name of the .core output file
294   verbosity             :: Int,         -- verbosity level
295   cppFlag               :: Bool,        -- preprocess with cpp?
296   ppFlag                :: Bool,        -- preprocess with a Haskell Pp?
297   stolen_x86_regs       :: Int,         
298   cmdlineHcIncludes     :: [String],    -- -#includes
299
300   -- options for particular phases
301   opt_L                 :: [String],
302   opt_P                 :: [String],
303   opt_F                 :: [String],
304   opt_c                 :: [String],
305   opt_a                 :: [String],
306   opt_m                 :: [String],
307 #ifdef ILX                         
308   opt_I                 :: [String],
309   opt_i                 :: [String],
310 #endif
311
312   -- hsc dynamic flags
313   flags                 :: [DynFlag]
314  }
315
316 data HscLang
317   = HscC
318   | HscAsm
319   | HscJava
320   | HscILX
321   | HscInterpreted
322   | HscNothing
323     deriving (Eq, Show)
324
325 defaultDynFlags = DynFlags {
326   coreToDo = [], stgToDo = [], 
327   hscLang = HscC, 
328   hscOutName = "", 
329   hscStubHOutName = "", hscStubCOutName = "",
330   extCoreName = "",
331   verbosity = 0, 
332   cppFlag               = False,
333   ppFlag                = False,
334   stolen_x86_regs       = 4,
335   cmdlineHcIncludes     = [],
336   opt_L                 = [],
337   opt_P                 = [],
338   opt_F                 = [],
339   opt_c                 = [],
340   opt_a                 = [],
341   opt_m                 = [],
342 #ifdef ILX
343   opt_I                 = [],
344   opt_i                 = [],
345 #endif
346   flags = standardWarnings,
347   }
348
349 {- 
350     Verbosity levels:
351         
352     0   |   print errors & warnings only
353     1   |   minimal verbosity: print "compiling M ... done." for each module.
354     2   |   equivalent to -dshow-passes
355     3   |   equivalent to existing "ghc -v"
356     4   |   "ghc -v -ddump-most"
357     5   |   "ghc -v -ddump-all"
358 -}
359
360 dopt :: DynFlag -> DynFlags -> Bool
361 dopt f dflags  = f `elem` (flags dflags)
362
363 dopt_CoreToDo :: DynFlags -> [CoreToDo]
364 dopt_CoreToDo = coreToDo
365
366 dopt_StgToDo :: DynFlags -> [StgToDo]
367 dopt_StgToDo = stgToDo
368
369 dopt_OutName :: DynFlags -> String
370 dopt_OutName = hscOutName
371
372 dopt_HscLang :: DynFlags -> HscLang
373 dopt_HscLang = hscLang
374
375 dopt_set :: DynFlags -> DynFlag -> DynFlags
376 dopt_set dfs f = dfs{ flags = f : flags dfs }
377
378 dopt_unset :: DynFlags -> DynFlag -> DynFlags
379 dopt_unset dfs f = dfs{ flags = filter (/= f) (flags dfs) }
380 \end{code}
381
382 -----------------------------------------------------------------------------
383 -- Mess about with the mutable variables holding the dynamic arguments
384
385 -- v_InitDynFlags 
386 --      is the "baseline" dynamic flags, initialised from
387 --      the defaults and command line options, and updated by the
388 --      ':s' command in GHCi.
389 --
390 -- v_DynFlags
391 --      is the dynamic flags for the current compilation.  It is reset
392 --      to the value of v_InitDynFlags before each compilation, then
393 --      updated by reading any OPTIONS pragma in the current module.
394
395 \begin{code}
396 GLOBAL_VAR(v_InitDynFlags, defaultDynFlags, DynFlags)
397 GLOBAL_VAR(v_DynFlags,     defaultDynFlags, DynFlags)
398
399 setDynFlags :: DynFlags -> IO ()
400 setDynFlags dfs = writeIORef v_DynFlags dfs
401
402 saveDynFlags :: IO ()
403 saveDynFlags = do dfs <- readIORef v_DynFlags
404                   writeIORef v_InitDynFlags dfs
405
406 restoreDynFlags :: IO DynFlags
407 restoreDynFlags = do dfs <- readIORef v_InitDynFlags
408                      writeIORef v_DynFlags dfs
409                      return dfs
410
411 getDynFlags :: IO DynFlags
412 getDynFlags = readIORef v_DynFlags
413
414 updDynFlags :: (DynFlags -> DynFlags) -> IO ()
415 updDynFlags f = do dfs <- readIORef v_DynFlags
416                    writeIORef v_DynFlags (f dfs)
417
418 dynFlag :: (DynFlags -> a) -> IO a
419 dynFlag f = do dflags <- readIORef v_DynFlags; return (f dflags)
420
421 setDynFlag, unSetDynFlag :: DynFlag -> IO ()
422 setDynFlag f   = updDynFlags (\dfs -> dopt_set dfs f)
423 unSetDynFlag f = updDynFlags (\dfs -> dopt_unset dfs f)
424 \end{code}
425
426
427 %************************************************************************
428 %*                                                                      *
429 \subsection{Warnings}
430 %*                                                                      *
431 %************************************************************************
432
433 \begin{code}
434 standardWarnings
435     = [ Opt_WarnDeprecations,
436         Opt_WarnOverlappingPatterns,
437         Opt_WarnMissingFields,
438         Opt_WarnMissingMethods,
439         Opt_WarnDuplicateExports
440       ]
441
442 minusWOpts
443     = standardWarnings ++ 
444       [ Opt_WarnUnusedBinds,
445         Opt_WarnUnusedMatches,
446         Opt_WarnUnusedImports,
447         Opt_WarnIncompletePatterns,
448         Opt_WarnMisc
449       ]
450
451 minusWallOpts
452     = minusWOpts ++
453       [ Opt_WarnTypeDefaults,
454         Opt_WarnNameShadowing,
455         Opt_WarnMissingSigs,
456         Opt_WarnHiShadows
457       ]
458 \end{code}
459
460 %************************************************************************
461 %*                                                                      *
462 \subsection{Classifying command-line options}
463 %*                                                                      *
464 %************************************************************************
465
466 \begin{code}
467 -- v_Statis_hsc_opts is here to avoid a circular dependency with
468 -- main/DriverState.
469 GLOBAL_VAR(v_Static_hsc_opts, [], [String])
470
471 lookUp           :: FAST_STRING -> Bool
472 lookup_int       :: String -> Maybe Int
473 lookup_def_int   :: String -> Int -> Int
474 lookup_def_float :: String -> Float -> Float
475 lookup_str       :: String -> Maybe String
476
477 unpacked_static_opts = unsafePerformIO (readIORef v_Static_hsc_opts)
478 packed_static_opts   = map _PK_ unpacked_static_opts
479
480 lookUp     sw = sw `elem` packed_static_opts
481         
482 lookup_str sw = firstJust (map (startsWith sw) unpacked_static_opts)
483
484 lookup_int sw = case (lookup_str sw) of
485                   Nothing -> Nothing
486                   Just xx -> Just (read xx)
487
488 lookup_def_int sw def = case (lookup_str sw) of
489                             Nothing -> def              -- Use default
490                             Just xx -> read xx
491
492 lookup_def_float sw def = case (lookup_str sw) of
493                             Nothing -> def              -- Use default
494                             Just xx -> read xx
495
496
497 {-
498  Putting the compiler options into temporary at-files
499  may turn out to be necessary later on if we turn hsc into
500  a pure Win32 application where I think there's a command-line
501  length limit of 255. unpacked_opts understands the @ option.
502
503 unpacked_opts :: [String]
504 unpacked_opts =
505   concat $
506   map (expandAts) $
507   map _UNPK_ argv  -- NOT ARGV any more: v_Static_hsc_opts
508   where
509    expandAts ('@':fname) = words (unsafePerformIO (readFile fname))
510    expandAts l = [l]
511 -}
512 \end{code}
513
514 %************************************************************************
515 %*                                                                      *
516 \subsection{Static options}
517 %*                                                                      *
518 %************************************************************************
519
520 \begin{code}
521 -- debugging opts
522 opt_PprStyle_NoPrags            = lookUp  SLIT("-dppr-noprags")
523 opt_PprStyle_Debug              = lookUp  SLIT("-dppr-debug")
524 opt_PprStyle_RawTypes           = lookUp  SLIT("-dppr-rawtypes")
525 opt_PprUserLength               = lookup_def_int "-dppr-user-length" 5 --ToDo: give this a name
526
527 -- profiling opts
528 opt_AutoSccsOnAllToplevs        = lookUp  SLIT("-fauto-sccs-on-all-toplevs")
529 opt_AutoSccsOnExportedToplevs   = lookUp  SLIT("-fauto-sccs-on-exported-toplevs")
530 opt_AutoSccsOnIndividualCafs    = lookUp  SLIT("-fauto-sccs-on-individual-cafs")
531 opt_AutoSccsOnDicts             = lookUp  SLIT("-fauto-sccs-on-dicts")
532 opt_SccProfilingOn              = lookUp  SLIT("-fscc-profiling")
533 opt_DoTickyProfiling            = lookUp  SLIT("-fticky-ticky")
534
535 -- language opts
536 opt_AllStrict                   = lookUp  SLIT("-fall-strict")
537 opt_NoMonomorphismRestriction   = lookUp  SLIT("-fno-monomorphism-restriction")
538 opt_DictsStrict                 = lookUp  SLIT("-fdicts-strict")
539 opt_IrrefutableTuples           = lookUp  SLIT("-firrefutable-tuples")
540 opt_MaxContextReductionDepth    = lookup_def_int "-fcontext-stack" mAX_CONTEXT_REDUCTION_DEPTH
541 opt_NumbersStrict               = lookUp  SLIT("-fnumbers-strict")
542 opt_Parallel                    = lookUp  SLIT("-fparallel")
543 opt_SMP                         = lookUp  SLIT("-fsmp")
544
545 -- optimisation opts
546 opt_NoMethodSharing             = lookUp  SLIT("-fno-method-sharing")
547 opt_DoSemiTagging               = lookUp  SLIT("-fsemi-tagging")
548 opt_FoldrBuildOn                = lookUp  SLIT("-ffoldr-build-on")
549 opt_LiberateCaseThreshold       = lookup_def_int "-fliberate-case-threshold" (10::Int)
550 opt_StgDoLetNoEscapes           = lookUp  SLIT("-flet-no-escape")
551 opt_UnfoldCasms                 = lookUp  SLIT("-funfold-casms-in-hi-file")
552 opt_UsageSPOn                   = lookUp  SLIT("-fusagesp-on")
553 opt_UnboxStrictFields           = lookUp  SLIT("-funbox-strict-fields")
554 opt_MaxWorkerArgs               = lookup_def_int "-fmax-worker-args" (10::Int)
555
556 {-
557    The optional '-inpackage=P' flag tells what package
558    we are compiling this module for.
559    The Prelude, for example is compiled with '-inpackage std'
560 -}
561 opt_InPackage                   = case lookup_str "-inpackage=" of
562                                     Just p  -> _PK_ p
563                                     Nothing -> SLIT("Main")     -- The package name if none is specified
564
565 opt_EmitCExternDecls            = lookUp  SLIT("-femit-extern-decls")
566 opt_EnsureSplittableC           = lookUp  SLIT("-fglobalise-toplev-names")
567 opt_GranMacros                  = lookUp  SLIT("-fgransim")
568 opt_HiVersion                   = read cProjectVersionInt :: Int
569 opt_HistorySize                 = lookup_def_int "-fhistory-size" 20
570 opt_IgnoreAsserts               = lookUp  SLIT("-fignore-asserts")
571 opt_IgnoreIfacePragmas          = lookUp  SLIT("-fignore-interface-pragmas")
572 opt_NoHiCheck                   = lookUp  SLIT("-fno-hi-version-check")
573 opt_OmitBlackHoling             = lookUp  SLIT("-dno-black-holing")
574 opt_OmitInterfacePragmas        = lookUp  SLIT("-fomit-interface-pragmas")
575 opt_RuntimeTypes                = lookUp  SLIT("-fruntime-types")
576
577 -- Simplifier switches
578 opt_SimplNoPreInlining          = lookUp  SLIT("-fno-pre-inlining")
579         -- NoPreInlining is there just to see how bad things
580         -- get if you don't do it!
581 opt_SimplDoEtaReduction         = lookUp  SLIT("-fdo-eta-reduction")
582 opt_SimplDoLambdaEtaExpansion   = lookUp  SLIT("-fdo-lambda-eta-expansion")
583 opt_SimplCaseMerge              = lookUp  SLIT("-fcase-merge")
584 opt_SimplExcessPrecision        = lookUp  SLIT("-fexcess-precision")
585
586 -- Unfolding control
587 opt_UF_CreationThreshold        = lookup_def_int "-funfolding-creation-threshold"  (45::Int)
588 opt_UF_UseThreshold             = lookup_def_int "-funfolding-use-threshold"       (8::Int)     -- Discounts can be big
589 opt_UF_FunAppDiscount           = lookup_def_int "-funfolding-fun-discount"        (6::Int)     -- It's great to inline a fn
590 opt_UF_KeenessFactor            = lookup_def_float "-funfolding-keeness-factor"    (1.5::Float)
591 opt_UF_UpdateInPlace            = lookUp  SLIT("-funfolding-update-in-place")
592
593 opt_UF_CheapOp  = ( 1 :: Int)   -- Only one instruction; and the args are charged for
594 opt_UF_DearOp   = ( 4 :: Int)
595                         
596 opt_NoPruneDecls                = lookUp  SLIT("-fno-prune-decls")
597 opt_NoPruneTyDecls              = lookUp  SLIT("-fno-prune-tydecls")
598 opt_Static                      = lookUp  SLIT("-static")
599 opt_Unregisterised              = lookUp  SLIT("-funregisterised")
600 opt_EmitExternalCore            = lookUp  SLIT("-fext-core")
601 \end{code}
602
603 %************************************************************************
604 %*                                                                      *
605 \subsection{List of static hsc flags}
606 %*                                                                      *
607 %************************************************************************
608
609 \begin{code}
610 isStaticHscFlag f =
611   f `elem` [
612         "fauto-sccs-on-all-toplevs",
613         "fauto-sccs-on-exported-toplevs",
614         "fauto-sccs-on-individual-cafs",
615         "fauto-sccs-on-dicts",
616         "fscc-profiling",
617         "fticky-ticky",
618         "fall-strict",
619         "fdicts-strict",
620         "firrefutable-tuples",
621         "fnumbers-strict",
622         "fparallel",
623         "fsmp",
624         "fsemi-tagging",
625         "ffoldr-build-on",
626         "flet-no-escape",
627         "funfold-casms-in-hi-file",
628         "fusagesp-on",
629         "funbox-strict-fields",
630         "femit-extern-decls",
631         "fglobalise-toplev-names",
632         "fgransim",
633         "fignore-asserts",
634         "fignore-interface-pragmas",
635         "fno-hi-version-check",
636         "dno-black-holing",
637         "fno-method-sharing",
638         "fno-monomorphism-restriction",
639         "fomit-interface-pragmas",
640         "fruntime-types",
641         "fno-pre-inlining",
642         "fdo-eta-reduction",
643         "fdo-lambda-eta-expansion",
644         "fcase-merge",
645         "fexcess-precision",
646         "funfolding-update-in-place",
647         "fno-prune-decls",
648         "fno-prune-tydecls",
649         "static",
650         "funregisterised",
651         "fext-core",
652         "frule-check"
653         ]
654   || any (flip prefixMatch f) [
655         "fcontext-stack",
656         "fliberate-case-threshold",
657         "fmax-worker-args",
658         "fhistory-size",
659         "funfolding-creation-threshold",
660         "funfolding-use-threshold",
661         "funfolding-fun-discount",
662         "funfolding-keeness-factor"
663      ]
664 \end{code}
665
666 %************************************************************************
667 %*                                                                      *
668 \subsection{Misc functions for command-line options}
669 %*                                                                      *
670 %************************************************************************
671
672
673
674 \begin{code}
675 startsWith :: String -> String -> Maybe String
676 -- startsWith pfx (pfx++rest) = Just rest
677
678 startsWith []     str = Just str
679 startsWith (c:cs) (s:ss)
680   = if c /= s then Nothing else startsWith cs ss
681 startsWith  _     []  = Nothing
682
683 endsWith  :: String -> String -> Maybe String
684 endsWith cs ss
685   = case (startsWith (reverse cs) (reverse ss)) of
686       Nothing -> Nothing
687       Just rs -> Just (reverse rs)
688 \end{code}