-{- Mattson review:
-
-To: simonpj@dcs.gla.ac.uk, partain@dcs.gla.ac.uk
-Cc: kh@dcs.gla.ac.uk, trinder@dcs.gla.ac.uk, areid@dcs.gla.ac.uk
-Subject: Correct me if I'm wrong...
-Date: Fri, 17 Feb 1995 18:09:00 +0000
-From: Jim Mattson <mattson@dcs.gla.ac.uk>
-
-BigTupleRep == TUPLE
-
- 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
- system, since we need to distinguish mutables from immutables when
- deciding whether to copy or move closures across processors.
-
-DataRep == DATA (aka MutableByteArray & ByteArray)
- Never generated by the compiler, and only used in the RTS for
- ArrayOfData. Always a primitive object (never entered). May
- be mutable...though we don't distinguish between mutable and
- immutable data arrays in the sequential world, it would probably
- be useful in the parallel world to know when it is safe to just
- copy one of these. I believe the hooks are in place for changing
- the InfoPtr on a MutableByteArray when it's frozen to a ByteArray
- if we want to do so.
-
-DynamicRep == DYN
- Never generated by the compiler, and only used in the RTS for
- PAPs and the Stable Pointer table. PAPs are non-primitive,
- non-updatable, normal-form objects, but the SPT is a primitive,
- mutable object. At the moment, there is no SPT in the parallel
- world. Presumably, it would be possible to have an SPT on each
- processor, and we could identify a stable pointer as a (processor,
- SPT-entry) pair, but would it be worth it?
-
-MuTupleRep == MUTUPLE
- Never generated by the compiler, and only used in the RTS when
- mutuples *do* require special attention at GC time.
- When it is used, it is a primitive object (never entered).
- Always mutable...there is an IMMUTUPLE in the RTS, but no
- corresponding type in the compiler.
-
---jim
--}
-
-instance Eq SMRep where
- (SpecialisedRep k1 a1 b1 _) == (SpecialisedRep k2 a2 b2 _) = (tagOf_SMSpecRepKind k1) _EQ_ (tagOf_SMSpecRepKind k2)
- && a1 == a2 && b1 == b2
- (GenericRep a1 b1 _) == (GenericRep a2 b2 _) = a1 == a2 && b1 == b2
- (BigTupleRep a1) == (BigTupleRep a2) = a1 == a2
- (MuTupleRep a1) == (MuTupleRep a2) = a1 == a2
- (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)
-
-instance Ord SMRep where
- -- ToDo: cmp-ify? This instance seems a bit weird (WDP 94/10)
- rep1 <= rep2 = rep1 < rep2 || rep1 == rep2
- rep1 < rep2
- = let tag1 = tagOf_SMRep rep1
- tag2 = tagOf_SMRep rep2
- in
- if tag1 _LT_ tag2 then True
- else if tag1 _GT_ tag2 then False
- else {- tags equal -} rep1 `lt` rep2
- where
- (SpecialisedRep k1 a1 b1 _) `lt` (SpecialisedRep k2 a2 b2 _) =
- t1 _LT_ t2 || (t1 _EQ_ t2 && (a1 < a2 || (a1 == a2 && b1 < b2)))
- where t1 = tagOf_SMSpecRepKind k1
- t2 = tagOf_SMSpecRepKind k2
- (GenericRep a1 b1 _) `lt` (GenericRep a2 b2 _) = a1 < a2 || (a1 == a2 && b1 < b2)
- (BigTupleRep a1) `lt` (BigTupleRep a2) = a1 < a2
- (MuTupleRep a1) `lt` (MuTupleRep a2) = a1 < a2
- (DataRep a1) `lt` (DataRep a2) = a1 < a2
- a `lt` b = True
-
-tagOf_SMSpecRepKind SpecRep = (ILIT(1) :: FAST_INT)
-tagOf_SMSpecRepKind ConstantRep = ILIT(2)
-tagOf_SMSpecRepKind CharLikeRep = ILIT(3)
-tagOf_SMSpecRepKind IntLikeRep = ILIT(4)
-
-tagOf_SMRep (StaticRep _ _) = (ILIT(1) :: FAST_INT)
-tagOf_SMRep (SpecialisedRep k _ _ _) = ILIT(2)
-tagOf_SMRep (GenericRep _ _ _) = ILIT(3)
-tagOf_SMRep (BigTupleRep _) = ILIT(4)
-tagOf_SMRep (DataRep _) = ILIT(5)
-tagOf_SMRep DynamicRep = ILIT(6)
-tagOf_SMRep BlackHoleRep = ILIT(7)
-tagOf_SMRep PhantomRep = ILIT(8)
-tagOf_SMRep (MuTupleRep _) = ILIT(9)