[project @ 1999-06-23 10:33:03 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / CmdLineOpts.lhs
index 14f0cf6..8652480 100644 (file)
@@ -14,17 +14,20 @@ module CmdLineOpts (
        intSwitchSet,
        switchIsOn,
 
+       src_filename,
+
        -- debugging opts
        opt_D_dump_absC,
        opt_D_dump_asm,
        opt_D_dump_cpranal,
+       opt_D_dump_cse,
        opt_D_dump_deriv,
        opt_D_dump_ds,
        opt_D_dump_flatC,
        opt_D_dump_foreign,
        opt_D_dump_inlinings,
        opt_D_dump_occur_anal,
-       opt_D_dump_rdr,
+       opt_D_dump_parsed,
        opt_D_dump_realC,
        opt_D_dump_rn,
        opt_D_dump_rules,
@@ -155,6 +158,7 @@ import GlaExts
 import Argv
 import Constants       -- Default values for some flags
 
+import FastString      ( headFS )
 import Maybes          ( assocMaybe, firstJust, maybeToBool )
 import Panic           ( panic, panic# )
 
@@ -212,6 +216,7 @@ data CoreToDo               -- These are diff core-to-core passes,
   | CoreDoSpecialising
   | CoreDoUSPInf
   | CoreDoCPResult 
+  | CoreCSE
 \end{code}
 
 \begin{code}
@@ -283,6 +288,13 @@ unpacked_opts =
 \end{code}
 
 \begin{code}
+src_filename :: FAST_STRING
+src_filename = case argv of
+                 filename : rest | headFS filename /= '-' -> filename
+                 otherwise -> panic "no filename"
+\end{code}
+
+\begin{code}
 -- debugging opts
 opt_D_dump_absC                        = lookUp  SLIT("-ddump-absC")
 opt_D_dump_asm                 = lookUp  SLIT("-ddump-asm")
@@ -293,7 +305,7 @@ opt_D_dump_flatC            = lookUp  SLIT("-ddump-flatC")
 opt_D_dump_foreign             = lookUp  SLIT("-ddump-foreign-stubs")
 opt_D_dump_inlinings           = lookUp  SLIT("-ddump-inlinings")
 opt_D_dump_occur_anal          = lookUp  SLIT("-ddump-occur-anal")
-opt_D_dump_rdr                 = lookUp  SLIT("-ddump-rdr")
+opt_D_dump_parsed              = lookUp  SLIT("-ddump-parsed")
 opt_D_dump_realC               = lookUp  SLIT("-ddump-realC")
 opt_D_dump_rn                  = lookUp  SLIT("-ddump-rn")
 opt_D_dump_simpl               = lookUp  SLIT("-ddump-simpl")
@@ -304,6 +316,7 @@ opt_D_dump_stranal          = lookUp  SLIT("-ddump-stranal")
 opt_D_dump_tc                  = lookUp  SLIT("-ddump-tc")
 opt_D_dump_rules               = lookUp  SLIT("-ddump-rules")
 opt_D_dump_usagesp              = lookUp  SLIT("-ddump-usagesp")
+opt_D_dump_cse                         = lookUp  SLIT("-ddump-cse")
 opt_D_dump_worker_wrapper      = lookUp  SLIT("-ddump-workwrap")
 opt_D_show_passes              = lookUp  SLIT("-dshow-passes")
 opt_D_dump_rn_trace            = lookUp  SLIT("-ddump-rn-trace")
@@ -410,8 +423,8 @@ opt_UF_FunAppDiscount               = lookup_def_int "-funfolding-fun-discount"        (6::Int)     -
 opt_UF_PrimArgDiscount         = lookup_def_int "-funfolding-prim-discount"       (1::Int)
 opt_UF_KeenessFactor           = lookup_def_float "-funfolding-keeness-factor"    (2.0::Float)
 
-opt_UF_CheapOp  = ( 1 :: Int)
-opt_UF_DearOp   = ( 8 :: Int)
+opt_UF_CheapOp  = ( 0 :: Int)  -- Only one instruction; and the args are charged for
+opt_UF_DearOp   = ( 4 :: Int)
 opt_UF_NoRepLit = ( 20 :: Int) -- Strings can be pretty big
                        
 opt_ProduceS                   = lookup_str "-S="
@@ -458,6 +471,7 @@ classifyOpts = sep argv [] [] -- accumulators...
          "-ffloat-inwards"  -> CORE_TD(CoreDoFloatInwards)
          "-ffull-laziness"  -> CORE_TD(CoreDoFullLaziness)
          "-fliberate-case"  -> CORE_TD(CoreLiberateCase)
+         "-fcse"            -> CORE_TD(CoreCSE)
          "-fprint-core"     -> CORE_TD(CoreDoPrintCore)
          "-fstatic-args"    -> CORE_TD(CoreDoStaticArgs)
          "-fstrictness"     -> CORE_TD(CoreDoStrictness)
@@ -576,8 +590,10 @@ isAmongSimpl on_switches           -- Switches mentioned later occur *earlier*
        case (indexArray# stuff (tagOf_SimplSwitch switch)) of
 #if __GLASGOW_HASKELL__ < 400
          Lift v -> v
-#else
+#elif __GLASGOW_HASKELL__ < 403
          (# _, v #) -> v
+#else
+         (# v #) -> v
 #endif
     }
   where