%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: CgCase.lhs,v 1.33 1999/06/24 13:04:16 simonmar Exp $
+% $Id: CgCase.lhs,v 1.34 1999/06/28 16:29:45 simonpj Exp $
%
%********************************************************
%* *
isNewTyCon, isAlgTyCon, isFunTyCon, isPrimTyCon,
tyConDataCons, tyConFamilySize )
import Type ( Type, typePrimRep, splitAlgTyConApp,
- splitTyConApp_maybe, splitRepTyConApp_maybe )
+ splitTyConApp_maybe, repType )
import Unique ( Unique, Uniquable(..), mkBuiltinUnique )
import Maybes ( maybeToBool )
import Util
\begin{code}
getScrutineeTyCon :: Type -> Maybe TyCon
getScrutineeTyCon ty =
- case splitRepTyConApp_maybe ty of
+ case splitTyConApp_maybe (repType ty) of
Nothing -> Nothing
Just (tc,_) ->
if isFunTyCon tc then Nothing else -- not interested in funs
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: CgExpr.lhs,v 1.28 1999/06/24 13:04:18 simonmar Exp $
+% $Id: CgExpr.lhs,v 1.29 1999/06/28 16:29:45 simonpj Exp $
%
%********************************************************
%* *
import PrimRep ( getPrimRepSize, PrimRep(..), isFollowableRep )
import TyCon ( maybeTyConSingleCon,
isUnboxedTupleTyCon, isEnumerationTyCon )
-import Type ( Type, typePrimRep, splitTyConApp_maybe, splitRepTyConApp_maybe )
+import Type ( Type, typePrimRep, splitTyConApp_maybe, repType )
import Maybes ( assocMaybe, maybeToBool )
import Unique ( mkBuiltinUnique )
import BasicTypes ( TopLevelFlag(..), RecFlag(..) )
allocate some temporaries for the return values.
-}
let
- (tc,ty_args) = case splitRepTyConApp_maybe res_ty of
+ (tc,ty_args) = case splitTyConApp_maybe (repType res_ty) of
Nothing -> pprPanic "primRetUnboxedTuple" (ppr res_ty)
Just pr -> pr
prim_reps = map typePrimRep ty_args
import VarEnv
import PrimOp ( PrimOp(..), primOpUsg, primOpSig )
import Type ( isUnLiftedType, isUnboxedTupleType, Type, splitFunTy_maybe,
- UsageAnn(..), tyUsg, applyTy, mkUsgTy )
+ UsageAnn(..), tyUsg, applyTy, mkUsgTy, repType )
import TysPrim ( intPrimTy )
import UniqSupply -- all of it, really
import Util ( lengthExceeds )
mk_stg_let bndr rhs dem floats body
#endif
- | isUnLiftedType bndr_ty -- Use a case/PrimAlts
- = ASSERT( not (isUnboxedTupleType bndr_ty) )
+ | isUnLiftedType bndr_rep_ty -- Use a case/PrimAlts
+ = ASSERT( not (isUnboxedTupleType bndr_rep_ty) )
mkStgBinds floats $
- mkStgCase rhs bndr (StgPrimAlts bndr_ty [] (StgBindDefault body))
+ mkStgCase rhs bndr (StgPrimAlts bndr_rep_ty [] (StgBindDefault body))
| is_whnf
= if is_strict then
= if is_strict then
-- Strict let with non-WHNF rhs
mkStgBinds floats $
- mkStgCase rhs bndr (StgAlgAlts bndr_ty [] (StgBindDefault body))
+ mkStgCase rhs bndr (StgAlgAlts bndr_rep_ty [] (StgBindDefault body))
else
-- Lazy let with non-WHNF rhs, so keep the floats in the RHS
mkStgBinds floats rhs `thenUs` \ new_rhs ->
returnUs (StgLet (StgNonRec bndr (exprToRhs dem NotTopLevel new_rhs)) body)
where
- bndr_ty = idType bndr
- is_strict = isStrictDem dem
- is_whnf = case rhs of
- StgCon _ _ _ -> True
- StgLam _ _ _ -> True
- other -> False
+ bndr_rep_ty = repType (idType bndr)
+ is_strict = isStrictDem dem
+ is_whnf = case rhs of
+ StgCon _ _ _ -> True
+ StgLam _ _ _ -> True
+ other -> False
-- Split at the first strict binding
splitFloats fs@(NonRecF _ _ dem _ : _)
zipFunTys,
mkTyConApp, mkTyConTy, splitTyConApp_maybe,
- splitAlgTyConApp_maybe, splitAlgTyConApp, splitRepTyConApp_maybe,
+ splitAlgTyConApp_maybe, splitAlgTyConApp,
mkDictTy, splitDictTy_maybe, isDictTy,
- mkSynTy, isSynTy, deNoteType,
+ mkSynTy, isSynTy, deNoteType, repType,
mkUsgTy, isUsgTy{- dont use -}, isNotUsgTy, splitUsgTy, unUsgTy, tyUsg,
isDictTy other = False
\end{code}
-splitRepTyConApp_maybe is like splitTyConApp_maybe except
-that it looks through
- (a) for-alls, and
- (b) newtypes
-in addition to synonyms. It's useful in the back end where we're not
-interested in newtypes anymore.
-
-\begin{code}
-splitRepTyConApp_maybe :: Type -> Maybe (TyCon, [Type])
-splitRepTyConApp_maybe (FunTy arg res) = Just (funTyCon, [arg,res])
-splitRepTyConApp_maybe (NoteTy _ ty) = splitRepTyConApp_maybe ty
-splitRepTyConApp_maybe (ForAllTy _ ty) = splitRepTyConApp_maybe ty
-splitRepTyConApp_maybe (TyConApp tc tys)
- | isNewTyCon tc
- = case splitFunTy_maybe (applyTys (dataConType (head (tyConDataCons tc))) tys) of
- Just (rep_ty, _) -> splitRepTyConApp_maybe rep_ty
- | otherwise
- = Just (tc,tys)
-splitRepTyConApp_maybe other = Nothing
-\end{code}
-
---------------------------------------------------------------------
SynTy
~~~~~
+repType looks through
+ (a) for-alls, and
+ (b) newtypes
+in addition to synonyms. It's useful in the back end where we're not
+interested in newtypes anymore.
+
+\begin{code}
+repType :: Type -> Type
+repType (NoteTy _ ty) = repType ty
+repType (ForAllTy _ ty) = repType ty
+repType (TyConApp tc tys) | isNewTyCon tc
+ = case splitFunTy_maybe (applyTys (dataConType (head (tyConDataCons tc))) tys) of
+ Just (rep_ty, _) -> repType rep_ty
+repType other_ty = other_ty
+\end{code}
+
+
---------------------------------------------------------------------
UsgNote