[project @ 1996-07-19 18:36:04 by partain]
[ghc-hetmet.git] / ghc / compiler / main / CmdLineOpts.lhs
index 99169c1..13abecb 100644 (file)
@@ -55,8 +55,6 @@ module CmdLineOpts (
        opt_GranMacros,
        opt_Haskell_1_3,
        opt_HiMap,
-       opt_HideBuiltinNames,
-       opt_HideMostBuiltinNames,
        opt_IgnoreIfacePragmas,
        opt_IgnoreStrictnessPragmas,
        opt_IrrefutableEverything,
@@ -98,6 +96,8 @@ import Argv
 
 CHK_Ubiq() -- debugging consistency check
 
+import CgCompInfo      -- Default values for some flags
+
 import Maybes          ( assocMaybe, firstJust, maybeToBool )
 import Util            ( startsWith, panic, panic#, assertPanic )
 \end{code}
@@ -195,6 +195,7 @@ data SimplifierSwitch
   | MaxSimplifierIterations Int
 
   | SimplUnfoldingUseThreshold      Int -- per-simplification variants
+  | SimplUnfoldingConDiscount       Int
   | SimplUnfoldingCreationThreshold Int
 
   | KeepSpecPragmaIds      -- We normally *toss* Ids we can do without
@@ -214,6 +215,8 @@ data SimplifierSwitch
                        -- Oops!
                        -- So only use this flag inside List.hs
                        -- (Sigh, what a HACK, Andy.  WDP 96/01)
+
+  | SimplCaseMerge
 \end{code}
 
 %************************************************************************
@@ -274,8 +277,6 @@ opt_ForConcurrent           = lookUp  SLIT("-fconcurrent")
 opt_GranMacros                 = lookUp  SLIT("-fgransim")
 opt_GlasgowExts                        = lookUp  SLIT("-fglasgow-exts")
 opt_Haskell_1_3                        = lookUp  SLIT("-fhaskell-1.3")
-opt_HideBuiltinNames           = lookUp  SLIT("-fhide-builtin-names")
-opt_HideMostBuiltinNames       = lookUp  SLIT("-fmin-builtin-names")
 opt_IgnoreStrictnessPragmas    = lookUp  SLIT("-fignore-strictness-pragmas")
 opt_IrrefutableEverything      = lookUp  SLIT("-firrefutable-everything")
 opt_IrrefutableTuples          = lookUp  SLIT("-firrefutable-tuples")
@@ -341,7 +342,7 @@ classifyOpts = sep argv [] [] -- accumulators...
          ',' : _       -> IGNORE_ARG() -- it is for the parser
 
          "-fsimplify"  -> -- gather up SimplifierSwitches specially...
-                          simpl_sep opts [] core_td stg_td
+                          simpl_sep opts defaultSimplSwitches core_td stg_td
 
          "-fcalc-inlinings1"-> CORE_TD(CoreDoCalcInlinings1)
          "-fcalc-inlinings2"-> CORE_TD(CoreDoCalcInlinings2)
@@ -384,8 +385,7 @@ classifyOpts = sep argv [] [] -- accumulators...
 
     simpl_sep (opt1:opts) simpl_sw core_td stg_td
       = case (_UNPK_ opt1) of
-         "(" -> ASSERT (null simpl_sw)
-                simpl_sep opts [] core_td stg_td
+         "(" -> simpl_sep opts simpl_sw core_td stg_td
          ")" -> let
                    this_simpl = CoreDoSimplify (isAmongSimpl simpl_sw)
                 in
@@ -408,6 +408,7 @@ classifyOpts = sep argv [] [] -- accumulators...
          "-fdo-inline-foldr-build"         -> SIMPL_SW(SimplDoInlineFoldrBuild)
          "-freuse-con"                     -> SIMPL_SW(SimplReuseCon)
          "-fcase-of-case"                  -> SIMPL_SW(SimplCaseOfCase)
+         "-fcase-merge"                    -> SIMPL_SW(SimplCaseMerge)
          "-flet-to-case"                   -> SIMPL_SW(SimplLetToCase)
          "-fpedantic-bottoms"              -> SIMPL_SW(SimplPedanticBottoms)
          "-fkeep-spec-pragma-ids"          -> SIMPL_SW(KeepSpecPragmaIds)
@@ -422,15 +423,19 @@ classifyOpts = sep argv [] [] -- accumulators...
          o | starts_with_msi  -> SIMPL_SW(MaxSimplifierIterations (read after_msi))
            | starts_with_suut -> SIMPL_SW(SimplUnfoldingUseThreshold (read after_suut))
            | starts_with_suct -> SIMPL_SW(SimplUnfoldingCreationThreshold (read after_suct))
+           | starts_with_sucd -> SIMPL_SW(SimplUnfoldingConDiscount (read after_sucd))
           where
            maybe_suut          = startsWith "-fsimpl-uf-use-threshold"      o
            maybe_suct          = startsWith "-fsimpl-uf-creation-threshold" o
+           maybe_sucd          = startsWith "-fsimpl-uf-con-discount" o
            maybe_msi           = startsWith "-fmax-simplifier-iterations"   o
            starts_with_suut    = maybeToBool maybe_suut
            starts_with_suct    = maybeToBool maybe_suct
+           starts_with_sucd    = maybeToBool maybe_sucd
            starts_with_msi     = maybeToBool maybe_msi
            (Just after_suut)   = maybe_suut
            (Just after_suct)   = maybe_suct
+           (Just after_sucd)   = maybe_sucd
            (Just after_msi)    = maybe_msi
 
          _ -> -- NB: the driver is really supposed to handle bad options
@@ -474,18 +479,20 @@ tagOf_SimplSwitch EssentialUnfoldingsOnly = ILIT(19)
 tagOf_SimplSwitch ShowSimplifierProgress       = ILIT(20)
 tagOf_SimplSwitch (MaxSimplifierIterations _)  = ILIT(21)
 tagOf_SimplSwitch (SimplUnfoldingUseThreshold _)      = ILIT(22)
-tagOf_SimplSwitch (SimplUnfoldingCreationThreshold _) = ILIT(23)
-tagOf_SimplSwitch KeepSpecPragmaIds            = ILIT(24)
-tagOf_SimplSwitch KeepUnusedBindings           = ILIT(25)
-tagOf_SimplSwitch SimplNoLetFromCase           = ILIT(26)
-tagOf_SimplSwitch SimplNoLetFromApp            = ILIT(27)
-tagOf_SimplSwitch SimplNoLetFromStrictLet      = ILIT(28)
-tagOf_SimplSwitch SimplDontFoldBackAppend       = ILIT(29)
+tagOf_SimplSwitch (SimplUnfoldingConDiscount _)       = ILIT(23)
+tagOf_SimplSwitch (SimplUnfoldingCreationThreshold _) = ILIT(24)
+tagOf_SimplSwitch KeepSpecPragmaIds            = ILIT(25)
+tagOf_SimplSwitch KeepUnusedBindings           = ILIT(26)
+tagOf_SimplSwitch SimplNoLetFromCase           = ILIT(27)
+tagOf_SimplSwitch SimplNoLetFromApp            = ILIT(28)
+tagOf_SimplSwitch SimplNoLetFromStrictLet      = ILIT(29)
+tagOf_SimplSwitch SimplDontFoldBackAppend       = ILIT(30)
+tagOf_SimplSwitch SimplCaseMerge               = ILIT(31)
 -- If you add anything here, be sure to change lAST_SIMPL_SWITCH_TAG, too!
 
 tagOf_SimplSwitch _ = panic# "tagOf_SimplSwitch"
 
-lAST_SIMPL_SWITCH_TAG = IBOX(tagOf_SimplSwitch SimplDontFoldBackAppend)
+lAST_SIMPL_SWITCH_TAG = IBOX(tagOf_SimplSwitch SimplCaseMerge)
 \end{code}
 
 %************************************************************************
@@ -508,9 +515,12 @@ lAST_SIMPL_SWITCH_TAG = IBOX(tagOf_SimplSwitch SimplDontFoldBackAppend)
 
 isAmongSimpl :: [SimplifierSwitch] -> SimplifierSwitch -> SwitchResult
 
-isAmongSimpl on_switches
+isAmongSimpl on_switches               -- Switches mentioned later occur *earlier*
+                                       -- in the list; defaults right at the end.
   = let
        tidied_on_switches = foldl rm_dups [] on_switches
+               -- The fold*l* ensures that we keep the latest switches;
+               -- ie the ones that occur earliest in the list.
 
        sw_tbl :: Array Int SwitchResult
 
@@ -531,12 +541,12 @@ isAmongSimpl on_switches
   where
     mk_assoc_elem k@(MaxSimplifierIterations lvl)       = IBOX(tagOf_SimplSwitch k) SET_TO SwInt lvl
     mk_assoc_elem k@(SimplUnfoldingUseThreshold      i) = IBOX(tagOf_SimplSwitch k) SET_TO SwInt i
+    mk_assoc_elem k@(SimplUnfoldingConDiscount       i) = IBOX(tagOf_SimplSwitch k) SET_TO SwInt i
     mk_assoc_elem k@(SimplUnfoldingCreationThreshold i) = IBOX(tagOf_SimplSwitch k) SET_TO SwInt i
 
     mk_assoc_elem k = IBOX(tagOf_SimplSwitch k) SET_TO SwBool   True -- I'm here, Mom!
 
     -- cannot have duplicates if we are going to use the array thing
-
     rm_dups switches_so_far switch
       = if switch `is_elem` switches_so_far
        then switches_so_far
@@ -547,6 +557,16 @@ isAmongSimpl on_switches
                            || sw `is_elem` ss
 \end{code}
 
+Default settings for simplifier switches
+
+\begin{code}
+defaultSimplSwitches = [SimplUnfoldingCreationThreshold uNFOLDING_CREATION_THRESHOLD,
+                       SimplUnfoldingUseThreshold      uNFOLDING_USE_THRESHOLD,
+                       SimplUnfoldingConDiscount       uNFOLDING_CON_DISCOUNT_WEIGHT,
+                       MaxSimplifierIterations         1
+                      ]
+\end{code}
+
 %************************************************************************
 %*                                                                     *
 \subsection{Misc functions for command-line options}