GHC.Core.Opt.Simplify.Env

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

Safe Haskell | Ignore
Language | GHC2021

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 JoinPointHood
  - | 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 #

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 # |
Instance details Defined in GHC.Core.Opt.Simplify.Env Methods ppr :: SimplMode -> SDoc #

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

smPedanticBottoms :: SimplMode -> Bool #

smPlatform :: SimplMode -> Platform #

# Environments

data SimplEnv #

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 #

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) #

# Substitution results

data SimplSR #

A substitution result.

Constructors

DoneEx OutExpr JoinPointHood |
DoneId OutId |
ContEx TvSubstEnv CvSubstEnv SimplIdSubst InExpr |

#### Instances

Instances details

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

mkContEx :: SimplEnv -> InExpr -> SimplSR #

substId :: SimplEnv -> InId -> SimplSR #

lookupRecBndr :: SimplEnv -> InId -> OutId #

# Simplifying `Id` binders

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 #

# Floats

data SimplFloats #

Constructors

SimplFloats |
Fields sfLetFloats :: LetFloats sfJoinFloats :: JoinFloats sfInScope :: InScopeSet

#### Instances

Instances details

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

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] #

# LetFloats

data LetFloats #

#### Instances

Instances details

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

data FloatEnable #

Constructors

FloatDisabled |
FloatNestedOnly |
FloatEnabled |

letFloatBinds :: LetFloats -> [CoreBind] #

emptyLetFloats :: LetFloats #

unitLetFloat :: OutBind -> LetFloats #

addLetFlts :: LetFloats -> LetFloats -> LetFloats #

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

# JoinFloats

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 #