[project @ 1997-06-05 21:10:48 by sof]
[ghc-hetmet.git] / ghc / compiler / coreSyn / CoreLift.lhs
index 9020e0b..bb6a323 100644 (file)
@@ -12,23 +12,24 @@ module CoreLift (
        mkLiftedId,
        liftExpr,
        bindUnlift,
-       applyBindUnlifts,
-       isUnboxedButNotState
+       applyBindUnlifts
 
     ) where
 
-import Ubiq{-uitous-}
+IMP_Ubiq(){-uitous-}
 
 import CoreSyn
 import CoreUtils       ( coreExprType )
 import Id              ( idType, mkSysLocal,
-                         nullIdEnv, growIdEnvList, lookupIdEnv, IdEnv(..),
-                         GenId{-instances-}
+                         nullIdEnv, growIdEnvList, lookupIdEnv, SYN_IE(IdEnv),
+                         GenId{-instances-}, SYN_IE(Id)
                        )
-import Outputable      ( isLocallyDefined, getSrcLoc )
-import PrelInfo                ( liftDataCon, mkLiftTy, statePrimTyCon )
+import Name            ( isLocallyDefined, getSrcLoc, getOccString )
 import TyCon           ( isBoxedTyCon, TyCon{-instance-} )
-import Type            ( maybeAppDataTyCon, eqTy )
+import Type            ( maybeAppDataTyConExpandingDicts, eqTy )
+import TysPrim         ( statePrimTyCon )
+import TysWiredIn      ( liftDataCon, mkLiftTy )
+import Unique           ( Unique )
 import UniqSupply      ( getUnique, getUniques, splitUniqSupply, UniqSupply )
 import Util            ( zipEqual, zipWithEqual, assertPanic, panic )
 
@@ -129,6 +130,10 @@ liftCoreExpr (SCC label expr)
   = liftCoreExpr expr          `thenL` \ expr ->
     returnL (SCC label expr)
 
+liftCoreExpr (Coerce coerce ty expr)
+  = liftCoreExpr expr          `thenL` \ expr ->
+    returnL (Coerce coerce ty expr) -- ToDo:right?:Coerce
+
 liftCoreExpr (Let (NonRec binder rhs) body) -- special case: no lifting
   = liftCoreExpr rhs   `thenL` \ rhs ->
     liftCoreExpr body  `thenL` \ body ->
@@ -209,8 +214,7 @@ liftDeflt (BindDefault binder rhs)
 type LiftM a
   = IdEnv (Id, Id)     -- lifted Ids are mapped to:
                        --   * lifted Id with the same Unique
-                       --     (top-level bindings must keep their
-                       --      unique (see TopLevId in Id.lhs))
+                       --     (top-level bindings must keep their unique
                        --   * unlifted version with a new Unique
     -> UniqSupply      -- unique supply
     -> a               -- result
@@ -257,7 +261,7 @@ liftBinders top_lev bind liftM idenv s0
     (s1, s2)   = splitUniqSupply s0
     lift_ids   = [ id | id <- bindersOf bind, isUnboxedButNotState (idType id) ]
     lift_uniqs = getUniques (length lift_ids) s1
-    lift_map   = zipEqual lift_ids (zipWithEqual mkLiftedId lift_ids lift_uniqs)
+    lift_map   = zipEqual "liftBinders" lift_ids (zipWithEqual "liftBinders" mkLiftedId lift_ids lift_uniqs)
 
     -- ToDo: Give warning for recursive bindings involving unboxed values ???
 
@@ -275,7 +279,7 @@ mkLiftedId id u
   = ASSERT (isUnboxedButNotState unlifted_ty)
     (lifted_id, unlifted_id)
   where
-    id_name     = panic "CoreLift.mkLiftedId:id_name" --LATER: getOccName id
+    id_name     = _PK_ (getOccString id)               -- yuk!
     lifted_id   = updateIdType id lifted_ty
     unlifted_id = mkSysLocal id_name u unlifted_ty (getSrcLoc id)
 
@@ -308,7 +312,7 @@ applyBindUnlifts []     expr = expr
 applyBindUnlifts (f:fs) expr = f (applyBindUnlifts fs expr)
 
 isUnboxedButNotState ty
-  = case (maybeAppDataTyCon ty) of
+  = case (maybeAppDataTyConExpandingDicts ty) of
       Nothing -> False
       Just (tycon, _, _) ->
        not (isBoxedTyCon tycon) && not (tycon == statePrimTyCon)