projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove GADT refinements, part 4
[ghc-hetmet.git]
/
compiler
/
basicTypes
/
IdInfo.lhs
diff --git
a/compiler/basicTypes/IdInfo.lhs
b/compiler/basicTypes/IdInfo.lhs
index
b009794
..
708f4df
100644
(file)
--- a/
compiler/basicTypes/IdInfo.lhs
+++ b/
compiler/basicTypes/IdInfo.lhs
@@
-65,7
+65,7
@@
module IdInfo (
-- Specialisation
SpecInfo(..), specInfo, setSpecInfo, isEmptySpecInfo,
-- Specialisation
SpecInfo(..), specInfo, setSpecInfo, isEmptySpecInfo,
- specInfoFreeVars, specInfoRules, seqSpecInfo,
+ specInfoFreeVars, specInfoRules, seqSpecInfo, setSpecInfoHead,
-- CAF info
CafInfo(..), cafInfo, ppCafInfo, setCafInfo, mayHaveCafRefs,
-- CAF info
CafInfo(..), cafInfo, ppCafInfo, setCafInfo, mayHaveCafRefs,
@@
-82,6
+82,7
@@
module IdInfo (
import CoreSyn
import Class
import PrimOp
import CoreSyn
import Class
import PrimOp
+import Name
import Var
import VarSet
import BasicTypes
import Var
import VarSet
import BasicTypes
@@
-91,11
+92,11
@@
import ForeignCall
import NewDemand
import Outputable
import Module
import NewDemand
import Outputable
import Module
+import FastString
import Data.Maybe
#ifdef OLD_STRICTNESS
import Data.Maybe
#ifdef OLD_STRICTNESS
-import Name
import Demand
import qualified Demand
import Util
import Demand
import qualified Demand
import Util
@@
-130,8
+131,8
@@
infixl 1 `setSpecInfo`,
To be removed later
\begin{code}
To be removed later
\begin{code}
--- setAllStrictnessInfo :: IdInfo -> Maybe StrictSig -> IdInfo
-- Set old and new strictness info
-- Set old and new strictness info
+setAllStrictnessInfo :: IdInfo -> Maybe StrictSig -> IdInfo
setAllStrictnessInfo info Nothing
= info { newStrictnessInfo = Nothing
#ifdef OLD_STRICTNESS
setAllStrictnessInfo info Nothing
= info { newStrictnessInfo = Nothing
#ifdef OLD_STRICTNESS
@@
-148,9
+149,11
@@
setAllStrictnessInfo info (Just sig)
#endif
}
#endif
}
+seqNewStrictnessInfo :: Maybe StrictSig -> ()
seqNewStrictnessInfo Nothing = ()
seqNewStrictnessInfo (Just ty) = seqStrictSig ty
seqNewStrictnessInfo Nothing = ()
seqNewStrictnessInfo (Just ty) = seqStrictSig ty
+pprNewStrictness :: Maybe StrictSig -> SDoc
pprNewStrictness Nothing = empty
pprNewStrictness (Just sig) = ftext FSLIT("Str:") <+> ppr sig
pprNewStrictness Nothing = empty
pprNewStrictness (Just sig) = ftext FSLIT("Str:") <+> ppr sig
@@
-212,6
+215,7
@@
oldDemand (Call _) = WwStrict
\begin{code}
\begin{code}
+seqNewDemandInfo :: Maybe Demand -> ()
seqNewDemandInfo Nothing = ()
seqNewDemandInfo (Just dmd) = seqDemand dmd
\end{code}
seqNewDemandInfo Nothing = ()
seqNewDemandInfo (Just dmd) = seqDemand dmd
\end{code}
@@
-255,6
+259,7
@@
data GlobalIdDetails
| NotGlobalId -- Used as a convenient extra return value from globalIdDetails
| NotGlobalId -- Used as a convenient extra return value from globalIdDetails
+notGlobalId :: GlobalIdDetails
notGlobalId = NotGlobalId
instance Outputable GlobalIdDetails where
notGlobalId = NotGlobalId
instance Outputable GlobalIdDetails where
@@
-352,19
+357,25
@@
megaSeqIdInfo info
Setters
\begin{code}
Setters
\begin{code}
+setWorkerInfo :: IdInfo -> WorkerInfo -> IdInfo
setWorkerInfo info wk = wk `seq` info { workerInfo = wk }
setWorkerInfo info wk = wk `seq` info { workerInfo = wk }
+setSpecInfo :: IdInfo -> SpecInfo -> IdInfo
setSpecInfo info sp = sp `seq` info { specInfo = sp }
setSpecInfo info sp = sp `seq` info { specInfo = sp }
+setInlinePragInfo :: IdInfo -> InlinePragInfo -> IdInfo
setInlinePragInfo info pr = pr `seq` info { inlinePragInfo = pr }
setInlinePragInfo info pr = pr `seq` info { inlinePragInfo = pr }
+setOccInfo :: IdInfo -> OccInfo -> IdInfo
setOccInfo info oc = oc `seq` info { occInfo = oc }
#ifdef OLD_STRICTNESS
setStrictnessInfo info st = st `seq` info { strictnessInfo = st }
#endif
-- Try to avoid spack leaks by seq'ing
setOccInfo info oc = oc `seq` info { occInfo = oc }
#ifdef OLD_STRICTNESS
setStrictnessInfo info st = st `seq` info { strictnessInfo = st }
#endif
-- Try to avoid spack leaks by seq'ing
+setUnfoldingInfoLazily :: IdInfo -> Unfolding -> IdInfo
setUnfoldingInfoLazily info uf -- Lazy variant to avoid looking at the
= -- unfolding of an imported Id unless necessary
info { unfoldingInfo = uf } -- (In this case the demand-zapping is redundant.)
setUnfoldingInfoLazily info uf -- Lazy variant to avoid looking at the
= -- unfolding of an imported Id unless necessary
info { unfoldingInfo = uf } -- (In this case the demand-zapping is redundant.)
+setUnfoldingInfo :: IdInfo -> Unfolding -> IdInfo
setUnfoldingInfo info uf
-- We do *not* seq on the unfolding info, For some reason, doing so
-- actually increases residency significantly.
setUnfoldingInfo info uf
-- We do *not* seq on the unfolding info, For some reason, doing so
-- actually increases residency significantly.
@@
-375,12
+386,17
@@
setDemandInfo info dd = info { demandInfo = dd }
setCprInfo info cp = info { cprInfo = cp }
#endif
setCprInfo info cp = info { cprInfo = cp }
#endif
+setArityInfo :: IdInfo -> ArityInfo -> IdInfo
setArityInfo info ar = info { arityInfo = ar }
setArityInfo info ar = info { arityInfo = ar }
+setCafInfo :: IdInfo -> CafInfo -> IdInfo
setCafInfo info caf = info { cafInfo = caf }
setCafInfo info caf = info { cafInfo = caf }
+setLBVarInfo :: IdInfo -> LBVarInfo -> IdInfo
setLBVarInfo info lb = {-lb `seq`-} info { lbvarInfo = lb }
setLBVarInfo info lb = {-lb `seq`-} info { lbvarInfo = lb }
+setNewDemandInfo :: IdInfo -> Maybe Demand -> IdInfo
setNewDemandInfo info dd = dd `seq` info { newDemandInfo = dd }
setNewDemandInfo info dd = dd `seq` info { newDemandInfo = dd }
+setNewStrictnessInfo :: IdInfo -> Maybe StrictSig -> IdInfo
setNewStrictnessInfo info dd = dd `seq` info { newStrictnessInfo = dd }
\end{code}
setNewStrictnessInfo info dd = dd `seq` info { newStrictnessInfo = dd }
\end{code}
@@
-406,6
+422,7
@@
vanillaIdInfo
newStrictnessInfo = Nothing
}
newStrictnessInfo = Nothing
}
+noCafIdInfo :: IdInfo
noCafIdInfo = vanillaIdInfo `setCafInfo` NoCafRefs
-- Used for built-in type Ids in MkId.
\end{code}
noCafIdInfo = vanillaIdInfo `setCafInfo` NoCafRefs
-- Used for built-in type Ids in MkId.
\end{code}
@@
-431,8
+448,10
@@
type ArityInfo = Arity
-- The arity might increase later in the compilation process, if
-- an extra lambda floats up to the binding site.
-- The arity might increase later in the compilation process, if
-- an extra lambda floats up to the binding site.
+unknownArity :: Arity
unknownArity = 0 :: Arity
unknownArity = 0 :: Arity
+ppArityInfo :: Int -> SDoc
ppArityInfo 0 = empty
ppArityInfo n = hsep [ptext SLIT("Arity"), int n]
\end{code}
ppArityInfo 0 = empty
ppArityInfo n = hsep [ptext SLIT("Arity"), int n]
\end{code}
@@
-464,9
+483,13
@@
type InlinePragInfo = Activation
%************************************************************************
\begin{code}
%************************************************************************
\begin{code}
--- CoreRules is used only in an idSpecialisation (move to IdInfo?)
data SpecInfo
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. I don't think it needs to include the
+ -- ru_fn though.
+ -- Note [Rule dependency info] in OccurAnal
emptySpecInfo :: SpecInfo
emptySpecInfo = SpecInfo [] emptyVarSet
emptySpecInfo :: SpecInfo
emptySpecInfo = SpecInfo [] emptyVarSet
@@
-480,10
+503,18
@@
specInfoFreeVars (SpecInfo _ fvs) = fvs
specInfoRules :: SpecInfo -> [CoreRule]
specInfoRules (SpecInfo rules _) = rules
specInfoRules :: SpecInfo -> [CoreRule]
specInfoRules (SpecInfo rules _) = rules
+setSpecInfoHead :: Name -> SpecInfo -> SpecInfo
+setSpecInfoHead fn (SpecInfo rules fvs)
+ = SpecInfo (map set_head rules) fvs
+ where
+ set_head rule = rule { ru_fn = fn }
+
+seqSpecInfo :: SpecInfo -> ()
seqSpecInfo (SpecInfo rules fvs) = seqRules rules `seq` seqVarSet fvs
\end{code}
seqSpecInfo (SpecInfo rules fvs) = seqRules rules `seq` seqVarSet fvs
\end{code}
+
%************************************************************************
%* *
\subsection[worker-IdInfo]{Worker info about an @Id@}
%************************************************************************
%* *
\subsection[worker-IdInfo]{Worker info about an @Id@}
@@
-527,6
+558,7
@@
seqWorker :: WorkerInfo -> ()
seqWorker (HasWorker id a) = id `seq` a `seq` ()
seqWorker NoWorker = ()
seqWorker (HasWorker id a) = id `seq` a `seq` ()
seqWorker NoWorker = ()
+ppWorkerInfo :: WorkerInfo -> SDoc
ppWorkerInfo NoWorker = empty
ppWorkerInfo (HasWorker wk_id _) = ptext SLIT("Worker") <+> ppr wk_id
ppWorkerInfo NoWorker = empty
ppWorkerInfo (HasWorker wk_id _) = ptext SLIT("Worker") <+> ppr wk_id
@@
-536,9
+568,11
@@
workerExists (HasWorker _ _) = True
workerId :: WorkerInfo -> Id
workerId (HasWorker id _) = id
workerId :: WorkerInfo -> Id
workerId (HasWorker id _) = id
+workerId NoWorker = panic "workerId: NoWorker"
wrapperArity :: WorkerInfo -> Arity
wrapperArity (HasWorker _ a) = a
wrapperArity :: WorkerInfo -> Arity
wrapperArity (HasWorker _ a) = a
+wrapperArity NoWorker = panic "wrapperArity: NoWorker"
\end{code}
\end{code}
@@
-560,13
+594,17
@@
data CafInfo
| NoCafRefs -- A function or static constructor
-- that refers to no CAFs.
| NoCafRefs -- A function or static constructor
-- that refers to no CAFs.
+vanillaCafInfo :: CafInfo
vanillaCafInfo = MayHaveCafRefs -- Definitely safe
vanillaCafInfo = MayHaveCafRefs -- Definitely safe
+mayHaveCafRefs :: CafInfo -> Bool
mayHaveCafRefs MayHaveCafRefs = True
mayHaveCafRefs _ = False
mayHaveCafRefs MayHaveCafRefs = True
mayHaveCafRefs _ = False
+seqCaf :: CafInfo -> ()
seqCaf c = c `seq` ()
seqCaf c = c `seq` ()
+ppCafInfo :: CafInfo -> SDoc
ppCafInfo NoCafRefs = ptext SLIT("NoCafRefs")
ppCafInfo MayHaveCafRefs = empty
\end{code}
ppCafInfo NoCafRefs = ptext SLIT("NoCafRefs")
ppCafInfo MayHaveCafRefs = empty
\end{code}
@@
-644,15
+682,19
@@
work.
data LBVarInfo = NoLBVarInfo
| IsOneShotLambda -- The lambda is applied at most once).
data LBVarInfo = NoLBVarInfo
| IsOneShotLambda -- The lambda is applied at most once).
+seqLBVar :: LBVarInfo -> ()
seqLBVar l = l `seq` ()
\end{code}
\begin{code}
seqLBVar l = l `seq` ()
\end{code}
\begin{code}
+hasNoLBVarInfo :: LBVarInfo -> Bool
hasNoLBVarInfo NoLBVarInfo = True
hasNoLBVarInfo IsOneShotLambda = False
hasNoLBVarInfo NoLBVarInfo = True
hasNoLBVarInfo IsOneShotLambda = False
+noLBVarInfo :: LBVarInfo
noLBVarInfo = NoLBVarInfo
noLBVarInfo = NoLBVarInfo
+pprLBVarInfo :: LBVarInfo -> SDoc
pprLBVarInfo NoLBVarInfo = empty
pprLBVarInfo IsOneShotLambda = ptext SLIT("OneShot")
pprLBVarInfo NoLBVarInfo = empty
pprLBVarInfo IsOneShotLambda = ptext SLIT("OneShot")
@@
-684,11
+726,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
-- 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
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)
is_safe_dmd Nothing = True
is_safe_dmd (Just dmd) = not (isStrictDmd dmd)
@@
-704,9
+746,13
@@
zapDemandInfo info@(IdInfo {newDemandInfo = dmd})
\begin{code}
zapFragileInfo :: IdInfo -> Maybe IdInfo
-- Zap info that depends on free variables
\begin{code}
zapFragileInfo :: IdInfo -> Maybe IdInfo
-- Zap info that depends on free variables
-zapFragileInfo info = Just (info `setSpecInfo` emptySpecInfo
- `setWorkerInfo` NoWorker
- `setUnfoldingInfo` NoUnfolding)
+zapFragileInfo info
+ = Just (info `setSpecInfo` emptySpecInfo
+ `setWorkerInfo` NoWorker
+ `setUnfoldingInfo` NoUnfolding
+ `setOccInfo` if isFragileOcc occ then NoOccInfo else occ)
+ where
+ occ = occInfo info
\end{code}
%************************************************************************
\end{code}
%************************************************************************