ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Core.Opt.Simplify.Env

Contents

- The simplifier mode
- Environments
- Substitution results
- Simplifying `Id` binders
- Floats
- LetFloats
- JoinFloats

Synopsis

- data SimplMode = SimplMode {
  - sm_phase :: !CompilerPhase
  - sm_names :: ![String]
  - sm_rules :: !Bool
  - sm_inline :: !Bool
  - sm_eta_expand :: !Bool
  - sm_cast_swizzle :: !Bool
  - sm_uf_opts :: !UnfoldingOpts
  - sm_case_case :: !Bool
  - sm_pre_inline :: !Bool
  - sm_float_enable :: !FloatEnable
  - sm_do_eta_reduction :: !Bool
  - sm_arity_opts :: !ArityOpts
  - sm_rule_opts :: !RuleOpts
  - sm_case_folding :: !Bool
  - sm_case_merge :: !Bool
  - sm_co_opt_opts :: !OptCoercionOpts
  }
- updMode :: (SimplMode -> SimplMode) -> SimplEnv -> SimplEnv
- smPedanticBottoms :: SimplMode -> Bool
- smPlatform :: SimplMode -> Platform
- data SimplEnv = SimplEnv {
  - seMode :: !SimplMode
  - seFamEnvs :: !(FamInstEnv, FamInstEnv)
  - seTvSubst :: TvSubstEnv
  - seCvSubst :: CvSubstEnv
  - seIdSubst :: SimplIdSubst
  - seRecIds :: !UnVarSet
  - seInScope :: !InScopeSet
  - seCaseDepth :: !Int
  }
- pprSimplEnv :: SimplEnv -> SDoc
- seArityOpts :: SimplEnv -> ArityOpts
- seCaseCase :: SimplEnv -> Bool
- seCaseFolding :: SimplEnv -> Bool
- seCaseMerge :: SimplEnv -> Bool
- seCastSwizzle :: SimplEnv -> Bool
- seDoEtaReduction :: SimplEnv -> Bool
- seEtaExpand :: SimplEnv -> Bool
- seFloatEnable :: SimplEnv -> FloatEnable
- seInline :: SimplEnv -> Bool
- seNames :: SimplEnv -> [String]
- seOptCoercionOpts :: SimplEnv -> OptCoercionOpts
- sePedanticBottoms :: SimplEnv -> Bool
- sePhase :: SimplEnv -> CompilerPhase
- sePlatform :: SimplEnv -> Platform
- sePreInline :: SimplEnv -> Bool
- seRuleOpts :: SimplEnv -> RuleOpts
- seRules :: SimplEnv -> Bool
- seUnfoldingOpts :: SimplEnv -> UnfoldingOpts
- mkSimplEnv :: SimplMode -> (FamInstEnv, FamInstEnv) -> SimplEnv
- extendIdSubst :: SimplEnv -> Id -> SimplSR -> SimplEnv
- extendTvSubst :: SimplEnv -> TyVar -> Type -> SimplEnv
- extendCvSubst :: SimplEnv -> CoVar -> Coercion -> SimplEnv
- zapSubstEnv :: SimplEnv -> SimplEnv
- setSubstEnv :: SimplEnv -> TvSubstEnv -> CvSubstEnv -> SimplIdSubst -> SimplEnv
- bumpCaseDepth :: SimplEnv -> SimplEnv
- getInScope :: SimplEnv -> InScopeSet
- setInScopeFromE :: SimplEnv -> SimplEnv -> SimplEnv
- setInScopeFromF :: SimplEnv -> SimplFloats -> SimplEnv
- setInScopeSet :: SimplEnv -> InScopeSet -> SimplEnv
- modifyInScope :: SimplEnv -> CoreBndr -> SimplEnv
- addNewInScopeIds :: SimplEnv -> [CoreBndr] -> SimplEnv
- getSimplRules :: SimplM RuleEnv
- enterRecGroupRHSs :: SimplEnv -> [OutBndr] -> (SimplEnv -> SimplM (r, SimplEnv)) -> SimplM (r, SimplEnv)
- data SimplSR
  - = DoneEx OutExpr (Maybe JoinArity)
  - | DoneId OutId
  - | ContEx TvSubstEnv CvSubstEnv SimplIdSubst InExpr
