GHC.Core.Unfold

ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Core.Unfold

Synopsis

- data Unfolding
- data UnfoldingGuidance
- data ExprSize
  - = TooBig
  - | SizeIs {
    - _es_size_is :: !Int
    - _es_args :: !(Bag (Id, Int))
    - _es_discount :: !Int
    }
- sizeExpr :: UnfoldingOpts -> Int -> [Id] -> CoreExpr -> ExprSize
- data ArgSummary
  - = TrivArg
  - | NonTrivArg
  - | ValueArg
- nonTriv :: ArgSummary -> Bool
- data CallCtxt
  - = BoringCtxt
  - | RhsCtxt RecFlag
  - | DiscArgCtxt
  - | RuleArgCtxt
  - | ValAppCtxt
  - | CaseCtxt
- data UnfoldingOpts = UnfoldingOpts {
  - unfoldingCreationThreshold :: !Int
  - unfoldingUseThreshold :: !Int
  - unfoldingFunAppDiscount :: !Int
  - unfoldingDictDiscount :: !Int
  - unfoldingVeryAggressive :: !Bool
  - unfoldingCaseThreshold :: !Int
  - unfoldingCaseScaling :: !Int
  - unfoldingReportPrefix :: !(Maybe String)
  }
- defaultUnfoldingOpts :: UnfoldingOpts
- updateCreationThreshold :: Int -> UnfoldingOpts -> UnfoldingOpts
- updateUseThreshold :: Int -> UnfoldingOpts -> UnfoldingOpts
- updateFunAppDiscount :: Int -> UnfoldingOpts -> UnfoldingOpts
- updateDictDiscount :: Int -> UnfoldingOpts -> UnfoldingOpts
- updateVeryAggressive :: Bool -> UnfoldingOpts -> UnfoldingOpts
- updateCaseScaling :: Int -> UnfoldingOpts -> UnfoldingOpts
- updateCaseThreshold :: Int -> UnfoldingOpts -> UnfoldingOpts
- updateReportPrefix :: Maybe String -> UnfoldingOpts -> UnfoldingOpts
- inlineBoringOk :: CoreExpr -> Bool
- calcUnfoldingGuidance :: UnfoldingOpts -> Bool -> Bool -> CoreExpr -> UnfoldingGuidance
- uncondInlineJoin :: [Var] -> CoreExpr -> Bool

# Documentation

data Unfolding #

Records the unfolding of an identifier, which is approximately the form the identifier would have if we substituted its definition in for the identifier. This type should be treated as abstract everywhere except in GHC.Core.Unfold

#### Instances

Instances details

Outputable Unfolding # |
Instance details Defined in GHC.Core.Ppr Methods ppr :: Unfolding -> SDoc #

data UnfoldingGuidance #

`UnfoldingGuidance` says when unfolding should take place

#### Instances

Instances details

Outputable UnfoldingGuidance # |
Instance details Defined in GHC.Core.Ppr Methods ppr :: UnfoldingGuidance -> SDoc #
Eq UnfoldingGuidance # |
Instance details Defined in GHC.Core Methods (==) :: UnfoldingGuidance -> UnfoldingGuidance -> Bool # (/=) :: UnfoldingGuidance -> UnfoldingGuidance -> Bool #

data ExprSize #

The size of a candidate expression for unfolding

Constructors

TooBig |
SizeIs |
Fields _es_size_is :: !Int Size found _es_args :: !(Bag (Id, Int)) Arguments cased herein, and discount for each such _es_discount :: !Int Size to subtract if result is scrutinised by a case expression

#### Instances

Instances details

Outputable ExprSize # |
Instance details Defined in GHC.Core.Unfold Methods ppr :: ExprSize -> SDoc #

sizeExpr :: UnfoldingOpts -> Int -> [Id] -> CoreExpr -> ExprSize #

data ArgSummary #

Constructors

TrivArg |
NonTrivArg |
ValueArg |

#### Instances

Instances details

Outputable ArgSummary # |
Instance details Defined in GHC.Core.Unfold Methods ppr :: ArgSummary -> SDoc #

nonTriv :: ArgSummary -> Bool #

data CallCtxt #

Constructors

BoringCtxt |
RhsCtxt RecFlag |
DiscArgCtxt |
RuleArgCtxt |
ValAppCtxt |
CaseCtxt |

#### Instances

Instances details

Outputable CallCtxt # |
Instance details Defined in GHC.Core.Unfold Methods ppr :: CallCtxt -> SDoc #

data UnfoldingOpts #

Unfolding options

Constructors

UnfoldingOpts |
Fields unfoldingCreationThreshold :: !Int Threshold above which unfoldings are not *created* unfoldingUseThreshold :: !Int Threshold above which unfoldings are not *inlined* unfoldingFunAppDiscount :: !Int Discount for lambdas that are used (applied) unfoldingDictDiscount :: !Int Discount for dictionaries unfoldingVeryAggressive :: !Bool Force inlining in many more cases unfoldingCaseThreshold :: !Int Don't consider depth up to x unfoldingCaseScaling :: !Int Penalize depth with 1/x unfoldingReportPrefix :: !(Maybe String) Only report inlining decisions for names with this prefix

defaultUnfoldingOpts :: UnfoldingOpts #

updateCreationThreshold :: Int -> UnfoldingOpts -> UnfoldingOpts #

updateUseThreshold :: Int -> UnfoldingOpts -> UnfoldingOpts #

updateFunAppDiscount :: Int -> UnfoldingOpts -> UnfoldingOpts #

updateDictDiscount :: Int -> UnfoldingOpts -> UnfoldingOpts #

updateVeryAggressive :: Bool -> UnfoldingOpts -> UnfoldingOpts #

updateCaseScaling :: Int -> UnfoldingOpts -> UnfoldingOpts #

updateCaseThreshold :: Int -> UnfoldingOpts -> UnfoldingOpts #

updateReportPrefix :: Maybe String -> UnfoldingOpts -> UnfoldingOpts #

inlineBoringOk :: CoreExpr -> Bool #

calcUnfoldingGuidance :: UnfoldingOpts -> Bool -> Bool -> CoreExpr -> UnfoldingGuidance #

uncondInlineJoin :: [Var] -> CoreExpr -> Bool #