IdInfo

ghc-8.2.1: The GHC API

Safe Haskell | None
Language | Haskell2010

IdInfo

Contents

- The IdDetails type
- The IdInfo type
  - The OneShotInfo type
  - Zapping various forms of Info
  - The ArityInfo type
  - Demand and strictness Info
  - Unfolding Info
  - The InlinePragInfo type
  - The OccInfo type
  - The RuleInfo type
  - The CAFInfo type
  - Tick-box Info
  - Levity info

Synopsis

- data IdDetails
  - = VanillaId
  - | RecSelId {
    - sel_tycon :: RecSelParent
    - sel_naughty :: Bool
    }
  - | DataConWorkId DataCon
  - | DataConWrapId DataCon
  - | ClassOpId Class
  - | PrimOpId PrimOp
  - | FCallId ForeignCall
  - | TickBoxOpId TickBoxOp
  - | DFunId Bool
  - | CoVarId
  - | JoinId JoinArity
- pprIdDetails :: IdDetails -> SDoc
- coVarDetails :: IdDetails
- isCoVarDetails :: IdDetails -> Bool
- type JoinArity = Int
- isJoinIdDetails_maybe :: IdDetails -> Maybe JoinArity
- data RecSelParent
  - = RecSelData TyCon
  - | RecSelPatSyn PatSyn
- data IdInfo
- vanillaIdInfo :: IdInfo
- noCafIdInfo :: IdInfo
- data OneShotInfo
  - = NoOneShotInfo
  - | OneShotLam
- oneShotInfo :: IdInfo -> OneShotInfo
- noOneShotInfo :: OneShotInfo
- hasNoOneShotInfo :: OneShotInfo -> Bool
- setOneShotInfo :: IdInfo -> OneShotInfo -> IdInfo
- zapLamInfo :: IdInfo -> Maybe IdInfo
- zapFragileInfo :: IdInfo -> Maybe IdInfo
- zapDemandInfo :: IdInfo -> Maybe IdInfo
- zapUsageInfo :: IdInfo -> Maybe IdInfo
- zapUsageEnvInfo :: IdInfo -> Maybe IdInfo
- zapUsedOnceInfo :: IdInfo -> Maybe IdInfo
- zapTailCallInfo :: IdInfo -> Maybe IdInfo
- zapCallArityInfo :: IdInfo -> IdInfo
- type ArityInfo = Arity
- unknownArity :: Arity
- arityInfo :: IdInfo -> ArityInfo
- setArityInfo :: IdInfo -> ArityInfo -> IdInfo
- ppArityInfo :: Int -> SDoc
- callArityInfo :: IdInfo -> ArityInfo
- setCallArityInfo :: IdInfo -> ArityInfo -> IdInfo
- strictnessInfo :: IdInfo -> StrictSig
- setStrictnessInfo :: IdInfo -> StrictSig -> IdInfo
- demandInfo :: IdInfo -> Demand
- setDemandInfo :: IdInfo -> Demand -> IdInfo
- pprStrictness :: StrictSig -> SDoc
- unfoldingInfo :: IdInfo -> Unfolding
- setUnfoldingInfo :: IdInfo -> Unfolding -> IdInfo
- type InlinePragInfo = InlinePragma
- inlinePragInfo :: IdInfo -> InlinePragma
- setInlinePragInfo :: IdInfo -> InlinePragma -> IdInfo
- data OccInfo
  - = ManyOccs {
    - occ_tail :: !TailCallInfo
    }
  - | IAmDead
  - | OneOcc {
    - occ_in_lam :: !InsideLam
    - occ_one_br :: !OneBranch
    - occ_int_cxt :: !InterestingCxt
    - occ_tail :: !TailCallInfo
    }
  - | IAmALoopBreaker {
    - occ_rules_only :: !RulesOnly
    - occ_tail :: !TailCallInfo
    }