- mkContEx :: SimplEnv -> InExpr -> SimplSR
- substId :: SimplEnv -> InId -> SimplSR
- lookupRecBndr :: SimplEnv -> InId -> OutId
- simplNonRecBndr :: SimplEnv -> InBndr -> SimplM (SimplEnv, OutBndr)
- simplNonRecJoinBndr :: SimplEnv -> InBndr -> Mult -> OutType -> SimplM (SimplEnv, OutBndr)
- simplRecBndrs :: SimplEnv -> [InBndr] -> SimplM SimplEnv
- simplRecJoinBndrs :: SimplEnv -> [InBndr] -> Mult -> OutType -> SimplM SimplEnv
- simplBinder :: SimplEnv -> InBndr -> SimplM (SimplEnv, OutBndr)
- simplBinders :: SimplEnv -> [InBndr] -> SimplM (SimplEnv, [OutBndr])
- substTy :: HasDebugCallStack => SimplEnv -> Type -> Type
- substTyVar :: SimplEnv -> TyVar -> Type
- getSubst :: SimplEnv -> Subst
- substCo :: SimplEnv -> Coercion -> Coercion
- substCoVar :: SimplEnv -> CoVar -> Coercion
- data SimplFloats = SimplFloats {
  - sfLetFloats :: LetFloats
  - sfJoinFloats :: JoinFloats
  - sfInScope :: InScopeSet
  }
- emptyFloats :: SimplEnv -> SimplFloats
- isEmptyFloats :: SimplFloats -> Bool
- mkRecFloats :: SimplFloats -> SimplFloats
- mkFloatBind :: SimplEnv -> OutBind -> (SimplFloats, SimplEnv)
- addLetFloats :: SimplFloats -> LetFloats -> SimplFloats
- addJoinFloats :: SimplFloats -> JoinFloats -> SimplFloats
- addFloats :: SimplFloats -> SimplFloats -> SimplFloats
- extendFloats :: SimplFloats -> OutBind -> SimplFloats
- wrapFloats :: SimplFloats -> OutExpr -> OutExpr
- isEmptyJoinFloats :: JoinFloats -> Bool
- isEmptyLetFloats :: LetFloats -> Bool
- doFloatFromRhs :: FloatEnable -> TopLevelFlag -> RecFlag -> Bool -> SimplFloats -> OutExpr -> Bool
- getTopFloatBinds :: SimplFloats -> [CoreBind]
- data LetFloats
- data FloatEnable
  - = FloatDisabled
  - | FloatNestedOnly
  - | FloatEnabled
- letFloatBinds :: LetFloats -> [CoreBind]
- emptyLetFloats :: LetFloats
- unitLetFloat :: OutBind -> LetFloats
- addLetFlts :: LetFloats -> LetFloats -> LetFloats
- mapLetFloats :: LetFloats -> ((Id, CoreExpr) -> (Id, CoreExpr)) -> LetFloats
- type JoinFloat = OutBind
- type JoinFloats = OrdList JoinFloat
- emptyJoinFloats :: JoinFloats
- wrapJoinFloats :: JoinFloats -> OutExpr -> OutExpr
- wrapJoinFloatsX :: SimplFloats -> OutExpr -> (SimplFloats, OutExpr)
- unitJoinFloat :: OutBind -> JoinFloats
- addJoinFlts :: JoinFloats -> JoinFloats -> JoinFloats

# The simplifier mode

data SimplMode Source #

Constructors

SimplMode |

Fields

- sm_phase :: !CompilerPhase
- sm_names :: ![String]

  Name(s) of the phase

- sm_rules :: !Bool

  Whether RULES are enabled

- sm_inline :: !Bool

  Whether inlining is enabled

- sm_eta_expand :: !Bool

  Whether eta-expansion is enabled

- sm_cast_swizzle :: !Bool

  Do we swizzle casts past lambdas?

- sm_uf_opts :: !UnfoldingOpts

  Unfolding options

- sm_case_case :: !Bool

  Whether case-of-case is enabled

- sm_pre_inline :: !Bool

  Whether pre-inlining is enabled

- sm_float_enable :: !FloatEnable

  Whether to enable floating out

