-data LibCaseEnv
- = LibCaseEnv {
- lc_size :: Int, -- Bomb-out size for deciding if
- -- potential liberatees are too big.
- -- (passed in from cmd-line args)
-
- lc_lvl :: LibCaseLevel, -- Current level
-
- lc_lvl_env :: IdEnv LibCaseLevel,
- -- Binds all non-top-level in-scope Ids
- -- (top-level and imported things have
- -- a level of zero)
-
- lc_rec_env :: IdEnv CoreBind,
- -- Binds *only* recursively defined ids,
- -- to their own binding group,
- -- and *only* in their own RHSs
-
- lc_scruts :: [(Id,LibCaseLevel)]
- -- Each of these Ids was scrutinised by an
- -- enclosing case expression, with the
- -- specified number of enclosing
- -- recursive bindings; furthermore,
- -- the Id is bound at a lower level
- -- than the case expression. The order is
- -- insignificant; it's a bag really
-
--- lc_fams :: FamInstEnvs
- -- Instance env for indexed data types
- }
-
-initEnv :: Int -> LibCaseEnv
-initEnv bomb_size
- = LibCaseEnv { lc_size = bomb_size, lc_lvl = 0,
- lc_lvl_env = emptyVarEnv, lc_rec_env = emptyVarEnv,
- lc_scruts = [] }
-
-bombOutSize = lc_size
-\end{code}
-
-
-Programs
-~~~~~~~~
-\begin{code}
-liberateCase :: DynFlags -> [CoreBind] -> IO [CoreBind]
-liberateCase dflags binds
- = do {
- showPass dflags "Liberate case" ;
- let { binds' = do_prog (initEnv opt_LiberateCaseThreshold) binds } ;
- endPass dflags "Liberate case" Opt_D_verbose_core2core binds'
- {- no specific flag for dumping -}
- }
+liberateCase :: HscEnv -> UniqSupply -> RuleBase -> ModGuts
+ -> IO (SimplCount, ModGuts)
+liberateCase hsc_env _ _ guts
+ = do { let dflags = hsc_dflags hsc_env
+
+ ; showPass dflags "Liberate case"
+ ; let { env = initEnv dflags
+ ; binds' = do_prog env (mg_binds guts) }
+ ; endPass dflags "Liberate case" Opt_D_verbose_core2core binds'
+ {- no specific flag for dumping -}
+ ; return (zeroSimplCount dflags, guts { mg_binds = binds' }) }