- isDeadOcc :: OccInfo -> Bool
- isStrongLoopBreaker :: OccInfo -> Bool
- isWeakLoopBreaker :: OccInfo -> Bool
- occInfo :: IdInfo -> OccInfo
- setOccInfo :: IdInfo -> OccInfo -> IdInfo
- type InsideLam = Bool
- type OneBranch = Bool
- insideLam :: InsideLam
- notInsideLam :: InsideLam
- oneBranch :: OneBranch
- notOneBranch :: OneBranch
- data TailCallInfo
  - = AlwaysTailCalled JoinArity
  - | NoTailCallInfo
- tailCallInfo :: OccInfo -> TailCallInfo
- isAlwaysTailCalled :: OccInfo -> Bool
- data RuleInfo = RuleInfo [CoreRule] DVarSet
- emptyRuleInfo :: RuleInfo
- isEmptyRuleInfo :: RuleInfo -> Bool
- ruleInfoFreeVars :: RuleInfo -> DVarSet
- ruleInfoRules :: RuleInfo -> [CoreRule]
- setRuleInfoHead :: Name -> RuleInfo -> RuleInfo
- ruleInfo :: IdInfo -> RuleInfo
- setRuleInfo :: IdInfo -> RuleInfo -> IdInfo
- data CafInfo
  - = MayHaveCafRefs
  - | NoCafRefs
- ppCafInfo :: CafInfo -> SDoc
- mayHaveCafRefs :: CafInfo -> Bool
- cafInfo :: IdInfo -> CafInfo
- setCafInfo :: IdInfo -> CafInfo -> IdInfo
- data TickBoxOp = TickBox Module !TickBoxId
- type TickBoxId = Int
- data LevityInfo
- levityInfo :: IdInfo -> LevityInfo
- setNeverLevPoly :: HasDebugCallStack => IdInfo -> Type -> IdInfo
- setLevityInfoWithType :: IdInfo -> Type -> IdInfo
- isNeverLevPolyIdInfo :: IdInfo -> Bool

# The IdDetails type

data IdDetails Source #

Identifier Details

The `IdDetails` of an `Id` give stable, and necessary, information about the Id.

Constructors

VanillaId |
RecSelId | The `Id` for a record selector
Fields sel_tycon :: RecSelParent sel_naughty :: Bool
DataConWorkId DataCon | The `Id` is for a data constructor worker
DataConWrapId DataCon | The `Id` is for a data constructor wrapper
ClassOpId Class | The `Id` is a superclass selector, or class operation of a class
PrimOpId PrimOp | The `Id` is for a primitive operator
FCallId ForeignCall | The `Id` is for a foreign call. Type will be simple: no type families, newtypes, etc
TickBoxOpId TickBoxOp | The `Id` is for a HPC tick box (both traditional and binary)
DFunId Bool | A dictionary function. Bool = True = the class has only one method, so may be implemented with a newtype, so it might be bad to be strict on this dictionary
CoVarId | A coercion variable This only covers un-lifted coercions, of type (t1 ~ t2), not their lifted variants
JoinId JoinArity | An `Id` for a join point taking n arguments Note [Join points] in CoreSyn

Instances

Outputable IdDetails # |
Methods ppr :: IdDetails -> SDoc Source # pprPrec :: Rational -> IdDetails -> SDoc Source #

pprIdDetails :: IdDetails -> SDoc Source #

coVarDetails :: IdDetails Source #

Just a synonym for `CoVarId`. Written separately so it can be exported in the hs-boot file.

isCoVarDetails :: IdDetails -> Bool Source #

Check if an `IdDetails` says `CoVarId`.

type JoinArity = Int Source #

The number of arguments that a join point takes. Unlike the arity of a function, this is a purely syntactic property and is fixed when the join point is created (or converted from a value). Both type and value arguments are counted.

isJoinIdDetails_maybe :: IdDetails -> Maybe JoinArity Source #

data RecSelParent Source #

Recursive Selector Parent

