{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
module IdInfo (
IdDetails(..), pprIdDetails, coVarDetails, isCoVarDetails,
JoinArity, isJoinIdDetails_maybe,
RecSelParent(..),
IdInfo,
vanillaIdInfo, noCafIdInfo,
OneShotInfo(..),
oneShotInfo, noOneShotInfo, hasNoOneShotInfo,
setOneShotInfo,
zapLamInfo, zapFragileInfo,
zapDemandInfo, zapUsageInfo, zapUsageEnvInfo, zapUsedOnceInfo,
zapTailCallInfo, zapCallArityInfo, zapUnfolding,
ArityInfo,
unknownArity,
arityInfo, setArityInfo, ppArityInfo,
callArityInfo, setCallArityInfo,
strictnessInfo, setStrictnessInfo,
demandInfo, setDemandInfo, pprStrictness,
unfoldingInfo, setUnfoldingInfo,
InlinePragInfo,
inlinePragInfo, setInlinePragInfo,
OccInfo(..),
isDeadOcc, isStrongLoopBreaker, isWeakLoopBreaker,
occInfo, setOccInfo,
InsideLam, OneBranch,
insideLam, notInsideLam, oneBranch, notOneBranch,
TailCallInfo(..),
tailCallInfo, isAlwaysTailCalled,
RuleInfo(..),
emptyRuleInfo,
isEmptyRuleInfo, ruleInfoFreeVars,
ruleInfoRules, setRuleInfoHead,
ruleInfo, setRuleInfo,
CafInfo(..),
ppCafInfo, mayHaveCafRefs,
cafInfo, setCafInfo,
TickBoxOp(..), TickBoxId,
LevityInfo, levityInfo, setNeverLevPoly, setLevityInfoWithType,
isNeverLevPolyIdInfo
) where
#include "HsVersions.h"
import GhcPrelude
import CoreSyn
import Class
import {-# SOURCE #-} PrimOp (PrimOp)
import Name
import VarSet
import BasicTypes
import DataCon
import TyCon
import PatSyn
import Type
import ForeignCall
import Outputable
import Module
import Demand
import Util
infixl 1 `setRuleInfo`,
`setArityInfo`,
`setInlinePragInfo`,
`setUnfoldingInfo`,
`setOneShotInfo`,
`setOccInfo`,
`setCafInfo`,
`setStrictnessInfo`,
`setDemandInfo`,
`setNeverLevPoly`,
`setLevityInfoWithType`
data IdDetails
= VanillaId
| RecSelId
{ IdDetails -> RecSelParent
sel_tycon :: RecSelParent
, IdDetails -> Bool
sel_naughty :: Bool
}
| DataConWorkId DataCon
| DataConWrapId DataCon
| ClassOpId Class
| PrimOpId PrimOp
| FCallId ForeignCall
| TickBoxOpId TickBoxOp
| DFunId Bool
| CoVarId
| JoinId JoinArity
data RecSelParent = RecSelData TyCon | RecSelPatSyn PatSyn deriving RecSelParent -> RecSelParent -> Bool
(RecSelParent -> RecSelParent -> Bool)
-> (RecSelParent -> RecSelParent -> Bool) -> Eq RecSelParent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecSelParent -> RecSelParent -> Bool
$c/= :: RecSelParent -> RecSelParent -> Bool
== :: RecSelParent -> RecSelParent -> Bool
$c== :: RecSelParent -> RecSelParent -> Bool
Eq
instance Outputable RecSelParent where
ppr :: RecSelParent -> SDoc
ppr RecSelParent
p = case RecSelParent
p of
RecSelData TyCon
ty_con -> TyCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyCon
ty_con
RecSelPatSyn PatSyn
ps -> PatSyn -> SDoc
forall a. Outputable a => a -> SDoc
ppr PatSyn
ps
coVarDetails :: IdDetails
coVarDetails :: IdDetails
coVarDetails = IdDetails
CoVarId
isCoVarDetails :: IdDetails -> Bool
isCoVarDetails :: IdDetails -> Bool
isCoVarDetails IdDetails
CoVarId = Bool
True
isCoVarDetails IdDetails
_ = Bool
False
isJoinIdDetails_maybe :: IdDetails -> Maybe JoinArity
isJoinIdDetails_maybe :: IdDetails -> Maybe JoinArity
isJoinIdDetails_maybe (JoinId JoinArity
join_arity) = JoinArity -> Maybe JoinArity
forall a. a -> Maybe a
Just JoinArity
join_arity
isJoinIdDetails_maybe IdDetails
_ = Maybe JoinArity
forall a. Maybe a
Nothing
instance Outputable IdDetails where
ppr :: IdDetails -> SDoc
ppr = IdDetails -> SDoc
pprIdDetails
pprIdDetails :: IdDetails -> SDoc
pprIdDetails :: IdDetails -> SDoc
pprIdDetails IdDetails
VanillaId = SDoc
empty
pprIdDetails IdDetails
other = SDoc -> SDoc
brackets (IdDetails -> SDoc
pp IdDetails
other)
where
pp :: IdDetails -> SDoc
pp IdDetails
VanillaId = String -> SDoc
forall a. String -> a
panic String
"pprIdDetails"
pp (DataConWorkId DataCon
_) = String -> SDoc
text String
"DataCon"
pp (DataConWrapId DataCon
_) = String -> SDoc
text String
"DataConWrapper"
pp (ClassOpId {}) = String -> SDoc
text String
"ClassOp"
pp (PrimOpId PrimOp
_) = String -> SDoc
text String
"PrimOp"
pp (FCallId ForeignCall
_) = String -> SDoc
text String
"ForeignCall"
pp (TickBoxOpId TickBoxOp
_) = String -> SDoc
text String
"TickBoxOp"
pp (DFunId Bool
nt) = String -> SDoc
text String
"DFunId" SDoc -> SDoc -> SDoc
<> Bool -> SDoc -> SDoc
ppWhen Bool
nt (String -> SDoc
text String
"(nt)")
pp (RecSelId { sel_naughty :: IdDetails -> Bool
sel_naughty = Bool
is_naughty })
= SDoc -> SDoc
brackets (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
text String
"RecSel" SDoc -> SDoc -> SDoc
<>
Bool -> SDoc -> SDoc
ppWhen Bool
is_naughty (String -> SDoc
text String
"(naughty)")
pp IdDetails
CoVarId = String -> SDoc
text String
"CoVarId"
pp (JoinId JoinArity
arity) = String -> SDoc
text String
"JoinId" SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
parens (JoinArity -> SDoc
int JoinArity
arity)
data IdInfo
= IdInfo {
IdInfo -> JoinArity
arityInfo :: !ArityInfo,
IdInfo -> RuleInfo
ruleInfo :: RuleInfo,
IdInfo -> Unfolding
unfoldingInfo :: Unfolding,
IdInfo -> CafInfo
cafInfo :: CafInfo,
IdInfo -> OneShotInfo
oneShotInfo :: OneShotInfo,
IdInfo -> InlinePragma
inlinePragInfo :: InlinePragma,
IdInfo -> OccInfo
occInfo :: OccInfo,
IdInfo -> StrictSig
strictnessInfo :: StrictSig,
IdInfo -> Demand
demandInfo :: Demand,
IdInfo -> JoinArity
callArityInfo :: !ArityInfo,
IdInfo -> LevityInfo
levityInfo :: LevityInfo
}
setRuleInfo :: IdInfo -> RuleInfo -> IdInfo
setRuleInfo :: IdInfo -> RuleInfo -> IdInfo
setRuleInfo IdInfo
info RuleInfo
sp = RuleInfo
sp RuleInfo -> IdInfo -> IdInfo
`seq` IdInfo
info { ruleInfo :: RuleInfo
ruleInfo = RuleInfo
sp }
setInlinePragInfo :: IdInfo -> InlinePragma -> IdInfo
setInlinePragInfo :: IdInfo -> InlinePragma -> IdInfo
setInlinePragInfo IdInfo
info InlinePragma
pr = InlinePragma
pr InlinePragma -> IdInfo -> IdInfo
`seq` IdInfo
info { inlinePragInfo :: InlinePragma
inlinePragInfo = InlinePragma
pr }
setOccInfo :: IdInfo -> OccInfo -> IdInfo
setOccInfo :: IdInfo -> OccInfo -> IdInfo
setOccInfo IdInfo
info OccInfo
oc = OccInfo
oc OccInfo -> IdInfo -> IdInfo
`seq` IdInfo
info { occInfo :: OccInfo
occInfo = OccInfo
oc }
setUnfoldingInfo :: IdInfo -> Unfolding -> IdInfo
setUnfoldingInfo :: IdInfo -> Unfolding -> IdInfo
setUnfoldingInfo IdInfo
info Unfolding
uf
=
IdInfo
info { unfoldingInfo :: Unfolding
unfoldingInfo = Unfolding
uf }
setArityInfo :: IdInfo -> ArityInfo -> IdInfo
setArityInfo :: IdInfo -> JoinArity -> IdInfo
setArityInfo IdInfo
info JoinArity
ar = IdInfo
info { arityInfo :: JoinArity
arityInfo = JoinArity
ar }
setCallArityInfo :: IdInfo -> ArityInfo -> IdInfo
setCallArityInfo :: IdInfo -> JoinArity -> IdInfo
setCallArityInfo IdInfo
info JoinArity
ar = IdInfo
info { callArityInfo :: JoinArity
callArityInfo = JoinArity
ar }
setCafInfo :: IdInfo -> CafInfo -> IdInfo
setCafInfo :: IdInfo -> CafInfo -> IdInfo
setCafInfo IdInfo
info CafInfo
caf = IdInfo
info { cafInfo :: CafInfo
cafInfo = CafInfo
caf }
setOneShotInfo :: IdInfo -> OneShotInfo -> IdInfo
setOneShotInfo :: IdInfo -> OneShotInfo -> IdInfo
setOneShotInfo IdInfo
info OneShotInfo
lb = IdInfo
info { oneShotInfo :: OneShotInfo
oneShotInfo = OneShotInfo
lb }
setDemandInfo :: IdInfo -> Demand -> IdInfo
setDemandInfo :: IdInfo -> Demand -> IdInfo
setDemandInfo IdInfo
info Demand
dd = Demand
dd Demand -> IdInfo -> IdInfo
`seq` IdInfo
info { demandInfo :: Demand
demandInfo = Demand
dd }
setStrictnessInfo :: IdInfo -> StrictSig -> IdInfo
setStrictnessInfo :: IdInfo -> StrictSig -> IdInfo
setStrictnessInfo IdInfo
info StrictSig
dd = StrictSig
dd StrictSig -> IdInfo -> IdInfo
`seq` IdInfo
info { strictnessInfo :: StrictSig
strictnessInfo = StrictSig
dd }
vanillaIdInfo :: IdInfo
vanillaIdInfo :: IdInfo
vanillaIdInfo
= IdInfo :: JoinArity
-> RuleInfo
-> Unfolding
-> CafInfo
-> OneShotInfo
-> InlinePragma
-> OccInfo
-> StrictSig
-> Demand
-> JoinArity
-> LevityInfo
-> IdInfo
IdInfo {
cafInfo :: CafInfo
cafInfo = CafInfo
vanillaCafInfo,
arityInfo :: JoinArity
arityInfo = JoinArity
unknownArity,
ruleInfo :: RuleInfo
ruleInfo = RuleInfo
emptyRuleInfo,
unfoldingInfo :: Unfolding
unfoldingInfo = Unfolding
noUnfolding,
oneShotInfo :: OneShotInfo
oneShotInfo = OneShotInfo
NoOneShotInfo,
inlinePragInfo :: InlinePragma
inlinePragInfo = InlinePragma
defaultInlinePragma,
occInfo :: OccInfo
occInfo = OccInfo
noOccInfo,
demandInfo :: Demand
demandInfo = Demand
topDmd,
strictnessInfo :: StrictSig
strictnessInfo = StrictSig
nopSig,
callArityInfo :: JoinArity
callArityInfo = JoinArity
unknownArity,
levityInfo :: LevityInfo
levityInfo = LevityInfo
NoLevityInfo
}
noCafIdInfo :: IdInfo
noCafIdInfo :: IdInfo
noCafIdInfo = IdInfo
vanillaIdInfo IdInfo -> CafInfo -> IdInfo
`setCafInfo` CafInfo
NoCafRefs
type ArityInfo = Arity
unknownArity :: Arity
unknownArity :: JoinArity
unknownArity = JoinArity
0
ppArityInfo :: Int -> SDoc
ppArityInfo :: JoinArity -> SDoc
ppArityInfo JoinArity
0 = SDoc
empty
ppArityInfo JoinArity
n = [SDoc] -> SDoc
hsep [String -> SDoc
text String
"Arity", JoinArity -> SDoc
int JoinArity
n]
type InlinePragInfo = InlinePragma
pprStrictness :: StrictSig -> SDoc
pprStrictness :: StrictSig -> SDoc
pprStrictness StrictSig
sig = StrictSig -> SDoc
forall a. Outputable a => a -> SDoc
ppr StrictSig
sig
data RuleInfo
= RuleInfo
[CoreRule]
DVarSet
emptyRuleInfo :: RuleInfo
emptyRuleInfo :: RuleInfo
emptyRuleInfo = [CoreRule] -> DVarSet -> RuleInfo
RuleInfo [] DVarSet
emptyDVarSet
isEmptyRuleInfo :: RuleInfo -> Bool
isEmptyRuleInfo :: RuleInfo -> Bool
isEmptyRuleInfo (RuleInfo [CoreRule]
rs DVarSet
_) = [CoreRule] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [CoreRule]
rs
ruleInfoFreeVars :: RuleInfo -> DVarSet
ruleInfoFreeVars :: RuleInfo -> DVarSet
ruleInfoFreeVars (RuleInfo [CoreRule]
_ DVarSet
fvs) = DVarSet
fvs
ruleInfoRules :: RuleInfo -> [CoreRule]
ruleInfoRules :: RuleInfo -> [CoreRule]
ruleInfoRules (RuleInfo [CoreRule]
rules DVarSet
_) = [CoreRule]
rules
setRuleInfoHead :: Name -> RuleInfo -> RuleInfo
setRuleInfoHead :: Name -> RuleInfo -> RuleInfo
setRuleInfoHead Name
fn (RuleInfo [CoreRule]
rules DVarSet
fvs)
= [CoreRule] -> DVarSet -> RuleInfo
RuleInfo ((CoreRule -> CoreRule) -> [CoreRule] -> [CoreRule]
forall a b. (a -> b) -> [a] -> [b]
map (Name -> CoreRule -> CoreRule
setRuleIdName Name
fn) [CoreRule]
rules) DVarSet
fvs
data CafInfo
= MayHaveCafRefs
| NoCafRefs
deriving (CafInfo -> CafInfo -> Bool
(CafInfo -> CafInfo -> Bool)
-> (CafInfo -> CafInfo -> Bool) -> Eq CafInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CafInfo -> CafInfo -> Bool
$c/= :: CafInfo -> CafInfo -> Bool
== :: CafInfo -> CafInfo -> Bool
$c== :: CafInfo -> CafInfo -> Bool
Eq, Eq CafInfo
Eq CafInfo
-> (CafInfo -> CafInfo -> Ordering)
-> (CafInfo -> CafInfo -> Bool)
-> (CafInfo -> CafInfo -> Bool)
-> (CafInfo -> CafInfo -> Bool)
-> (CafInfo -> CafInfo -> Bool)
-> (CafInfo -> CafInfo -> CafInfo)
-> (CafInfo -> CafInfo -> CafInfo)
-> Ord CafInfo
CafInfo -> CafInfo -> Bool
CafInfo -> CafInfo -> Ordering
CafInfo -> CafInfo -> CafInfo
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CafInfo -> CafInfo -> CafInfo
$cmin :: CafInfo -> CafInfo -> CafInfo
max :: CafInfo -> CafInfo -> CafInfo
$cmax :: CafInfo -> CafInfo -> CafInfo
>= :: CafInfo -> CafInfo -> Bool
$c>= :: CafInfo -> CafInfo -> Bool
> :: CafInfo -> CafInfo -> Bool
$c> :: CafInfo -> CafInfo -> Bool
<= :: CafInfo -> CafInfo -> Bool
$c<= :: CafInfo -> CafInfo -> Bool
< :: CafInfo -> CafInfo -> Bool
$c< :: CafInfo -> CafInfo -> Bool
compare :: CafInfo -> CafInfo -> Ordering
$ccompare :: CafInfo -> CafInfo -> Ordering
$cp1Ord :: Eq CafInfo
Ord)
vanillaCafInfo :: CafInfo
vanillaCafInfo :: CafInfo
vanillaCafInfo = CafInfo
MayHaveCafRefs
mayHaveCafRefs :: CafInfo -> Bool
mayHaveCafRefs :: CafInfo -> Bool
mayHaveCafRefs CafInfo
MayHaveCafRefs = Bool
True
mayHaveCafRefs CafInfo
_ = Bool
False
instance Outputable CafInfo where
ppr :: CafInfo -> SDoc
ppr = CafInfo -> SDoc
ppCafInfo
ppCafInfo :: CafInfo -> SDoc
ppCafInfo :: CafInfo -> SDoc
ppCafInfo CafInfo
NoCafRefs = String -> SDoc
text String
"NoCafRefs"
ppCafInfo CafInfo
MayHaveCafRefs = SDoc
empty
zapLamInfo :: IdInfo -> Maybe IdInfo
zapLamInfo :: IdInfo -> Maybe IdInfo
zapLamInfo info :: IdInfo
info@(IdInfo {occInfo :: IdInfo -> OccInfo
occInfo = OccInfo
occ, demandInfo :: IdInfo -> Demand
demandInfo = Demand
demand})
| OccInfo -> Bool
is_safe_occ OccInfo
occ Bool -> Bool -> Bool
&& Demand -> Bool
forall s u. JointDmd (Str s) (Use u) -> Bool
is_safe_dmd Demand
demand
= Maybe IdInfo
forall a. Maybe a
Nothing
| Bool
otherwise
= IdInfo -> Maybe IdInfo
forall a. a -> Maybe a
Just (IdInfo
info {occInfo :: OccInfo
occInfo = OccInfo
safe_occ, demandInfo :: Demand
demandInfo = Demand
topDmd})
where
is_safe_occ :: OccInfo -> Bool
is_safe_occ OccInfo
occ | OccInfo -> Bool
isAlwaysTailCalled OccInfo
occ = Bool
False
is_safe_occ (OneOcc { occ_in_lam :: OccInfo -> Bool
occ_in_lam = Bool
in_lam }) = Bool
in_lam
is_safe_occ OccInfo
_other = Bool
True
safe_occ :: OccInfo
safe_occ = case OccInfo
occ of
OneOcc{} -> OccInfo
occ { occ_in_lam :: Bool
occ_in_lam = Bool
True
, occ_tail :: TailCallInfo
occ_tail = TailCallInfo
NoTailCallInfo }
IAmALoopBreaker{}
-> OccInfo
occ { occ_tail :: TailCallInfo
occ_tail = TailCallInfo
NoTailCallInfo }
OccInfo
_other -> OccInfo
occ
is_safe_dmd :: JointDmd (Str s) (Use u) -> Bool
is_safe_dmd JointDmd (Str s) (Use u)
dmd = Bool -> Bool
not (JointDmd (Str s) (Use u) -> Bool
forall s u. JointDmd (Str s) (Use u) -> Bool
isStrictDmd JointDmd (Str s) (Use u)
dmd)
zapDemandInfo :: IdInfo -> Maybe IdInfo
zapDemandInfo :: IdInfo -> Maybe IdInfo
zapDemandInfo IdInfo
info = IdInfo -> Maybe IdInfo
forall a. a -> Maybe a
Just (IdInfo
info {demandInfo :: Demand
demandInfo = Demand
topDmd})
zapUsageInfo :: IdInfo -> Maybe IdInfo
zapUsageInfo :: IdInfo -> Maybe IdInfo
zapUsageInfo IdInfo
info = IdInfo -> Maybe IdInfo
forall a. a -> Maybe a
Just (IdInfo
info {demandInfo :: Demand
demandInfo = Demand -> Demand
zapUsageDemand (IdInfo -> Demand
demandInfo IdInfo
info)})
zapUsageEnvInfo :: IdInfo -> Maybe IdInfo
zapUsageEnvInfo :: IdInfo -> Maybe IdInfo
zapUsageEnvInfo IdInfo
info
| StrictSig -> Bool
hasDemandEnvSig (IdInfo -> StrictSig
strictnessInfo IdInfo
info)
= IdInfo -> Maybe IdInfo
forall a. a -> Maybe a
Just (IdInfo
info {strictnessInfo :: StrictSig
strictnessInfo = StrictSig -> StrictSig
zapUsageEnvSig (IdInfo -> StrictSig
strictnessInfo IdInfo
info)})
| Bool
otherwise
= Maybe IdInfo
forall a. Maybe a
Nothing
zapUsedOnceInfo :: IdInfo -> Maybe IdInfo
zapUsedOnceInfo :: IdInfo -> Maybe IdInfo
zapUsedOnceInfo IdInfo
info
= IdInfo -> Maybe IdInfo
forall a. a -> Maybe a
Just (IdInfo -> Maybe IdInfo) -> IdInfo -> Maybe IdInfo
forall a b. (a -> b) -> a -> b
$ IdInfo
info { strictnessInfo :: StrictSig
strictnessInfo = StrictSig -> StrictSig
zapUsedOnceSig (IdInfo -> StrictSig
strictnessInfo IdInfo
info)
, demandInfo :: Demand
demandInfo = Demand -> Demand
zapUsedOnceDemand (IdInfo -> Demand
demandInfo IdInfo
info) }
zapFragileInfo :: IdInfo -> Maybe IdInfo
zapFragileInfo :: IdInfo -> Maybe IdInfo
zapFragileInfo info :: IdInfo
info@(IdInfo { occInfo :: IdInfo -> OccInfo
occInfo = OccInfo
occ, unfoldingInfo :: IdInfo -> Unfolding
unfoldingInfo = Unfolding
unf })
= Unfolding
new_unf Unfolding -> Maybe IdInfo -> Maybe IdInfo
`seq`
IdInfo -> Maybe IdInfo
forall a. a -> Maybe a
Just (IdInfo
info IdInfo -> RuleInfo -> IdInfo
`setRuleInfo` RuleInfo
emptyRuleInfo
IdInfo -> Unfolding -> IdInfo
`setUnfoldingInfo` Unfolding
new_unf
IdInfo -> OccInfo -> IdInfo
`setOccInfo` OccInfo -> OccInfo
zapFragileOcc OccInfo
occ)
where
new_unf :: Unfolding
new_unf = Unfolding -> Unfolding
zapFragileUnfolding Unfolding
unf
zapFragileUnfolding :: Unfolding -> Unfolding
zapFragileUnfolding :: Unfolding -> Unfolding
zapFragileUnfolding Unfolding
unf
| Unfolding -> Bool
isFragileUnfolding Unfolding
unf = Unfolding
noUnfolding
| Bool
otherwise = Unfolding
unf
zapUnfolding :: Unfolding -> Unfolding
zapUnfolding :: Unfolding -> Unfolding
zapUnfolding Unfolding
unf | Unfolding -> Bool
isEvaldUnfolding Unfolding
unf = Unfolding
evaldUnfolding
| Bool
otherwise = Unfolding
noUnfolding
zapTailCallInfo :: IdInfo -> Maybe IdInfo
zapTailCallInfo :: IdInfo -> Maybe IdInfo
zapTailCallInfo IdInfo
info
= case IdInfo -> OccInfo
occInfo IdInfo
info of
OccInfo
occ | OccInfo -> Bool
isAlwaysTailCalled OccInfo
occ -> IdInfo -> Maybe IdInfo
forall a. a -> Maybe a
Just (IdInfo
info IdInfo -> OccInfo -> IdInfo
`setOccInfo` OccInfo
safe_occ)
| Bool
otherwise -> Maybe IdInfo
forall a. Maybe a
Nothing
where
safe_occ :: OccInfo
safe_occ = OccInfo
occ { occ_tail :: TailCallInfo
occ_tail = TailCallInfo
NoTailCallInfo }
zapCallArityInfo :: IdInfo -> IdInfo
zapCallArityInfo :: IdInfo -> IdInfo
zapCallArityInfo IdInfo
info = IdInfo -> JoinArity -> IdInfo
setCallArityInfo IdInfo
info JoinArity
0
type TickBoxId = Int
data TickBoxOp
= TickBox Module {-# UNPACK #-} !TickBoxId
instance Outputable TickBoxOp where
ppr :: TickBoxOp -> SDoc
ppr (TickBox Module
mod JoinArity
n) = String -> SDoc
text String
"tick" SDoc -> SDoc -> SDoc
<+> (Module, JoinArity) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (Module
mod,JoinArity
n)
data LevityInfo = NoLevityInfo
| NeverLevityPolymorphic
deriving LevityInfo -> LevityInfo -> Bool
(LevityInfo -> LevityInfo -> Bool)
-> (LevityInfo -> LevityInfo -> Bool) -> Eq LevityInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LevityInfo -> LevityInfo -> Bool
$c/= :: LevityInfo -> LevityInfo -> Bool
== :: LevityInfo -> LevityInfo -> Bool
$c== :: LevityInfo -> LevityInfo -> Bool
Eq
instance Outputable LevityInfo where
ppr :: LevityInfo -> SDoc
ppr LevityInfo
NoLevityInfo = String -> SDoc
text String
"NoLevityInfo"
ppr LevityInfo
NeverLevityPolymorphic = String -> SDoc
text String
"NeverLevityPolymorphic"
setNeverLevPoly :: HasDebugCallStack => IdInfo -> Type -> IdInfo
setNeverLevPoly :: IdInfo -> Type -> IdInfo
setNeverLevPoly IdInfo
info Type
ty
= ASSERT2( not (resultIsLevPoly ty), ppr ty )
IdInfo
info { levityInfo :: LevityInfo
levityInfo = LevityInfo
NeverLevityPolymorphic }
setLevityInfoWithType :: IdInfo -> Type -> IdInfo
setLevityInfoWithType :: IdInfo -> Type -> IdInfo
setLevityInfoWithType IdInfo
info Type
ty
| Bool -> Bool
not (Type -> Bool
resultIsLevPoly Type
ty)
= IdInfo
info { levityInfo :: LevityInfo
levityInfo = LevityInfo
NeverLevityPolymorphic }
| Bool
otherwise
= IdInfo
info
isNeverLevPolyIdInfo :: IdInfo -> Bool
isNeverLevPolyIdInfo :: IdInfo -> Bool
isNeverLevPolyIdInfo IdInfo
info
| LevityInfo
NeverLevityPolymorphic <- IdInfo -> LevityInfo
levityInfo IdInfo
info = Bool
True
| Bool
otherwise = Bool
False