%
-% (c) The GRASP/AQUA Project, Glasgow University, 1992-1995
+% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
%
\section[SMRep]{Storage manager representations of closure}
module SMRep (
SMRep(..), SMSpecRepKind(..), SMUpdateKind(..),
getSMInfoStr, getSMInitHdrStr, getSMUpdInplaceHdrStr,
- ltSMRepHdr -- UNUSED, equivSMRepHdr
+ ltSMRepHdr,
+ isConstantRep, isSpecRep, isStaticRep, isPhantomRep,
+ isIntLikeRep
) where
-import Outputable
-import Pretty
-import Util
+IMP_Ubiq(){-uitous-}
+
+import Pretty ( ppStr )
+import Util ( panic )
\end{code}
%************************************************************************
SMSpecRepKind -- Which kind of specialised representation
Int -- # ptr words
Int -- # non-ptr words
- SMUpdateKind -- Updatable?
+ SMUpdateKind -- Updatable?
| GenericRep -- GC routines consult sizes in info tbl
Int -- # ptr words
Int -- # non-ptr words
- SMUpdateKind -- Updatable?
+ SMUpdateKind -- Updatable?
| BigTupleRep -- All ptrs, size in var-hdr field
-- Used for big tuples
Never generated by the compiler, and only used in the RTS when
mutuples don't require special attention at GC time (e.g. 2s)
When it is used, it is a primitive object (never entered).
- May be mutable...probably should never be used in the parallel
+ May be mutable...probably should never be used in the parallel
system, since we need to distinguish mutables from immutables when
deciding whether to copy or move closures across processors.
--jim
-}
+\end{code}
+
+\begin{code}
+isConstantRep, isSpecRep, isStaticRep, isPhantomRep, isIntLikeRep :: SMRep -> Bool
+isConstantRep (SpecialisedRep ConstantRep _ _ _) = True
+isConstantRep other = False
+
+isSpecRep (SpecialisedRep kind _ _ _) = True -- All the kinds of Spec closures
+isSpecRep other = False -- True indicates that the _VHS is 0 !
+
+isStaticRep (StaticRep _ _) = True
+isStaticRep _ = False
+isPhantomRep PhantomRep = True
+isPhantomRep _ = False
+
+isIntLikeRep (SpecialisedRep IntLikeRep _ _ _) = True
+isIntLikeRep other = False
+\end{code}
+
+\begin{code}
instance Eq SMRep where
(SpecialisedRep k1 a1 b1 _) == (SpecialisedRep k2 a2 b2 _) = (tagOf_SMSpecRepKind k1) _EQ_ (tagOf_SMSpecRepKind k2)
&& a1 == a2 && b1 == b2
(DataRep a1) == (DataRep a2) = a1 == a2
a == b = (tagOf_SMRep a) _EQ_ (tagOf_SMRep b)
-{- UNUSED:
-equivSMRepHdr :: SMRep -> SMRep -> Bool
-a `equivSMRepHdr` b = (tagOf_SMRep a) _EQ_ (tagOf_SMRep b)
--}
-
ltSMRepHdr :: SMRep -> SMRep -> Bool
a `ltSMRepHdr` b = (tagOf_SMRep a) _LT_ (tagOf_SMRep b)