ghc-8.0.2: The GHC API

Safe HaskellNone
LanguageHaskell2010

IdInfo

Contents

Synopsis

The IdDetails type

data IdDetails #

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

Constructors

VanillaId 
RecSelId

The Id for a record selector

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

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

coVarDetails :: IdDetails #

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

The IdInfo type

data IdInfo #

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 Ids 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.

vanillaIdInfo :: IdInfo #

Basic IdInfo that carries no useful information whatsoever

noCafIdInfo :: IdInfo #

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

The OneShotInfo type

data OneShotInfo #

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

ProbOneShot

The lambda is probably applied at most once See Note [Computing one-shot info, and ProbOneShot] in Demand

OneShotLam

The lambda is applied at most once.

oneShotInfo :: IdInfo -> OneShotInfo #

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

noOneShotInfo :: OneShotInfo #

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

Zapping various forms of Info

zapLamInfo :: IdInfo -> Maybe IdInfo #

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 #

Zap info that depends on free variables

zapDemandInfo :: IdInfo -> Maybe IdInfo #

Remove all demand info on the IdInfo

zapUsageInfo :: IdInfo -> Maybe IdInfo #

Remove usage (but not strictness) info on the IdInfo

The ArityInfo type

type ArityInfo = Arity #

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 #

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

arityInfo :: IdInfo -> ArityInfo #

Id arity

callArityInfo :: IdInfo -> ArityInfo #

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

Demand and strictness Info

demandInfo :: IdInfo -> Demand #

ID demand information

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

Unfolding Info

unfoldingInfo :: IdInfo -> Unfolding #

The Ids unfolding

The InlinePragInfo type

type InlinePragInfo = InlinePragma #

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 #

Any inline pragma atached to the Id

The OccInfo type

data OccInfo #

Identifier occurrence information

Constructors

NoOccInfo

There are many occurrences, or unknown occurrences

IAmDead

Marks unused variables. Sometimes useful for lambda and case-bound variables.

OneOcc !InsideLam !OneBranch !InterestingCxt

Occurs exactly once, not inside a rule

IAmALoopBreaker !RulesOnly

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

Instances

occInfo :: IdInfo -> OccInfo #

How the Id occurs in the program

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

The RuleInfo type

data RuleInfo #

Records the specializations of this Id that we know about in the form of rewrite CoreRules that target them

Constructors

RuleInfo [CoreRule] DVarSet 

emptyRuleInfo :: RuleInfo #

Assume that no specilizations exist: always safe

ruleInfoFreeVars :: RuleInfo -> DVarSet #

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

setRuleInfoHead :: Name -> RuleInfo -> RuleInfo #

Change the name of the function the rule is keyed on on all of the CoreRules

ruleInfo :: IdInfo -> RuleInfo #

Specialisations of the Ids function which exist See Note [Specialisations and RULES in IdInfo]

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

The CAFInfo type

data CafInfo #

Records whether an Id makes Constant Applicative Form references

Constructors

MayHaveCafRefs

Indicates that the Id is for either:

  1. A function or static constructor that refers to one or more CAFs, or
  2. A real live CAF
NoCafRefs

A function or static constructor that refers to no CAFs.

cafInfo :: IdInfo -> CafInfo #

Id CAF info

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

Tick-box Info

data TickBoxOp #

Tick box for Hpc-style coverage

Constructors

TickBox Module !TickBoxId 

type TickBoxId = Int #