diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-05-26 16:11:58 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-17 19:04:50 -0500 |
commit | 4322de246d35091e5e95a3a87fb4c1f9b7a61ee9 (patch) | |
tree | 092cd0e518b59d5fc0d666c6f1bf56e0b3c421c2 /compiler/GHC/Core/Opt | |
parent | f4d50bafb7e14f76273aaf6f634815d5628ccc86 (diff) | |
download | haskell-wip/rules-module.tar.gz |
Split up `GHC.Core` somewhatwip/rules-module
- `GHC.Core.Annotated` now contains annotated Core
- `GHC.Core.Rules` now contains the rules definitions
- `GHC.Core.Orphans` now contains the orphans *something*
- `GHC.Core.Unfoldings` now contains the unfoldings defintions
- The old `GHC.Core.Rules`, which was about applying rules, is now
`GHC.Core.Rules.Apply`. Compare with `GHC.Core.Simplify.Inlin` which was also
about operations not the data structures and simple predictes
themselves (which is `GHC.Core.Unfold`).
Diffstat (limited to 'compiler/GHC/Core/Opt')
-rw-r--r-- | compiler/GHC/Core/Opt/Arity.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/CSE.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/ConstantFold.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/ConstantFold.hs-boot | 8 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/CprAnal.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/DmdAnal.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Exitify.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/FloatIn.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Monad.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/OccurAnal.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Pipeline.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/SetLevels.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Simplify.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Simplify/Inline.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Simplify/Iteration.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Simplify/Monad.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Simplify/Utils.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/SpecConstr.hs | 14 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/Specialise.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/WorkWrap.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/Core/Opt/WorkWrap/Utils.hs | 1 |
21 files changed, 44 insertions, 16 deletions
diff --git a/compiler/GHC/Core/Opt/Arity.hs b/compiler/GHC/Core/Opt/Arity.hs index 5ed015281a..d8ad51a5c8 100644 --- a/compiler/GHC/Core/Opt/Arity.hs +++ b/compiler/GHC/Core/Opt/Arity.hs @@ -49,6 +49,8 @@ where import GHC.Prelude import GHC.Core +import GHC.Core.Rules +import GHC.Core.Unfoldings import GHC.Core.FVs import GHC.Core.Utils import GHC.Core.DataCon diff --git a/compiler/GHC/Core/Opt/CSE.hs b/compiler/GHC/Core/Opt/CSE.hs index 2f7718709a..4786275d2a 100644 --- a/compiler/GHC/Core/Opt/CSE.hs +++ b/compiler/GHC/Core/Opt/CSE.hs @@ -21,6 +21,7 @@ import GHC.Core.Utils ( mkAltExpr import GHC.Core.FVs ( exprFreeVars ) import GHC.Core.Type ( tyConAppArgs ) import GHC.Core +import GHC.Core.Unfoldings import GHC.Utils.Outputable import GHC.Types.Basic import GHC.Types.Tickish diff --git a/compiler/GHC/Core/Opt/ConstantFold.hs b/compiler/GHC/Core/Opt/ConstantFold.hs index 3d36368d5b..37c7c7d60f 100644 --- a/compiler/GHC/Core/Opt/ConstantFold.hs +++ b/compiler/GHC/Core/Opt/ConstantFold.hs @@ -43,6 +43,8 @@ import GHC.Types.Name ( Name, nameOccName ) import GHC.Types.Basic import GHC.Core +import GHC.Core.Rules +import GHC.Core.Unfoldings import GHC.Core.Make import GHC.Core.SimpleOpt ( exprIsConApp_maybe, exprIsLiteral_maybe ) import GHC.Core.DataCon ( DataCon,dataConTagZ, dataConTyCon, dataConWrapId, dataConWorkId ) diff --git a/compiler/GHC/Core/Opt/ConstantFold.hs-boot b/compiler/GHC/Core/Opt/ConstantFold.hs-boot index 216af660ae..b47786ab03 100644 --- a/compiler/GHC/Core/Opt/ConstantFold.hs-boot +++ b/compiler/GHC/Core/Opt/ConstantFold.hs-boot @@ -1,8 +1,8 @@ module GHC.Core.Opt.ConstantFold where -import GHC.Prelude -import GHC.Core -import GHC.Builtin.PrimOps -import GHC.Types.Name +import GHC.Prelude ( Maybe ) +import GHC.Core.Rules( CoreRule ) +import GHC.Builtin.PrimOps ( PrimOp ) +import GHC.Types.Name ( Name ) primOpRules :: Name -> PrimOp -> Maybe CoreRule diff --git a/compiler/GHC/Core/Opt/CprAnal.hs b/compiler/GHC/Core/Opt/CprAnal.hs index 87d9eb2ec7..3d77c20fd8 100644 --- a/compiler/GHC/Core/Opt/CprAnal.hs +++ b/compiler/GHC/Core/Opt/CprAnal.hs @@ -27,6 +27,7 @@ import GHC.Core.DataCon import GHC.Core.Type import GHC.Core.Utils import GHC.Core +import GHC.Core.Unfoldings import GHC.Core.Seq import GHC.Core.Opt.WorkWrap.Utils diff --git a/compiler/GHC/Core/Opt/DmdAnal.hs b/compiler/GHC/Core/Opt/DmdAnal.hs index fbe843cff8..ee4f0c4f33 100644 --- a/compiler/GHC/Core/Opt/DmdAnal.hs +++ b/compiler/GHC/Core/Opt/DmdAnal.hs @@ -19,6 +19,8 @@ import GHC.Prelude import GHC.Core.Opt.WorkWrap.Utils import GHC.Types.Demand -- All of it import GHC.Core +import GHC.Core.Rules +import GHC.Core.Unfoldings import GHC.Core.Multiplicity ( scaledThing ) import GHC.Utils.Outputable import GHC.Types.Var.Env diff --git a/compiler/GHC/Core/Opt/Exitify.hs b/compiler/GHC/Core/Opt/Exitify.hs index 6ad4614286..e56619877c 100644 --- a/compiler/GHC/Core/Opt/Exitify.hs +++ b/compiler/GHC/Core/Opt/Exitify.hs @@ -40,6 +40,7 @@ import GHC.Types.Var import GHC.Types.Id import GHC.Types.Id.Info import GHC.Core +import GHC.Core.Annotated import GHC.Core.Utils import GHC.Utils.Monad.State.Strict import GHC.Builtin.Uniques diff --git a/compiler/GHC/Core/Opt/FloatIn.hs b/compiler/GHC/Core/Opt/FloatIn.hs index 2feef8a617..bbee9bb128 100644 --- a/compiler/GHC/Core/Opt/FloatIn.hs +++ b/compiler/GHC/Core/Opt/FloatIn.hs @@ -23,6 +23,7 @@ import GHC.Platform import GHC.Core import GHC.Core.Opt.Arity( isOneShotBndr ) +import GHC.Core.Annotated import GHC.Core.Make hiding ( wrapFloats ) import GHC.Core.Utils import GHC.Core.FVs diff --git a/compiler/GHC/Core/Opt/Monad.hs b/compiler/GHC/Core/Opt/Monad.hs index d38f3e6c59..39e0ce791c 100644 --- a/compiler/GHC/Core/Opt/Monad.hs +++ b/compiler/GHC/Core/Opt/Monad.hs @@ -43,7 +43,7 @@ import GHC.Prelude hiding ( read ) import GHC.Driver.Session import GHC.Driver.Env -import GHC.Core.Rules ( RuleBase, RuleEnv, mkRuleEnv ) +import GHC.Core.Rules.Apply ( RuleBase, RuleEnv, mkRuleEnv ) import GHC.Core.Opt.Stats ( SimplCount, zeroSimplCount, plusSimplCount ) import GHC.Types.Annotations diff --git a/compiler/GHC/Core/Opt/OccurAnal.hs b/compiler/GHC/Core/Opt/OccurAnal.hs index fc374adb99..0a69e27b5b 100644 --- a/compiler/GHC/Core/Opt/OccurAnal.hs +++ b/compiler/GHC/Core/Opt/OccurAnal.hs @@ -25,6 +25,8 @@ module GHC.Core.Opt.OccurAnal ( import GHC.Prelude hiding ( head, init, last, tail ) import GHC.Core +import GHC.Core.Rules +import GHC.Core.Unfoldings import GHC.Core.FVs import GHC.Core.Utils ( exprIsTrivial, isDefaultAlt, isExpandableApp, mkCastMCo, mkTicks ) diff --git a/compiler/GHC/Core/Opt/Pipeline.hs b/compiler/GHC/Core/Opt/Pipeline.hs index 8be830dbeb..754d9776c3 100644 --- a/compiler/GHC/Core/Opt/Pipeline.hs +++ b/compiler/GHC/Core/Opt/Pipeline.hs @@ -21,8 +21,9 @@ import GHC.Driver.Config.Core.Rules ( initRuleOpts ) import GHC.Platform.Ways ( hasWay, Way(WayProf) ) import GHC.Core +import GHC.Core.Rules import GHC.Core.Opt.CSE ( cseProgram ) -import GHC.Core.Rules ( RuleBase, mkRuleBase, ruleCheckProgram, getRules ) +import GHC.Core.Rules.Apply ( RuleBase, mkRuleBase, ruleCheckProgram, getRules ) import GHC.Core.Ppr ( pprCoreBindings ) import GHC.Core.Utils ( dumpIdInfoOfProgram ) import GHC.Core.Lint ( lintAnnots ) diff --git a/compiler/GHC/Core/Opt/SetLevels.hs b/compiler/GHC/Core/Opt/SetLevels.hs index 95084cf7b6..51c171f438 100644 --- a/compiler/GHC/Core/Opt/SetLevels.hs +++ b/compiler/GHC/Core/Opt/SetLevels.hs @@ -66,6 +66,7 @@ module GHC.Core.Opt.SetLevels ( import GHC.Prelude import GHC.Core +import GHC.Core.Annotated import GHC.Core.Opt.Monad ( FloatOutSwitches(..) ) import GHC.Core.Utils ( exprType, exprIsHNF , exprOkForSpeculation @@ -81,6 +82,7 @@ import GHC.Core.Type ( Type, tyCoVarsOfType , mightBeUnliftedType, closeOverKindsDSet , typeHasFixedRuntimeRep ) +import GHC.Core.Unfoldings ( isStableUnfolding ) import GHC.Core.Multiplicity ( pattern ManyTy ) import GHC.Types.Id diff --git a/compiler/GHC/Core/Opt/Simplify.hs b/compiler/GHC/Core/Opt/Simplify.hs index 7b7b439e33..d585af35a9 100644 --- a/compiler/GHC/Core/Opt/Simplify.hs +++ b/compiler/GHC/Core/Opt/Simplify.hs @@ -11,6 +11,7 @@ import GHC.Driver.Flags import GHC.Core import GHC.Core.Rules +import GHC.Core.Rules.Apply import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr ) import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) import GHC.Core.Stats ( coreBindsSize, coreBindsStats, exprSize ) @@ -22,6 +23,7 @@ import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Monad import GHC.Core.Opt.Stats ( simplCountN ) import GHC.Core.FamInstEnv +import GHC.Core.Unfoldings import GHC.Utils.Error ( withTiming ) import GHC.Utils.Logger as Logger diff --git a/compiler/GHC/Core/Opt/Simplify/Inline.hs b/compiler/GHC/Core/Opt/Simplify/Inline.hs index f91319e754..10b74be6a4 100644 --- a/compiler/GHC/Core/Opt/Simplify/Inline.hs +++ b/compiler/GHC/Core/Opt/Simplify/Inline.hs @@ -23,6 +23,7 @@ import GHC.Driver.Flags import GHC.Core import GHC.Core.Unfold +import GHC.Core.Unfoldings import GHC.Types.Id import GHC.Types.Basic ( Arity, RecFlag(..) ) import GHC.Utils.Logger diff --git a/compiler/GHC/Core/Opt/Simplify/Iteration.hs b/compiler/GHC/Core/Opt/Simplify/Iteration.hs index e29581a2f0..6f917c3f8b 100644 --- a/compiler/GHC/Core/Opt/Simplify/Iteration.hs +++ b/compiler/GHC/Core/Opt/Simplify/Iteration.hs @@ -45,8 +45,10 @@ import GHC.Core.Opt.Arity ( ArityType, exprArity, arityTypeBotSigs_maybe , typeArity, arityTypeArity, etaExpandAT ) import GHC.Core.SimpleOpt ( exprIsConApp_maybe, joinPointBinding_maybe, joinPointBindings_maybe ) import GHC.Core.FVs ( mkRuleInfo ) -import GHC.Core.Rules ( lookupRule, getRules ) +import GHC.Core.Rules +import GHC.Core.Rules.Apply ( lookupRule, getRules ) import GHC.Core.Multiplicity +import GHC.Core.Unfoldings import GHC.Types.Literal ( litIsLifted ) --, mkLitInt ) -- temporarily commented out. See #8326 import GHC.Types.SourceText diff --git a/compiler/GHC/Core/Opt/Simplify/Monad.hs b/compiler/GHC/Core/Opt/Simplify/Monad.hs index 826c11f335..12e2338530 100644 --- a/compiler/GHC/Core/Opt/Simplify/Monad.hs +++ b/compiler/GHC/Core/Opt/Simplify/Monad.hs @@ -28,7 +28,7 @@ import GHC.Types.Id ( Id, mkSysLocalOrCoVarM ) import GHC.Types.Id.Info ( IdDetails(..), vanillaIdInfo, setArityInfo ) import GHC.Core.Type ( Type, Mult ) import GHC.Core.Opt.Stats -import GHC.Core.Rules +import GHC.Core.Rules.Apply import GHC.Core.Utils ( mkLamTypes ) import GHC.Types.Unique.Supply import GHC.Driver.Flags diff --git a/compiler/GHC/Core/Opt/Simplify/Utils.hs b/compiler/GHC/Core/Opt/Simplify/Utils.hs index 28b1ebc221..c4bf05a00a 100644 --- a/compiler/GHC/Core/Opt/Simplify/Utils.hs +++ b/compiler/GHC/Core/Opt/Simplify/Utils.hs @@ -45,6 +45,7 @@ module GHC.Core.Opt.Simplify.Utils ( import GHC.Prelude hiding (head, init, last, tail) import GHC.Core +import GHC.Core.Rules import GHC.Types.Literal ( isLitRubbish ) import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Inline @@ -54,10 +55,11 @@ import GHC.Core.Ppr import GHC.Core.TyCo.Ppr ( pprParendType ) import GHC.Core.FVs import GHC.Core.Utils -import GHC.Core.Rules( RuleEnv, getRules ) +import GHC.Core.Rules.Apply ( RuleEnv, getRules ) import GHC.Core.Opt.Arity import GHC.Core.Unfold import GHC.Core.Unfold.Make +import GHC.Core.Unfoldings import GHC.Core.Opt.Simplify.Monad import GHC.Core.Type hiding( substTy ) import GHC.Core.Coercion hiding( substCo ) @@ -1065,7 +1067,7 @@ including those in the LHS of rules. This can cause somewhat surprising results; for instance, in #18162 we found that a rule template contained ticks in its arguments, because postInlineUnconditionally substituted in a trivial expression that contains -ticks. See Note [Tick annotations in RULE matching] in GHC.Core.Rules for +ticks. See Note [Tick annotations in RULE matching] in GHC.Core.Rules.Apply for details. Note [Cast swizzling on rule LHSs] diff --git a/compiler/GHC/Core/Opt/SpecConstr.hs b/compiler/GHC/Core/Opt/SpecConstr.hs index 6a45129f06..4b10a924af 100644 --- a/compiler/GHC/Core/Opt/SpecConstr.hs +++ b/compiler/GHC/Core/Opt/SpecConstr.hs @@ -29,6 +29,7 @@ import GHC.Driver.Session ( DynFlags(..), GeneralFlag( Opt_SpecConstrKeen ) , gopt, hasPprDebug ) import GHC.Core +import GHC.Core.Rules import GHC.Core.Subst import GHC.Core.Utils import GHC.Core.Unfold @@ -40,8 +41,9 @@ import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) import GHC.Core.DataCon import GHC.Core.Class( classTyVars ) import GHC.Core.Coercion hiding( substCo ) -import GHC.Core.Rules +import GHC.Core.Rules.Apply import GHC.Core.Predicate ( typeDeterminesValue ) +import GHC.Core.Unfoldings import GHC.Core.Type hiding ( substTy ) import GHC.Core.TyCon (TyCon, tyConName ) import GHC.Core.Multiplicity @@ -2586,19 +2588,19 @@ argToPat1 env in_scope val_env (Tick _ arg) arg_occ arg_str -- Ignore Notes. In particular, we want to ignore any InlineMe notes -- Perhaps we should not ignore profiling notes, but I'm going to -- ride roughshod over them all for now. - --- See Note [Tick annotations in RULE matching] in GHC.Core.Rules + --- See Note [Tick annotations in RULE matching] in GHC.Core.Rules.Apply argToPat1 env in_scope val_env (Let _ arg) arg_occ arg_str = argToPat env in_scope val_env arg arg_occ arg_str - -- See Note [Matching lets] in "GHC.Core.Rules" + -- See Note [Matching lets] in "GHC.Core.Rules.Apply" -- Look through let expressions -- e.g. f (let v = rhs in (v,w)) -- Here we can specialise for f (v,w) -- because the rule-matcher will look through the let. -{- Disabled; see Note [Matching cases] in "GHC.Core.Rules" +{- Disabled; see Note [Matching cases] in "GHC.Core.Rules.Apply" argToPat env in_scope val_env (Case scrut _ _ [(_, _, rhs)]) arg_occ - | exprOkForSpeculation scrut -- See Note [Matching cases] in "GHC.Core.Rules" + | exprOkForSpeculation scrut -- See Note [Matching cases] in "GHC.Core.Rules.Apply" = argToPat env in_scope val_env rhs arg_occ -} @@ -2702,7 +2704,7 @@ argToPat1 env in_scope val_env (Var v) arg_occ arg_str -- And by not wild-carding we tend to get forall'd -- variables that are in scope, which in turn can -- expose the weakness in let-matching --- See Note [Matching lets] in GHC.Core.Rules +-- See Note [Matching lets] in GHC.Core.Rules.Apply -- Check for a variable bound inside the function. -- Don't make a wild-card, because we may usefully share diff --git a/compiler/GHC/Core/Opt/Specialise.hs b/compiler/GHC/Core/Opt/Specialise.hs index dda10da34e..d9f9f7e38e 100644 --- a/compiler/GHC/Core/Opt/Specialise.hs +++ b/compiler/GHC/Core/Opt/Specialise.hs @@ -27,6 +27,8 @@ import GHC.Core import GHC.Core.Make ( mkLitRubbish ) import GHC.Core.Unify ( tcMatchTy ) import GHC.Core.Rules +import GHC.Core.Rules.Apply +import GHC.Core.Unfoldings import GHC.Core.Utils ( exprIsTrivial , mkCast, exprType , stripTicksTop, mkInScopeSetBndrs ) diff --git a/compiler/GHC/Core/Opt/WorkWrap.hs b/compiler/GHC/Core/Opt/WorkWrap.hs index 29f1e3973f..aefbafe03c 100644 --- a/compiler/GHC/Core/Opt/WorkWrap.hs +++ b/compiler/GHC/Core/Opt/WorkWrap.hs @@ -14,6 +14,7 @@ where import GHC.Prelude import GHC.Core +import GHC.Core.Rules import GHC.Core.Unfold.Make import GHC.Core.Utils ( exprType, exprIsHNF ) import GHC.Core.Type diff --git a/compiler/GHC/Core/Opt/WorkWrap/Utils.hs b/compiler/GHC/Core/Opt/WorkWrap/Utils.hs index f599975355..b45fb1210b 100644 --- a/compiler/GHC/Core/Opt/WorkWrap/Utils.hs +++ b/compiler/GHC/Core/Opt/WorkWrap/Utils.hs @@ -22,6 +22,7 @@ where import GHC.Prelude import GHC.Core +import GHC.Core.Unfoldings import GHC.Core.Utils import GHC.Core.DataCon import GHC.Core.Make |