X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FbasicTypes%2FIdInfo.lhs;h=6b43c687800c482abc0ed24b5f2327792ea00405;hp=d53bf5627d99638a48f0f07e57eb846b4e0dc65a;hb=6a05ec5ef5373f61b7f9f5bdc344483417fa801b;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1 diff --git a/compiler/basicTypes/IdInfo.lhs b/compiler/basicTypes/IdInfo.lhs index d53bf56..6b43c68 100644 --- a/compiler/basicTypes/IdInfo.lhs +++ b/compiler/basicTypes/IdInfo.lhs @@ -1,4 +1,5 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1993-1998 % \section[IdInfo]{@IdInfos@: Non-essential information about @Ids@} @@ -7,6 +8,13 @@ Haskell. [WDP 94/11]) \begin{code} +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module IdInfo ( GlobalIdDetails(..), notGlobalId, -- Not abstract @@ -15,7 +23,7 @@ module IdInfo ( seqIdInfo, megaSeqIdInfo, -- Zapping - zapLamInfo, zapDemandInfo, + zapLamInfo, zapDemandInfo, zapFragileInfo, -- Arity ArityInfo, @@ -70,36 +78,35 @@ module IdInfo ( CafInfo(..), cafInfo, ppCafInfo, setCafInfo, mayHaveCafRefs, -- Lambda-bound variable info - LBVarInfo(..), lbvarInfo, setLBVarInfo, noLBVarInfo, hasNoLBVarInfo + LBVarInfo(..), lbvarInfo, setLBVarInfo, noLBVarInfo, hasNoLBVarInfo, + + -- Tick-box info + TickBoxOp(..), TickBoxId, ) where #include "HsVersions.h" - import CoreSyn -import Class ( Class ) -import PrimOp ( PrimOp ) -import Var ( Id ) -import VarSet ( VarSet, emptyVarSet, seqVarSet ) -import BasicTypes ( OccInfo(..), isFragileOcc, isDeadOcc, seqOccInfo, isLoopBreaker, - InsideLam, insideLam, notInsideLam, - OneBranch, oneBranch, notOneBranch, - Arity, - Activation(..) - ) -import DataCon ( DataCon ) -import TyCon ( TyCon, FieldLabel ) -import ForeignCall ( ForeignCall ) +import Class +import PrimOp +import Var +import VarSet +import BasicTypes +import DataCon +import TyCon +import ForeignCall import NewDemand import Outputable -import Maybe ( isJust ) +import Module + +import Data.Maybe #ifdef OLD_STRICTNESS -import Name ( Name ) -import Demand hiding( Demand, seqDemand ) +import Name +import Demand import qualified Demand -import Util ( listLengthCmp ) -import List ( replicate ) +import Util +import Data.List #endif -- infixl so you can say (id `set` a `set` b) @@ -219,7 +226,7 @@ seqNewDemandInfo (Just dmd) = seqDemand dmd %************************************************************************ %* * -\subsection{GlobalIdDetails +\subsection{GlobalIdDetails} %* * %************************************************************************ @@ -232,7 +239,8 @@ data GlobalIdDetails = VanillaGlobal -- Imported from elsewhere, a default method Id. | RecordSelId -- The Id for a record selector - { sel_tycon :: TyCon + { sel_tycon :: TyCon -- For a data type family, this is the *instance* TyCon + -- not the family TyCon , sel_label :: FieldLabel , sel_naughty :: Bool -- True <=> naughty } -- See Note [Naughty record selectors] @@ -250,6 +258,8 @@ data GlobalIdDetails | PrimOpId PrimOp -- The Id for a primitive operator | FCallId ForeignCall -- The Id for a foreign call + | TickBoxOpId TickBoxOp -- The Id for a tick box (both traditional and binary) + | NotGlobalId -- Used as a convenient extra return value from globalIdDetails notGlobalId = NotGlobalId @@ -262,6 +272,7 @@ instance Outputable GlobalIdDetails where 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]") \end{code} @@ -460,9 +471,11 @@ type InlinePragInfo = Activation %************************************************************************ \begin{code} --- CoreRules is used only in an idSpecialisation (move to IdInfo?) data SpecInfo - = SpecInfo [CoreRule] VarSet -- Locally-defined free vars of RHSs + = SpecInfo + [CoreRule] + VarSet -- Locally-defined free vars of *both* LHS and RHS of rules + -- Note [Rule dependency info] emptySpecInfo :: SpecInfo emptySpecInfo = SpecInfo [] emptyVarSet @@ -479,6 +492,17 @@ specInfoRules (SpecInfo rules _) = rules seqSpecInfo (SpecInfo rules fvs) = seqRules rules `seq` seqVarSet fvs \end{code} +Note [Rule dependency info] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +THe VarSet in a SpecInfo is used for dependency analysis in the +occurrence analyser. We must track free vars in *both* lhs and rhs. Why both? +Consider + x = y + RULE f x = 4 +Then if we substitute y for x, we'd better do so in the + rule's LHS too, so we'd better ensure the dependency is respsected + + %************************************************************************ %* * @@ -680,11 +704,11 @@ zapLamInfo info@(IdInfo {occInfo = occ, newDemandInfo = demand}) -- The "unsafe" occ info is the ones that say I'm not in a lambda -- because that might not be true for an unsaturated lambda is_safe_occ (OneOcc in_lam _ _) = in_lam - is_safe_occ other = True + is_safe_occ _other = True safe_occ = case occ of OneOcc _ once int_cxt -> OneOcc insideLam once int_cxt - other -> occ + _other -> occ is_safe_dmd Nothing = True is_safe_dmd (Just dmd) = not (isStrictDmd dmd) @@ -697,3 +721,27 @@ zapDemandInfo info@(IdInfo {newDemandInfo = dmd}) | otherwise = Nothing \end{code} +\begin{code} +zapFragileInfo :: IdInfo -> Maybe IdInfo +-- Zap info that depends on free variables +zapFragileInfo info = Just (info `setSpecInfo` emptySpecInfo + `setWorkerInfo` NoWorker + `setUnfoldingInfo` NoUnfolding) +\end{code} + +%************************************************************************ +%* * +\subsection{TickBoxOp} +%* * +%************************************************************************ + +\begin{code} +type TickBoxId = Int + +data TickBoxOp + = TickBox Module {-# UNPACK #-} !TickBoxId + -- ^Tick box for Hpc-style coverage + +instance Outputable TickBoxOp where + ppr (TickBox mod n) = ptext SLIT("tick") <+> ppr (mod,n) +\end{code}