- sm_do_eta_reduction :: !Bool
- sm_arity_opts :: !ArityOpts
- sm_rule_opts :: !RuleOpts
- sm_case_folding :: !Bool
- sm_case_merge :: !Bool
- sm_co_opt_opts :: !OptCoercionOpts

  Coercion optimiser options

#### Instances

Instances details

Outputable SimplMode Source # |
Instance details Defined in GHC.Core.Opt.Simplify.Env Methods ppr :: SimplMode -> SDoc Source #

updMode :: (SimplMode -> SimplMode) -> SimplEnv -> SimplEnv Source #

smPedanticBottoms :: SimplMode -> Bool Source #

smPlatform :: SimplMode -> Platform Source #

# Environments

data SimplEnv Source #

Constructors

SimplEnv |

Fields

- seMode :: !SimplMode
- seFamEnvs :: !(FamInstEnv, FamInstEnv)
- seTvSubst :: TvSubstEnv
- seCvSubst :: CvSubstEnv
- seIdSubst :: SimplIdSubst
- seRecIds :: !UnVarSet

  Fast OutVarSet tracking which recursive RHSs we are analysing. See Note [Eta reduction in recursive RHSs] in GHC.Core.Opt.Arity.

- seInScope :: !InScopeSet
- seCaseDepth :: !Int

pprSimplEnv :: SimplEnv -> SDoc Source #

seArityOpts :: SimplEnv -> ArityOpts Source #

seCaseCase :: SimplEnv -> Bool Source #

seCaseFolding :: SimplEnv -> Bool Source #

seCaseMerge :: SimplEnv -> Bool Source #

seCastSwizzle :: SimplEnv -> Bool Source #

seDoEtaReduction :: SimplEnv -> Bool Source #

seEtaExpand :: SimplEnv -> Bool Source #

seFloatEnable :: SimplEnv -> FloatEnable Source #

seInline :: SimplEnv -> Bool Source #

seNames :: SimplEnv -> [String] Source #

seOptCoercionOpts :: SimplEnv -> OptCoercionOpts Source #

sePedanticBottoms :: SimplEnv -> Bool Source #

sePhase :: SimplEnv -> CompilerPhase Source #

sePlatform :: SimplEnv -> Platform Source #

sePreInline :: SimplEnv -> Bool Source #

seRuleOpts :: SimplEnv -> RuleOpts Source #

seRules :: SimplEnv -> Bool Source #

seUnfoldingOpts :: SimplEnv -> UnfoldingOpts Source #

mkSimplEnv :: SimplMode -> (FamInstEnv, FamInstEnv) -> SimplEnv Source #

extendIdSubst :: SimplEnv -> Id -> SimplSR -> SimplEnv Source #

extendTvSubst :: SimplEnv -> TyVar -> Type -> SimplEnv Source #

extendCvSubst :: SimplEnv -> CoVar -> Coercion -> SimplEnv Source #

zapSubstEnv :: SimplEnv -> SimplEnv Source #

setSubstEnv :: SimplEnv -> TvSubstEnv -> CvSubstEnv -> SimplIdSubst -> SimplEnv Source #

bumpCaseDepth :: SimplEnv -> SimplEnv Source #

getInScope :: SimplEnv -> InScopeSet Source #

setInScopeFromE :: SimplEnv -> SimplEnv -> SimplEnv Source #

setInScopeFromF :: SimplEnv -> SimplFloats -> SimplEnv Source #

setInScopeSet :: SimplEnv -> InScopeSet -> SimplEnv Source #

modifyInScope :: SimplEnv -> CoreBndr -> SimplEnv Source #

addNewInScopeIds :: SimplEnv -> [CoreBndr] -> SimplEnv Source #

getSimplRules :: SimplM RuleEnv Source #

enterRecGroupRHSs :: SimplEnv -> [OutBndr] -> (SimplEnv -> SimplM (r, SimplEnv)) -> SimplM (r, SimplEnv) Source #

# Substitution results

data SimplSR Source #

A substitution result.

Constructors

DoneEx OutExpr (Maybe JoinArity) |
DoneId OutId |
ContEx TvSubstEnv CvSubstEnv SimplIdSubst InExpr |

#### Instances

Instances details

