plutus-core-1.60.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusIR.Transform.Inline.Utils

Description

Types and their functions, and general utility (including heuristics) for inlining.

Synopsis

data InlineInfo tyname name uni fun ann #

Information used by the inliner that is constant across its operation. This includes some contextual and configuration information, and also some pre-computed information about the program.

See [Inlining and global uniqueness] for caveats about this information.

Constructors

InlineInfo 

Fields

newtype InlineTerm tyname name uni fun ann #

Substitution range, SubstRng in the paper but no Susp case. See Note [Inlining approach and 'Secrets of the GHC Inliner']

Constructors

Done (Dupable (Term tyname name uni fun ann)) 

newtype TermSubst tyname name uni fun ann #

Term substitution, Subst in the paper. A map of unprocessed variable and its substitution range.

Constructors

TermSubst 

Fields

Instances

Instances details
Monoid (TermSubst tyname name uni fun ann) # 
Instance details

Defined in PlutusIR.Transform.Inline.Utils

Methods

mempty :: TermSubst tyname name uni fun ann #

mappend :: TermSubst tyname name uni fun ann -> TermSubst tyname name uni fun ann -> TermSubst tyname name uni fun ann #

mconcat :: [TermSubst tyname name uni fun ann] -> TermSubst tyname name uni fun ann #

Semigroup (TermSubst tyname name uni fun ann) # 
Instance details

Defined in PlutusIR.Transform.Inline.Utils

Methods

(<>) :: TermSubst tyname name uni fun ann -> TermSubst tyname name uni fun ann -> TermSubst tyname name uni fun ann #

sconcat :: NonEmpty (TermSubst tyname name uni fun ann) -> TermSubst tyname name uni fun ann #

stimes :: Integral b => b -> TermSubst tyname name uni fun ann -> TermSubst tyname name uni fun ann #

newtype TypeSubst tyname uni ann #

Type substitution, similar to TermSubst but for types. A map of unprocessed type variable and its substitution range.

Constructors

TypeSubst 

Fields

Instances

Instances details
Monoid (NonRecInScopeSet tyname name uni fun ann) # 
Instance details

Defined in PlutusIR.Transform.Inline.Utils

Methods

mempty :: NonRecInScopeSet tyname name uni fun ann #

mappend :: NonRecInScopeSet tyname name uni fun ann -> NonRecInScopeSet tyname name uni fun ann -> NonRecInScopeSet tyname name uni fun ann #

mconcat :: [NonRecInScopeSet tyname name uni fun ann] -> NonRecInScopeSet tyname name uni fun ann #

Semigroup (NonRecInScopeSet tyname name uni fun ann) # 
Instance details

Defined in PlutusIR.Transform.Inline.Utils

Methods

(<>) :: NonRecInScopeSet tyname name uni fun ann -> NonRecInScopeSet tyname name uni fun ann -> NonRecInScopeSet tyname name uni fun ann #

sconcat :: NonEmpty (NonRecInScopeSet tyname name uni fun ann) -> NonRecInScopeSet tyname name uni fun ann #

stimes :: Integral b => b -> NonRecInScopeSet tyname name uni fun ann -> NonRecInScopeSet tyname name uni fun ann #

data InlineVarInfo tyname name uni fun ann #

Info attached to a let-binding needed for call site inlining.

Constructors

MkVarInfo 

Fields

data InlinerState tyname name uni fun ann #

Inliner context for both unconditional inlining and call site inlining. It includes substitution for both terms and types, which is similar to Subst in the paper. It also includes the non recursive in-scope set for call site inlining.

Constructors

InlinerState 

Fields

Instances

Instances details
TermUnique 
=> name

The name of the variable.

-> InlineVarInfo tyname name uni fun ann

The variable's info.

-> InlinerState tyname name uni fun ann 
-> InlinerState tyname name uni fun ann 

Insert a variable into the substitution.

applyTypeSubstitution :: forall tyname name uni fun ann. InliningConstraints tyname name uni fun => Type tyname uni ann -> InlineM tyname name uni fun ann (Type tyname uni ann) #

substTyName :: forall tyname name uni fun ann. InliningConstraints tyname name uni fun => tyname -> InlineM tyname name uni fun ann (Maybe (Type tyname uni ann)) #

substName :: forall tyname name uni fun ann. InliningConstraints tyname name uni fun => name -> InlineM tyname name uni fun ann (Maybe (Term tyname name uni fun ann)) #

renameTerm :: forall tyname name uni fun ann. InliningConstraints tyname name uni fun => InlineTerm tyname name uni fun ann -> InlineM tyname name uni fun ann (Term tyname name uni fun ann) #

checkPurity :: forall tyname name uni fun ann. InliningConstraints tyname name uni fun => Term tyname name uni fun ann -> InlineM tyname name uni fun ann Bool #

Check if term is pure. See Note [Inlining and purity]

isFirstVarBeforeEffects :: forall tyname name uni fun ann. InliningConstraints tyname name uni fun => name -> Term tyname name uni fun ann -> InlineM tyname name uni fun ann Bool #

isTermBindingPure :: forall tyname name uni fun ann. InliningConstraints tyname name uni fun => Strictness -> Term tyname name uni fun ann -> InlineM tyname name uni fun ann Bool #

Checks if a binding is pure, i.e. will evaluating it have effects

nameUsedAtMostOnce :: forall tyname name uni fun ann. InliningConstraints tyname name uni fun => name -> InlineM tyname name uni fun ann Bool #

effectSafe #

Arguments

:: forall tyname name uni fun ann. InliningConstraints tyname name uni fun 
=> Term tyname name uni fun ann 
-> Strictness 
-> name 
-> Bool

is it pure?

-> InlineM tyname name uni fun ann Bool 

costIsAcceptable :: Term tyname name uni fun ann -> Bool #

Is the cost increase (in terms of evaluation work) of inlining a variable whose RHS is the given term acceptable?

sizeIsAcceptable :: Bool -> Term tyname name uni fun ann -> Bool #

Is the size increase (in the AST) of inlining a variable whose RHS is the given term acceptable?

trivialType :: Type tyname uni ann -> Bool #

Is this an utterly trivial type which might as well be inlined?

shouldUnconditionallyInline #

Arguments

:: InliningConstraints tyname name uni fun 
=> Bool

Whether we know that the binding is safe to inline. If so, bypass the purity check.

-> Strictness 
-> name 
-> Term tyname name uni fun ann 
-> Term tyname name uni fun ann 
-> InlineM tyname name uni fun ann Bool