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