Outputable SimplSR Source # |
Instance details Defined in GHC.Core.Opt.Simplify.Env Methods ppr :: SimplSR -> SDoc Source #

mkContEx :: SimplEnv -> InExpr -> SimplSR Source #

substId :: SimplEnv -> InId -> SimplSR Source #

lookupRecBndr :: SimplEnv -> InId -> OutId Source #

# Simplifying `Id` binders

simplNonRecBndr :: SimplEnv -> InBndr -> SimplM (SimplEnv, OutBndr) Source #

simplNonRecJoinBndr :: SimplEnv -> InBndr -> Mult -> OutType -> SimplM (SimplEnv, OutBndr) Source #

simplRecBndrs :: SimplEnv -> [InBndr] -> SimplM SimplEnv Source #

simplRecJoinBndrs :: SimplEnv -> [InBndr] -> Mult -> OutType -> SimplM SimplEnv Source #

simplBinder :: SimplEnv -> InBndr -> SimplM (SimplEnv, OutBndr) Source #

simplBinders :: SimplEnv -> [InBndr] -> SimplM (SimplEnv, [OutBndr]) Source #

substTy :: HasDebugCallStack => SimplEnv -> Type -> Type Source #

substTyVar :: SimplEnv -> TyVar -> Type Source #

getSubst :: SimplEnv -> Subst Source #

substCo :: SimplEnv -> Coercion -> Coercion Source #

substCoVar :: SimplEnv -> CoVar -> Coercion Source #

# Floats

data SimplFloats Source #

Constructors

SimplFloats |

Fields

- sfLetFloats :: LetFloats
- sfJoinFloats :: JoinFloats
- sfInScope :: InScopeSet

#### Instances

Instances details

Outputable SimplFloats Source # |
Instance details Defined in GHC.Core.Opt.Simplify.Env Methods ppr :: SimplFloats -> SDoc Source #

emptyFloats :: SimplEnv -> SimplFloats Source #

isEmptyFloats :: SimplFloats -> Bool Source #

mkRecFloats :: SimplFloats -> SimplFloats Source #

mkFloatBind :: SimplEnv -> OutBind -> (SimplFloats, SimplEnv) Source #

addLetFloats :: SimplFloats -> LetFloats -> SimplFloats Source #

addJoinFloats :: SimplFloats -> JoinFloats -> SimplFloats Source #

addFloats :: SimplFloats -> SimplFloats -> SimplFloats Source #

extendFloats :: SimplFloats -> OutBind -> SimplFloats Source #

wrapFloats :: SimplFloats -> OutExpr -> OutExpr Source #

isEmptyJoinFloats :: JoinFloats -> Bool Source #

isEmptyLetFloats :: LetFloats -> Bool Source #

doFloatFromRhs :: FloatEnable -> TopLevelFlag -> RecFlag -> Bool -> SimplFloats -> OutExpr -> Bool Source #

getTopFloatBinds :: SimplFloats -> [CoreBind] Source #

# LetFloats

data LetFloats Source #

#### Instances

Instances details

Outputable LetFloats Source # |
Instance details Defined in GHC.Core.Opt.Simplify.Env Methods ppr :: LetFloats -> SDoc Source #

data FloatEnable Source #

Constructors

FloatDisabled |
FloatNestedOnly |
FloatEnabled |

letFloatBinds :: LetFloats -> [CoreBind] Source #

emptyLetFloats :: LetFloats Source #

unitLetFloat :: OutBind -> LetFloats Source #

addLetFlts :: LetFloats -> LetFloats -> LetFloats Source #

mapLetFloats :: LetFloats -> ((Id, CoreExpr) -> (Id, CoreExpr)) -> LetFloats Source #

# JoinFloats

type JoinFloat = OutBind Source #

type JoinFloats = OrdList JoinFloat Source #

emptyJoinFloats :: JoinFloats Source #

wrapJoinFloats :: JoinFloats -> OutExpr -> OutExpr Source #

wrapJoinFloatsX :: SimplFloats -> OutExpr -> (SimplFloats, OutExpr) Source #

unitJoinFloat :: OutBind -> JoinFloats Source #

addJoinFlts :: JoinFloats -> JoinFloats -> JoinFloats Source #