Constructors

RecSelData TyCon |
RecSelPatSyn PatSyn |

Instances

Eq RecSelParent # |
Methods (==) :: RecSelParent -> RecSelParent -> Bool # (/=) :: RecSelParent -> RecSelParent -> Bool #
Outputable RecSelParent # |
Methods ppr :: RecSelParent -> SDoc Source # pprPrec :: Rational -> RecSelParent -> SDoc Source #

# The IdInfo type

data IdInfo Source #

Identifier Information

An `IdInfo` gives optional information about an `Id`. If present it never lies, but it may not be present, in which case there is always a conservative assumption which can be made.

Two `Id`s may have different info even though they have the same `Unique` (and are hence the same `Id`); for example, one might lack the properties attached to the other.

Most of the `IdInfo` gives information about the value, or definition, of the `Id`, independent of its usage. Exceptions to this are `demandInfo`, `occInfo`, `oneShotInfo` and `callArityInfo`.

Performance note: when we update `IdInfo`, we have to reallocate this entire record, so it is a good idea not to let this data structure get too big.

vanillaIdInfo :: IdInfo Source #

Basic `IdInfo` that carries no useful information whatsoever

noCafIdInfo :: IdInfo Source #

More informative `IdInfo` we can use when we know the `Id` has no CAF references

## The OneShotInfo type

data OneShotInfo Source #

If the `Id` is a lambda-bound variable then it may have lambda-bound variable info. Sometimes we know whether the lambda binding this variable is a "one-shot" lambda; that is, whether it is applied at most once.

This information may be useful in optimisation, as computations may safely be floated inside such a lambda without risk of duplicating work.

Constructors

NoOneShotInfo | No information
OneShotLam | The lambda is applied at most once.

Instances

Eq OneShotInfo # |
Methods (==) :: OneShotInfo -> OneShotInfo -> Bool # (/=) :: OneShotInfo -> OneShotInfo -> Bool #
Outputable OneShotInfo # |
Methods ppr :: OneShotInfo -> SDoc Source # pprPrec :: Rational -> OneShotInfo -> SDoc Source #

oneShotInfo :: IdInfo -> OneShotInfo Source #

Info about a lambda-bound variable, if the `Id` is one

noOneShotInfo :: OneShotInfo Source #

It is always safe to assume that an `Id` has no lambda-bound variable information

hasNoOneShotInfo :: OneShotInfo -> Bool Source #

setOneShotInfo :: IdInfo -> OneShotInfo -> IdInfo infixl 1 Source #

## Zapping various forms of Info

zapLamInfo :: IdInfo -> Maybe IdInfo Source #

This is used to remove information on lambda binders that we have setup as part of a lambda group, assuming they will be applied all at once, but turn out to be part of an unsaturated lambda as in e.g:

    (\x1. \x2. e) arg1

zapFragileInfo :: IdInfo -> Maybe IdInfo Source #

Zap info that depends on free variables

zapDemandInfo :: IdInfo -> Maybe IdInfo Source #

Remove all demand info on the `IdInfo`

zapUsageInfo :: IdInfo -> Maybe IdInfo Source #

Remove usage (but not strictness) info on the `IdInfo`

zapUsageEnvInfo :: IdInfo -> Maybe IdInfo Source #

Remove usage environment info from the strictness signature on the `IdInfo`

zapUsedOnceInfo :: IdInfo -> Maybe IdInfo Source #

zapTailCallInfo :: IdInfo -> Maybe IdInfo Source #

zapCallArityInfo :: IdInfo -> IdInfo Source #

## The ArityInfo type

type ArityInfo = Arity Source #

Arity Information

An `ArityInfo` of `n` tells us that partial application of this `Id` to up to `n-1` value arguments does essentially no work.

That is not necessarily the same as saying that it has `n` leading lambdas, because coerces may get in the way.

The arity might increase later in the compilation process, if an extra lambda floats up to the binding site.

