\begin{code}
module IdInfo (
- -- * The GlobalIdDetails type
- GlobalIdDetails(..), notGlobalId, -- Not abstract
+ -- * The IdDetails type
+ IdDetails(..), pprIdDetails,
-- * The IdInfo type
IdInfo, -- Abstract
TickBoxOp(..), TickBoxId,
) where
-import {-# SOURCE #-} CoreSyn ( CoreRule, setRuleIdName, seqRules, Unfolding, noUnfolding )
+import CoreSyn ( CoreRule, setRuleIdName, seqRules, Unfolding, noUnfolding )
import Class
import PrimOp
%************************************************************************
%* *
-\subsection{GlobalIdDetails}
+ IdDetails
%* *
%************************************************************************
-This type is here (rather than in Id.lhs) mainly because there's
-an IdInfo.hi-boot, but no Id.hi-boot, and GlobalIdDetails is imported
-(recursively) by Var.lhs.
-
\begin{code}
--- | Information pertaining to global 'Id's. See "Var#globalvslocal" for the distinction
--- between global and local in this context
-data GlobalIdDetails
- = VanillaGlobal -- ^ The 'Id' is imported from elsewhere or is a default method 'Id'
+-- | The 'IdDetails' of an 'Id' give stable, and necessary,
+-- information about the Id.
+data IdDetails
+ = VanillaId
-- | The 'Id' for a record selector
- | RecordSelId
+ | RecSelId
{ sel_tycon :: TyCon -- ^ For a data type family, this is the /instance/ 'TyCon'
-- not the family 'TyCon'
- , sel_label :: FieldLabel
, sel_naughty :: Bool -- True <=> a "naughty" selector which can't actually exist, for example @x@ in:
- --
- -- > data T = forall a. MkT { x :: a }
- }
- -- See Note [Naughty record selectors]
- -- with MkId.mkRecordSelectorId
+ -- data T = forall a. MkT { x :: a }
+ } -- See Note [Naughty record selectors] in TcTyClsDecls
| DataConWorkId DataCon -- ^ The 'Id' is for a data constructor /worker/
| DataConWrapId DataCon -- ^ The 'Id' is for a data constructor /wrapper/
| TickBoxOpId TickBoxOp -- ^ The 'Id' is for a HPC tick box (both traditional and binary)
- | NotGlobalId -- ^ Used as a convenient extra return value from 'globalIdDetails'
-
--- | An entirely unhelpful 'GlobalIdDetails'
-notGlobalId :: GlobalIdDetails
-notGlobalId = NotGlobalId
-
-instance Outputable GlobalIdDetails where
- ppr NotGlobalId = ptext (sLit "[***NotGlobalId***]")
- ppr VanillaGlobal = ptext (sLit "[GlobalId]")
- ppr (DataConWorkId _) = ptext (sLit "[DataCon]")
- ppr (DataConWrapId _) = ptext (sLit "[DataConWrapper]")
- ppr (ClassOpId _) = ptext (sLit "[ClassOp]")
- ppr (PrimOpId _) = ptext (sLit "[PrimOp]")
- ppr (FCallId _) = ptext (sLit "[ForeignCall]")
- ppr (TickBoxOpId _) = ptext (sLit "[TickBoxOp]")
- ppr (RecordSelId {}) = ptext (sLit "[RecSel]")
+ | DFunId -- ^ A dictionary function. We don't use this in an essential way,
+ -- currently, but it's kind of nice that we can keep track of
+ -- which Ids are DFuns, across module boundaries too
+
+
+instance Outputable IdDetails where
+ ppr = pprIdDetails
+
+pprIdDetails :: IdDetails -> SDoc
+pprIdDetails VanillaId = empty
+pprIdDetails (RecSelId {}) = ptext (sLit "[RecSel]")
+pprIdDetails (DataConWorkId _) = ptext (sLit "[DataCon]")
+pprIdDetails (DataConWrapId _) = ptext (sLit "[DataConWrapper]")
+pprIdDetails (ClassOpId _) = ptext (sLit "[ClassOp]")
+pprIdDetails (PrimOpId _) = ptext (sLit "[PrimOp]")
+pprIdDetails (FCallId _) = ptext (sLit "[ForeignCall]")
+pprIdDetails (TickBoxOpId _) = ptext (sLit "[TickBoxOp]")
+pprIdDetails DFunId = ptext (sLit "[DFunId]")
\end{code}
+
+
%************************************************************************
%* *
\subsection{The main IdInfo type}
\begin{code}
-- | If this Id has a worker then we store a reference to it. Worker
--- functions are generated by the worker/wrapper pass, using information
+-- functions are generated by the worker\/wrapper pass, using information
-- information from strictness analysis.
data WorkerInfo = NoWorker -- ^ No known worker function
| HasWorker Id Arity -- ^ The 'Arity' is the arity of the /wrapper/ at the moment of the
- -- worker/wrapper split, which may be different from the current 'Id' 'Aritiy'
+ -- worker\/wrapper split, which may be different from the current 'Id' 'Aritiy'
seqWorker :: WorkerInfo -> ()
seqWorker (HasWorker id a) = id `seq` a `seq` ()
| NoCafRefs -- ^ A function or static constructor
-- that refers to no CAFs.
+ deriving (Eq, Ord)
-- | Assumes that the 'Id' has CAF references: definitely safe
vanillaCafInfo :: CafInfo
| ReturnsCPR -- ^ Yes, this function returns a constructed product
-- Implicitly, this means "after the function has been applied
- -- to all its arguments", so the worker/wrapper builder in
+ -- to all its arguments", so the worker\/wrapper builder in
-- WwLib.mkWWcpr checks that that it is indeed saturated before
-- making use of the CPR info