%
-% (c) The AQUA Project, Glasgow University, 1994
+% (c) The AQUA Project, Glasgow University, 1994-1996
%
\section[LiberateCase]{Unroll recursion to allow evals to be lifted from a loop}
+96/03: We aren't using this at the moment
\begin{code}
+module LiberateCase ( liberateCase ) where
+
#include "HsVersions.h"
-module LiberateCase ( liberateCase ) where
+import Util ( panic )
+
+liberateCase = panic "LiberateCase.liberateCase: ToDo"
-import CoreUnfold ( UnfoldingGuidance(..) )
-import Id ( localiseId, toplevelishId{-debugging-} )
+{- LATER: to end of file:
+import CoreUnfold ( UnfoldingGuidance(..), PragmaInfo(..) )
+import Id ( localiseId )
import Maybes
import Outputable
-import Pretty
import Util
\end{code}
-- Why "localiseId" above? Because we're creating a new local
-- copy of the original binding. In particular, the original
- -- binding might have been for a TopLevId, and this copy clearly
+ -- binding might have been for a top-level, and this copy clearly
-- will not be top-level!
-- It is enough to change just the binder, because subsequent
-- to think that something is top-level when it isn't.
rhs_small_enough rhs
- = case (calcUnfoldingGuidance True{-sccs OK-} lIBERATE_BOMB_SIZE rhs) of
+ = case (calcUnfoldingGuidance NoPragmaInfo lIBERATE_BOMB_SIZE rhs) of
UnfoldNever -> False
_ -> True -- we didn't BOMB, so it must be OK
-> CoreExpr
-> CoreExpr
-libCase env (Lit lit) = Lit lit
-libCase env (Var v) = mkCoLetsNoUnboxed (libCaseId env v) (Var v)
-libCase env (App fun arg) = mkCoLetsNoUnboxed (libCaseAtom env arg) (App (libCase env fun) arg)
-libCase env (CoTyApp fun ty) = CoTyApp (libCase env fun) ty
-libCase env (Con con tys args) = mkCoLetsNoUnboxed (libCaseAtoms env args) (Con con tys args)
-libCase env (Prim op tys args) = mkCoLetsNoUnboxed (libCaseAtoms env args) (Prim op tys args)
-libCase env (CoTyLam tyvar body) = CoTyLam tyvar (libCase env body)
-libCase env (SCC cc body) = SCC cc (libCase env body)
+libCase env (Lit lit) = Lit lit
+libCase env (Var v) = mkCoLetsNoUnboxed (libCaseId env v) (Var v)
+libCase env (App fun arg) = mkCoLetsNoUnboxed (libCaseAtom env arg) (App (libCase env fun) arg)
+libCase env (CoTyApp fun ty) = CoTyApp (libCase env fun) ty
+libCase env (Con con tys args) = mkCoLetsNoUnboxed (libCaseAtoms env args) (Con con tys args)
+libCase env (Prim op tys args) = mkCoLetsNoUnboxed (libCaseAtoms env args) (Prim op tys args)
+libCase env (CoTyLam tv body) = CoTyLam tv (libCase env body)
+libCase env (SCC cc body) = SCC cc (libCase env body)
+libCase env (Coerce c ty body) = Coerce c ty (libCase env body)
libCase env (Lam binder body)
= Lam binder (libCase (addBinders env [binder]) body)
scruts' = (scrut_var, lvl) : scruts
bind_lvl = case lookupIdEnv lvl_env scrut_var of
Just lvl -> lvl
- Nothing -> --false: ASSERT(toplevelishId scrut_var)
- topLevel
+ Nothing -> topLevel
lookupRecId :: LibCaseEnv -> Id -> Maybe CoreBinding
lookupRecId (LibCaseEnv bomb lvl lvl_env rec_env scruts) id
#else
= case (lookupIdEnv rec_env id) of
xxx@(Just _) -> xxx
- xxx -> --false: ASSERT(toplevelishId id)
- xxx
+ xxx -> xxx
#endif
lookupLevel :: LibCaseEnv -> Id -> LibCaseLevel
lookupLevel (LibCaseEnv bomb lvl lvl_env rec_env scruts) id
= case lookupIdEnv lvl_env id of
Just lvl -> lvl
- Nothing -> ASSERT(toplevelishId id)
- topLevel
+ Nothing -> topLevel
freeScruts :: LibCaseEnv
-> LibCaseLevel -- Level of the recursive Id
= not (null free_scruts)
where
free_scruts = [v | (v,lvl) <- scruts, lvl > rec_bind_lvl]
+-}
\end{code}