unknownArity :: Arity Source #

It is always safe to assume that an `Id` has an arity of 0

arityInfo :: IdInfo -> ArityInfo Source #

`Id` arity

setArityInfo :: IdInfo -> ArityInfo -> IdInfo infixl 1 Source #

ppArityInfo :: Int -> SDoc Source #

callArityInfo :: IdInfo -> ArityInfo Source #

How this is called. n = all calls have at least n arguments

setCallArityInfo :: IdInfo -> ArityInfo -> IdInfo Source #

## Demand and strictness Info

strictnessInfo :: IdInfo -> StrictSig Source #

setStrictnessInfo :: IdInfo -> StrictSig -> IdInfo infixl 1 Source #

demandInfo :: IdInfo -> Demand Source #

ID demand information

setDemandInfo :: IdInfo -> Demand -> IdInfo infixl 1 Source #

pprStrictness :: StrictSig -> SDoc Source #

## Unfolding Info

unfoldingInfo :: IdInfo -> Unfolding Source #

The `Id`s unfolding

setUnfoldingInfo :: IdInfo -> Unfolding -> IdInfo infixl 1 Source #

## The InlinePragInfo type

type InlinePragInfo = InlinePragma Source #

Inline Pragma Information

Tells when the inlining is active. When it is active the thing may be inlined, depending on how big it is.

If there was an `INLINE` pragma, then as a separate matter, the RHS will have been made to look small with a Core inline `Note`

The default `InlinePragInfo` is `AlwaysActive`, so the info serves entirely as a way to inhibit inlining until we want it

inlinePragInfo :: IdInfo -> InlinePragma Source #

Any inline pragma atached to the `Id`

setInlinePragInfo :: IdInfo -> InlinePragma -> IdInfo infixl 1 Source #

## The OccInfo type

data OccInfo Source #

identifier Occurrence Information

Constructors

ManyOccs | There are many occurrences, or unknown occurrences
Fields occ_tail :: !TailCallInfo
IAmDead | Marks unused variables. Sometimes useful for lambda and case-bound variables.
OneOcc | Occurs exactly once (per branch), not inside a rule
Fields occ_in_lam :: !InsideLam occ_one_br :: !OneBranch occ_int_cxt :: !InterestingCxt occ_tail :: !TailCallInfo
IAmALoopBreaker | This identifier breaks a loop of mutually recursive functions. The field marks whether it is only a loop breaker due to a reference in a rule
Fields occ_rules_only :: !RulesOnly occ_tail :: !TailCallInfo

Instances

Eq OccInfo # |
Methods (==) :: OccInfo -> OccInfo -> Bool # (/=) :: OccInfo -> OccInfo -> Bool #
Outputable OccInfo # |
Methods ppr :: OccInfo -> SDoc Source # pprPrec :: Rational -> OccInfo -> SDoc Source #

isDeadOcc :: OccInfo -> Bool Source #

isStrongLoopBreaker :: OccInfo -> Bool Source #

isWeakLoopBreaker :: OccInfo -> Bool Source #

occInfo :: IdInfo -> OccInfo Source #

How the `Id` occurs in the program

setOccInfo :: IdInfo -> OccInfo -> IdInfo infixl 1 Source #

type InsideLam = Bool Source #

Inside Lambda

type OneBranch = Bool Source #

insideLam :: InsideLam Source #

notInsideLam :: InsideLam Source #

oneBranch :: OneBranch Source #

notOneBranch :: OneBranch Source #

data TailCallInfo Source #

Constructors

AlwaysTailCalled JoinArity |
NoTailCallInfo |

Instances

Eq TailCallInfo # |
Methods (==) :: TailCallInfo -> TailCallInfo -> Bool # (/=) :: TailCallInfo -> TailCallInfo -> Bool #
Outputable TailCallInfo # |
Methods ppr :: TailCallInfo -> SDoc Source # pprPrec :: Rational -> TailCallInfo -> SDoc Source #

tailCallInfo :: OccInfo -> TailCallInfo Source #

isAlwaysTailCalled :: OccInfo -> Bool Source #

## The RuleInfo type

data RuleInfo Source #

Rule Information

Records the specializations of this `Id` that we know about in the form of rewrite `CoreRule`s that target them

Constructors

RuleInfo [CoreRule] DVarSet |

emptyRuleInfo :: RuleInfo Source #

Assume that no specilizations exist: always safe

isEmptyRuleInfo :: RuleInfo -> Bool Source #

ruleInfoFreeVars :: RuleInfo -> DVarSet Source #

Retrieve the locally-defined free variables of both the left and right hand sides of the specialization rules

ruleInfoRules :: RuleInfo -> [CoreRule] Source #

setRuleInfoHead :: Name -> RuleInfo -> RuleInfo Source #

Change the name of the function the rule is keyed on on all of the `CoreRule`s

ruleInfo :: IdInfo -> RuleInfo Source #

Specialisations of the `Id`s function which exist See Note [Specialisations and RULES in IdInfo]

setRuleInfo :: IdInfo -> RuleInfo -> IdInfo infixl 1 Source #

## The CAFInfo type

data CafInfo Source #

Constant applicative form Information

Records whether an `Id` makes Constant Applicative Form references

Constructors

MayHaveCafRefs | Indicates that the `Id` is for either: A function or static constructor that refers to one or more CAFs, or A real live CAF
NoCafRefs | A function or static constructor that refers to no CAFs.

Instances

Eq CafInfo # |
Methods (==) :: CafInfo -> CafInfo -> Bool # (/=) :: CafInfo -> CafInfo -> Bool #
Ord CafInfo # |
Methods compare :: CafInfo -> CafInfo -> Ordering # (<) :: CafInfo -> CafInfo -> Bool # (<=) :: CafInfo -> CafInfo -> Bool # (>) :: CafInfo -> CafInfo -> Bool # (>=) :: CafInfo -> CafInfo -> Bool # max :: CafInfo -> CafInfo -> CafInfo # min :: CafInfo -> CafInfo -> CafInfo #
Outputable CafInfo # |
Methods ppr :: CafInfo -> SDoc Source # pprPrec :: Rational -> CafInfo -> SDoc Source #

ppCafInfo :: CafInfo -> SDoc Source #

mayHaveCafRefs :: CafInfo -> Bool Source #

cafInfo :: IdInfo -> CafInfo Source #

`Id` CAF info

setCafInfo :: IdInfo -> CafInfo -> IdInfo infixl 1 Source #

## Tick-box Info

data TickBoxOp Source #

Tick box for Hpc-style coverage

Constructors

TickBox Module !TickBoxId |

Instances

Outputable TickBoxOp # |
Methods ppr :: TickBoxOp -> SDoc Source # pprPrec :: Rational -> TickBoxOp -> SDoc Source #

type TickBoxId = Int Source #

## Levity info

data LevityInfo Source #

Instances

Eq LevityInfo # |
Methods (==) :: LevityInfo -> LevityInfo -> Bool # (/=) :: LevityInfo -> LevityInfo -> Bool #
Outputable LevityInfo # |
Methods ppr :: LevityInfo -> SDoc Source # pprPrec :: Rational -> LevityInfo -> SDoc Source #

levityInfo :: IdInfo -> LevityInfo Source #

when applied, will this Id ever have a levity-polymorphic type?

setNeverLevPoly :: HasDebugCallStack => IdInfo -> Type -> IdInfo infixl 1 Source #

Marks an IdInfo describing an Id that is never levity polymorphic (even when applied). The Type is only there for checking that it's really never levity polymorphic

setLevityInfoWithType :: IdInfo -> Type -> IdInfo infixl 1 Source #

isNeverLevPolyIdInfo :: IdInfo -> Bool Source #