Commit 3ca52151 authored by Sylvain Henry's avatar Sylvain Henry
Browse files

GHC.Core.Opt renaming

* GHC.Core.Op                  => GHC.Core.Opt
* GHC.Core.Opt.Simplify.Driver => GHC.Core.Opt.Driver
* GHC.Core.Opt.Tidy            => GHC.Core.Tidy
* GHC.Core.Opt.WorkWrap.Lib    => GHC.Core.Opt.WorkWrap.Utils

As discussed in:
 * ghc/ghc#13009 (comment 264650)
parent 15ab6cd5
......@@ -354,7 +354,7 @@ an unlifted literal, like all the others.
Also, we do not permit case analysis with literal patterns on floating-point
types. See #9238 and Note [Rules for floating-point comparisons] in
GHC.Core.Op.ConstantFold for the rationale for this restriction.
GHC.Core.Opt.ConstantFold for the rationale for this restriction.
-------------------------- GHC.Core INVARIANTS ---------------------------
......@@ -508,7 +508,7 @@ checked by Core Lint.
5. Floating-point values must not be scrutinised against literals.
See #9238 and Note [Rules for floating-point comparisons]
in GHC.Core.Op.ConstantFold for rationale. Checked in lintCaseExpr;
in GHC.Core.Opt.ConstantFold for rationale. Checked in lintCaseExpr;
see the call to isFloatingTy.
6. The 'ty' field of (Case scrut bndr ty alts) is the type of the
......@@ -784,7 +784,7 @@ is crucial for understanding how case-of-case interacts with join points:
_ -> False
The simplifier will pull the case into the join point (see Note [Join points
and case-of-case] in GHC.Core.Op.Simplify):
and case-of-case] in GHC.Core.Opt.Simplify):
j :: Int -> Bool -> Bool -- changed!
......@@ -1296,7 +1296,7 @@ Orphan-hood is computed
The CoreRule type and its friends are dealt with mainly in GHC.Core.Rules, but
GHC.Core.FVs, GHC.Core.Subst, GHC.Core.Ppr, GHC.Core.Op.Tidy also inspect the
GHC.Core.FVs, GHC.Core.Subst, GHC.Core.Ppr, GHC.Core.Tidy also inspect the
......@@ -1816,7 +1816,7 @@ the occurrence info is wrong
-- The Ord is needed for the FiniteMap used in the lookForConstructor
-- in GHC.Core.Op.Simplify.Env. If you declared that lookForConstructor
-- in GHC.Core.Opt.Simplify.Env. If you declared that lookForConstructor
-- *ignores* constructor-applications with LitArg args, then you could get rid
-- of this Ord.
......@@ -1503,7 +1503,7 @@ mkPiCo r v co | isTyVar v = mkHomoForAllCos [v] co
-- We didn't call mkForAllCo here because if v does not appear
-- in co, the argement coercion will be nominal. But here we
-- want it to be r. It is only called in 'mkPiCos', which is
-- only used in GHC.Core.Op.Simplify.Utils, where we are sure for
-- only used in GHC.Core.Opt.Simplify.Utils, where we are sure for
-- now (Aug 2018) v won't occur in co.
mkFunCo r (mkReflCo r (varType v)) co
| otherwise = mkFunCo r (mkReflCo r (varType v)) co
......@@ -316,7 +316,7 @@ Nevertheless it is still useful to have data families in the FamInstEnv:
- For finding overlaps and conflicts
- For finding the representation type...see FamInstEnv.topNormaliseType
and its call site in GHC.Core.Op.Simplify
and its call site in GHC.Core.Opt.Simplify
- In standalone deriving instance Eq (T [Int]) we need to find the
representation type for T [Int]
......@@ -29,7 +29,7 @@ import GHC.Core
import GHC.Core.FVs
import GHC.Core.Utils
import GHC.Core.Stats ( coreBindsStats )
import GHC.Core.Op.Monad
import GHC.Core.Opt.Monad
import Bag
import GHC.Types.Literal
import GHC.Core.DataCon
......@@ -165,7 +165,7 @@ In the desugarer, it's very very convenient to be able to say (in effect)
let x::a = True in <body>
That is, use a type let. See Note [Type let] in CoreSyn.
One place it is used is in mkWwArgs; see Note [Join points and beta-redexes]
in GHC.Core.Op.WorkWrap.Lib. (Maybe there are other "clients" of this feature; I'm not sure).
in GHC.Core.Opt.WorkWrap.Utils. (Maybe there are other "clients" of this feature; I'm not sure).
* Hence when linting <body> we need to remember that a=Int, else we
might reject a correct program. So we carry a type substitution (in
......@@ -638,7 +638,7 @@ lintLetBind top_lvl rec_flag binder rhs rhs_ty
-- We used to check that the dmdTypeDepth of a demand signature never
-- exceeds idArity, but that is an unnecessary complication, see
-- Note [idArity varies independently of dmdTypeDepth] in GHC.Core.Op.DmdAnal
-- Note [idArity varies independently of dmdTypeDepth] in GHC.Core.Opt.DmdAnal
-- Check that the binder's arity is within the bounds imposed by
-- the type and the strictness signature. See Note [exprArity invariant]
......@@ -1166,7 +1166,7 @@ lintCaseExpr scrut var alt_ty alts =
-- Check that the scrutinee is not a floating-point type
-- if there are any literal alternatives
-- See GHC.Core Note [Case expression invariants] item (5)
-- See Note [Rules for floating-point comparisons] in GHC.Core.Op.ConstantFold
-- See Note [Rules for floating-point comparisons] in GHC.Core.Opt.ConstantFold
; let isLitPat (LitAlt _, _ , _) = True
isLitPat _ = False
; checkL (not $ isFloatingTy scrut_ty && any isLitPat alts)
......@@ -2842,7 +2842,7 @@ lintAnnots pname pass guts = do
let binds = flattenBinds $ mg_binds nguts
binds' = flattenBinds $ mg_binds nguts'
(diffs,_) = diffBinds True (mkRnEnv2 emptyInScopeSet) binds binds'
when (not (null diffs)) $ GHC.Core.Op.Monad.putMsg $ vcat
when (not (null diffs)) $ GHC.Core.Opt.Monad.putMsg $ vcat
[ lint_banner "warning" pname
, text "Core changes with annotations:"
, withPprStyle (defaultDumpStyle dflags) $ nest 2 $ vcat diffs
......@@ -192,7 +192,7 @@ mkWildEvBinder pred = mkWildValBinder pred
-- that you expect to use only at a *binding* site. Do not use it at
-- occurrence sites because it has a single, fixed unique, and it's very
-- easy to get into difficulties with shadowing. That's why it is used so little.
-- See Note [WildCard binders] in GHC.Core.Op.Simplify.Env
-- See Note [WildCard binders] in GHC.Core.Opt.Simplify.Env
mkWildValBinder :: Type -> Id
mkWildValBinder ty = mkLocalIdOrCoVar wildCardName ty
-- "OrCoVar" since a coercion can be a scrutinee with -fdefer-type-errors
......@@ -575,7 +575,7 @@ data FloatBind
= FloatLet CoreBind
| FloatCase CoreExpr Id AltCon [Var]
-- case e of y { C ys -> ... }
-- See Note [Floating single-alternative cases] in GHC.Core.Op.SetLevels
-- See Note [Floating single-alternative cases] in GHC.Core.Opt.SetLevels
instance Outputable FloatBind where
ppr (FloatLet b) = text "LET" <+> ppr b
......@@ -879,7 +879,7 @@ the first. But the stable-unfolding for f looks like
\x. case x of MkT a b -> g ($WMkT b a)
where $WMkT is the wrapper for MkT that evaluates its arguments. We
apply the same w/w split to this unfolding (see Note [Worker-wrapper
for INLINEABLE functions] in GHC.Core.Op.WorkWrap) so the template ends up like
for INLINEABLE functions] in GHC.Core.Opt.WorkWrap) so the template ends up like
\b. let a = absentError "blah"
x = MkT a b
in case x of MkT a b -> g ($WMkT b a)
......@@ -924,7 +924,7 @@ aBSENT_ERROR_ID
absent_ty = mkSpecForAllTys [alphaTyVar] (mkVisFunTy addrPrimTy alphaTy)
-- Not runtime-rep polymorphic. aBSENT_ERROR_ID is only used for
-- lifted-type things; see Note [Absent errors] in GHC.Core.Op.WorkWrap.Lib
-- lifted-type things; see Note [Absent errors] in GHC.Core.Opt.WorkWrap.Utils
arity_info = vanillaIdInfo `setArityInfo` 1
-- NB: no bottoming strictness info, unlike other error-ids.
-- See Note [aBSENT_ERROR_ID]
......@@ -9,7 +9,7 @@
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
module GHC.Core.Op.CSE (cseProgram, cseOneExpr) where
module GHC.Core.Opt.CSE (cseProgram, cseOneExpr) where
#include "HsVersions.h"
......@@ -124,7 +124,7 @@ Notice also that in the SUBSTITUTE case we leave behind a binding
x = y
even though we /also/ carry a substitution x -> y. Can we just drop
the binding instead? Well, not at top level! See Note [Top level and
postInlineUnconditionally] in GHC.Core.Op.Simplify.Utils; and in any
postInlineUnconditionally] in GHC.Core.Opt.Simplify.Utils; and in any
case CSE applies only to the /bindings/ of the program, and we leave
it to the simplifier to propate effects to the RULES. Finally, it
doesn't seem worth the effort to discard the nested bindings because
......@@ -231,7 +231,7 @@ the Integer instance of Enum in GHC.Enum.) Suppose moreover that foo's
stable unfolding originates from an INLINE or INLINEABLE pragma on foo.
Then we obviously do NOT want to extend the substitution with (foo->x),
because we promised to inline foo as what the user wrote. See similar Note
[Stable unfoldings and postInlineUnconditionally] in GHC.Core.Op.Simplify.Utils.
[Stable unfoldings and postInlineUnconditionally] in GHC.Core.Opt.Simplify.Utils.
Nor do we want to change the reverse mapping. Suppose we have
......@@ -687,7 +687,7 @@ turning K2 into 'x' increases the number of live variables. But
Note [Combine case alternatives]
combineAlts is just a more heavyweight version of the use of
combineIdenticalAlts in GHC.Core.Op.Simplify.Utils.prepareAlts. The basic idea is
combineIdenticalAlts in GHC.Core.Opt.Simplify.Utils.prepareAlts. The basic idea is
to transform
......@@ -710,7 +710,7 @@ Note [Combine case alts: awkward corner]
We would really like to check isDeadBinder on the binders in the
alternative. But alas, the simplifer zaps occ-info on binders in case
alternatives; see Note [Case alternative occ info] in GHC.Core.Op.Simplify.
alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify.
* One alternative (perhaps a good one) would be to do OccAnal
just before CSE. Then perhaps we could get rid of combineIdenticalAlts
......@@ -2,7 +2,7 @@
-- Copyright (c) 2014 Joachim Breitner
module GHC.Core.Op.CallArity
module GHC.Core.Opt.CallArity
( callArityAnalProgram
, callArityRHS -- for testing
) where
......@@ -17,7 +17,7 @@ ToDo:
{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -optc-DNON_POSIX_SOURCE -Wno-incomplete-uni-patterns #-}
module GHC.Core.Op.ConstantFold
module GHC.Core.Opt.ConstantFold
( primOpRules
, builtinRules
, caseRules
......@@ -1112,13 +1112,13 @@ is:
the returned value.
* An application like (dataToTag# (Just x)) is optimised by
dataToTagRule in GHC.Core.Op.ConstantFold.
dataToTagRule in GHC.Core.Opt.ConstantFold.
* A case expression like
case (dataToTag# e) of <alts>
gets transformed t
case e of <transformed alts>
by GHC.Core.Op.ConstantFold.caseRules; see Note [caseRules for dataToTag]
by GHC.Core.Opt.ConstantFold.caseRules; see Note [caseRules for dataToTag]
See #15696 for a long saga.
......@@ -1193,7 +1193,7 @@ Things to note
Implementing seq#. The compiler has magic for SeqOp in
- GHC.Core.Op.ConstantFold.seqRule: eliminate (seq# <whnf> s)
- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# <whnf> s)
- GHC.StgToCmm.Expr.cgExpr, and cgCase: special case for seq#
......@@ -1202,7 +1202,7 @@ Implementing seq#. The compiler has magic for SeqOp in
- Simplify.addEvals records evaluated-ness for the result; see
Note [Adding evaluatedness info to pattern-bound variables]
in GHC.Core.Op.Simplify
in GHC.Core.Opt.Simplify
seqRule :: RuleM CoreExpr
......@@ -2051,7 +2051,7 @@ wordPrimOps platform = PrimOps
-- Constant folding through case-expressions
-- cf Scrutinee Constant Folding in simplCore/GHC.Core.Op.Simplify.Utils
-- cf Scrutinee Constant Folding in simplCore/GHC.Core.Opt.Simplify.Utils
-- | Match the scrutinee of a case and potentially return a new scrutinee and a
......@@ -2212,7 +2212,7 @@ We don't want to get this!
Instead, we deal with turning one branch into DEFAULT in GHC.Core.Op.Simplify.Utils
Instead, we deal with turning one branch into DEFAULT in GHC.Core.Opt.Simplify.Utils
(add_default in mkCase3).
Note [caseRules for dataToTag]
......@@ -7,7 +7,7 @@
-- See
-- CPR analysis should happen after strictness analysis.
-- See Note [Phase ordering].
module GHC.Core.Op.CprAnal ( cprAnalProgram ) where
module GHC.Core.Opt.CprAnal ( cprAnalProgram ) where
#include "HsVersions.h"
......@@ -29,7 +29,7 @@ import GHC.Core.Utils ( exprIsHNF, dumpIdInfoOfProgram )
import GHC.Core.TyCon
import GHC.Core.Type
import GHC.Core.FamInstEnv
import GHC.Core.Op.WorkWrap.Lib
import GHC.Core.Opt.WorkWrap.Utils
import Util
import ErrUtils ( dumpIfSet_dyn, DumpFormat (..) )
import Maybes ( isJust, isNothing )
......@@ -108,7 +108,7 @@ cprAnalProgram dflags fam_envs binds = do
let binds_plus_cpr = snd $ mapAccumL cprAnalTopBind env binds
dumpIfSet_dyn dflags Opt_D_dump_cpr_signatures "Cpr signatures" FormatText $
dumpIdInfoOfProgram (ppr . cprInfo) binds_plus_cpr
-- See Note [Stamp out space leaks in demand analysis] in GHC.Core.Op.DmdAnal
-- See Note [Stamp out space leaks in demand analysis] in GHC.Core.Opt.DmdAnal
seqBinds binds_plus_cpr `seq` return binds_plus_cpr
-- Analyse a (group of) top-level binding(s)
......@@ -252,7 +252,7 @@ cprFix top_lvl env orig_pairs
= loop 1 initial_pairs
bot_sig = mkCprSig 0 botCpr
-- See Note [Initialising strictness] in GHC.Core.Op.DmdAnal
-- See Note [Initialising strictness] in GHC.Core.Opt.DmdAnal
initial_pairs | ae_virgin env = [(setIdCprInfo id bot_sig, rhs) | (id, rhs) <- orig_pairs ]
| otherwise = orig_pairs
......@@ -440,7 +440,7 @@ extendEnvForDataAlt env scrut case_bndr dc bndrs
-- to sums (yet); we lack WW for strict binders of sum type.
do_con_arg env (id, str)
| is_var scrut
-- See Note [Add demands for strict constructors] in WorkWrap.Lib
-- See Note [Add demands for strict constructors] in GHC.Core.Opt.WorkWrap.Utils
, let dmd = applyWhen (isMarkedStrict str) strictifyDmd (idDemandInfo id)
= extendAnalEnvForDemand env id dmd
| otherwise
......@@ -9,14 +9,14 @@
module GHC.Core.Op.DmdAnal ( dmdAnalProgram ) where
module GHC.Core.Opt.DmdAnal ( dmdAnalProgram ) where
#include "HsVersions.h"
import GhcPrelude
import GHC.Driver.Session
import GHC.Core.Op.WorkWrap.Lib ( findTypeShape )
import GHC.Core.Opt.WorkWrap.Utils ( findTypeShape )
import GHC.Types.Demand -- All of it
import GHC.Core
import GHC.Core.Seq ( seqBinds )
......@@ -754,7 +754,7 @@ information, but
* Performing the worker/wrapper split based on this information would be
implicitly eta-expanding `f`, playing fast and loose with divergence and
even being unsound in the presence of newtypes, so we refrain from doing so.
Also see Note [Don't eta expand in w/w] in GHC.Core.Op.WorkWrap.
Also see Note [Don't eta expand in w/w] in GHC.Core.Opt.WorkWrap.
Since we only compute one signature, we do so for arity 1. Computing multiple
signatures for different arities (i.e., polyvariance) would be entirely
......@@ -1241,7 +1241,7 @@ generator, though. So:
* We zap the used-once info in the worker-wrapper;
see Note [Zapping Used Once info in WorkWrap] in
If it's not reliable, it's better not to have it at all.
* Just before TidyCore, we add a pass of the demand analyser,
......@@ -6,7 +6,7 @@
module GHC.Core.Op.Simplify.Driver ( core2core, simplifyExpr ) where
module GHC.Core.Opt.Driver ( core2core, simplifyExpr ) where
#include "HsVersions.h"
......@@ -15,40 +15,40 @@ import GhcPrelude
import GHC.Driver.Session
import GHC.Core
import GHC.Driver.Types
import GHC.Core.Op.CSE ( cseProgram )
import GHC.Core.Opt.CSE ( cseProgram )
import GHC.Core.Rules ( mkRuleBase, unionRuleBase,
extendRuleBaseList, ruleCheckProgram, addRuleInfo,
getRules )
import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr )
import GHC.Core.Op.OccurAnal ( occurAnalysePgm, occurAnalyseExpr )
import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr )
import GHC.Types.Id.Info
import GHC.Core.Stats ( coreBindsSize, coreBindsStats, exprSize )
import GHC.Core.Utils ( mkTicks, stripTicksTop )
import GHC.Core.Lint ( endPass, lintPassResult, dumpPassResult,
lintAnnots )
import GHC.Core.Op.Simplify ( simplTopBinds, simplExpr, simplRules )
import GHC.Core.Op.Simplify.Utils ( simplEnvForGHCi, activeRule, activeUnfolding )
import GHC.Core.Op.Simplify.Env
import GHC.Core.Op.Simplify.Monad
import GHC.Core.Op.Monad
import GHC.Core.Opt.Simplify ( simplTopBinds, simplExpr, simplRules )
import GHC.Core.Opt.Simplify.Utils ( simplEnvForGHCi, activeRule, activeUnfolding )
import GHC.Core.Opt.Simplify.Env
import GHC.Core.Opt.Simplify.Monad
import GHC.Core.Opt.Monad
import qualified ErrUtils as Err
import GHC.Core.Op.FloatIn ( floatInwards )
import GHC.Core.Op.FloatOut ( floatOutwards )
import GHC.Core.Opt.FloatIn ( floatInwards )
import GHC.Core.Opt.FloatOut ( floatOutwards )
import GHC.Core.FamInstEnv
import GHC.Types.Id
import ErrUtils ( withTiming, withTimingD, DumpFormat (..) )
import GHC.Types.Basic ( CompilerPhase(..), isDefaultInlinePragma, defaultInlinePragma )
import GHC.Types.Var.Set
import GHC.Types.Var.Env
import GHC.Core.Op.LiberateCase ( liberateCase )
import GHC.Core.Op.StaticArgs ( doStaticArgs )
import GHC.Core.Op.Specialise ( specProgram)
import GHC.Core.Op.SpecConstr ( specConstrProgram)
import GHC.Core.Op.DmdAnal ( dmdAnalProgram )
import GHC.Core.Op.CprAnal ( cprAnalProgram )
import GHC.Core.Op.CallArity ( callArityAnalProgram )
import GHC.Core.Op.Exitify ( exitifyProgram )
import GHC.Core.Op.WorkWrap ( wwTopBinds )
import GHC.Core.Opt.LiberateCase ( liberateCase )
import GHC.Core.Opt.StaticArgs ( doStaticArgs )
import GHC.Core.Opt.Specialise ( specProgram)
import GHC.Core.Opt.SpecConstr ( specConstrProgram)
import GHC.Core.Opt.DmdAnal ( dmdAnalProgram )
import GHC.Core.Opt.CprAnal ( cprAnalProgram )
import GHC.Core.Opt.CallArity ( callArityAnalProgram )
import GHC.Core.Opt.Exitify ( exitifyProgram )
import GHC.Core.Opt.WorkWrap ( wwTopBinds )
import GHC.Types.SrcLoc
import Util
import GHC.Types.Module
......@@ -311,7 +311,7 @@ getCoreToDo dflags
simpl_phase 0 ["post-liberate-case"] max_iter
]), -- Run the simplifier after LiberateCase to vastly
-- reduce the possibility of shadowing
-- Reason: see Note [Shadowing] in GHC.Core.Op.SpecConstr
-- Reason: see Note [Shadowing] in GHC.Core.Opt.SpecConstr
runWhen spec_constr CoreDoSpecConstr,
......@@ -337,7 +337,7 @@ getCoreToDo dflags
-- Final run of the demand_analyser, ensures that one-shot thunks are
-- really really one-shot thunks. Only needed if the demand analyser
-- has run at all. See Note [Final Demand Analyser run] in GHC.Core.Op.DmdAnal
-- has run at all. See Note [Final Demand Analyser run] in GHC.Core.Opt.DmdAnal
-- It is EXTREMELY IMPORTANT to run this pass, otherwise execution
-- can become /exponentially/ more expensive. See #11731, #12996.
runWhen (strictness || late_dmd_anal) CoreDoDemand,
......@@ -605,7 +605,7 @@ simplExprGently :: SimplEnv -> CoreExpr -> SimplM CoreExpr
-- It's important that simplExprGently does eta reduction; see
-- Note [Simplifying the left-hand side of a RULE] above. The
-- simplifier does indeed do eta reduction (it's in GHC.Core.Op.Simplify.completeLam)
-- simplifier does indeed do eta reduction (it's in GHC.Core.Opt.Simplify.completeLam)
-- but only if -O is on.
simplExprGently env expr = do
......@@ -727,7 +727,7 @@ simplifyPgmIO pass@(CoreDoSimplify max_iterations mode)
; return (getTopFloatBinds floats, rules1) } ;
-- Stop if nothing happened; don't dump output
-- See Note [Which transformations are innocuous] in GHC.Core.Op.Monad
-- See Note [Which transformations are innocuous] in GHC.Core.Opt.Monad
if isZeroSimplCount counts1 then
return ( "Simplifier reached fixed point", iteration_no
, totalise (counts1 : counts_so_far) -- Include "free" ticks
module GHC.Core.Op.Exitify ( exitifyProgram ) where
module GHC.Core.Opt.Exitify ( exitifyProgram ) where
Note [Exitification]
......@@ -246,7 +246,7 @@ exitifyRec in_scope pairs
-- We are going to abstract over these variables, so we must
-- zap any IdInfo they have; see #15005
-- cf. GHC.Core.Op.SetLevels.abstractVars
-- cf. GHC.Core.Opt.SetLevels.abstractVars
zap v | isId v = setIdInfo v vanillaIdInfo
| otherwise = v
......@@ -16,7 +16,7 @@ then discover that they aren't needed in the chosen branch.
{-# OPTIONS_GHC -fprof-auto #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
module GHC.Core.Op.FloatIn ( floatInwards ) where
module GHC.Core.Opt.FloatIn ( floatInwards ) where
#include "HsVersions.h"
......@@ -28,7 +28,7 @@ import GHC.Core.Make hiding ( wrapFloats )
import GHC.Driver.Types ( ModGuts(..) )
import GHC.Core.Utils
import GHC.Core.FVs
import GHC.Core.Op.Monad ( CoreM )
import GHC.Core.Opt.Monad ( CoreM )
import GHC.Types.Id ( isOneShotBndr, idType, isJoinId, isJoinId_maybe )
import GHC.Types.Var
import GHC.Core.Type
......@@ -93,7 +93,7 @@ The fix is
to let bind the algebraic case scrutinees (done, I think) and
the case alternatives (except the ones with an
unboxed type)(not done, I think). This is best done in the
GHC.Core.Op.SetLevels.hs module, which tags things with their level numbers.
GHC.Core.Opt.SetLevels.hs module, which tags things with their level numbers.
do the full laziness pass (floating lets outwards).
......@@ -8,7 +8,7 @@
module GHC.Core.Op.FloatOut ( floatOutwards ) where
module GHC.Core.Opt.FloatOut ( floatOutwards ) where
import GhcPrelude
......@@ -16,13 +16,13 @@ import GHC.Core
import GHC.Core.Utils
import GHC.Core.Make
import GHC.Core.Arity ( etaExpand )
import GHC.Core.Op.Monad ( FloatOutSwitches(..) )
import GHC.Core.Opt.Monad ( FloatOutSwitches(..) )
import GHC.Driver.Session
import ErrUtils ( dumpIfSet_dyn, DumpFormat (..) )
import GHC.Types.Id ( Id, idArity, idType, isBottomingId,
isJoinId, isJoinId_maybe )
import GHC.Core.Op.SetLevels
import GHC.Core.Opt.SetLevels
import GHC.Types.Unique.Supply ( UniqSupply )
import Bag
import Util
......@@ -113,7 +113,7 @@ Note [Join points]
Every occurrence of a join point must be a tail call (see Note [Invariants on
join points] in GHC.Core), so we must be careful with how far we float them. The
mechanism for doing so is the *join ceiling*, detailed in Note [Join ceiling]
in GHC.Core.Op.SetLevels. For us, the significance is that a binder might be marked to be
in GHC.Core.Opt.SetLevels. For us, the significance is that a binder might be marked to be
dropped at the nearest boundary between tail calls and non-tail calls. For
......@@ -220,7 +220,7 @@ floatBind (NonRec (TB var _) rhs)
= case (floatRhs var rhs) of { (fs, rhs_floats, rhs') ->
-- A tiresome hack:
-- see Note [Bottoming floats: eta expansion] in GHC.Core.Op.SetLevels
-- see Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels
let rhs'' | isBottomingId var = etaExpand (idArity var) rhs'
| otherwise = rhs'
......@@ -337,7 +337,7 @@ makes f and x' look mutually recursive when they're not.
The test was shootout/k-nucleotide, as compiled using commit 47d5dd68 on the
wip/join-points branch.
TODO: This can probably be solved somehow in GHC.Core.Op.SetLevels. The difference between
TODO: This can probably be solved somehow in GHC.Core.Opt.SetLevels. The difference between
"this *is at* level <2,0>" and "this *depends on* level <2,0>" is very
......@@ -408,7 +408,7 @@ floatExpr lam@(Lam (TB _ lam_spec) _)
bndrs = [b | TB b _ <- bndrs_w_lvls]
bndr_lvl = asJoinCeilLvl (floatSpecLevel lam_spec)
-- All the binders have the same level
-- See GHC.Core.Op.SetLevels.lvlLamBndrs
-- See GHC.Core.Opt.SetLevels.lvlLamBndrs
-- Use asJoinCeilLvl to make this the join ceiling
case (floatBody bndr_lvl body) of { (fs, floats, body') ->
......@@ -597,7 +597,7 @@ lifted to top level.
The trouble is that
(a) we partition these floating bindings *at every binding site*
(b) GHC.Core.Op.SetLevels introduces a new bindings site for every float
(b) GHC.Core.Opt.SetLevels introduces a new bindings site for every float
So we had better not look at each binding at each binding site!
That is why MajorEnv is represented as a finite map.
......@@ -5,7 +5,7 @@
module GHC.Core.Op.LiberateCase ( liberateCase ) where
module GHC.Core.Opt.LiberateCase ( liberateCase ) where
#include "HsVersions.h"
......@@ -8,7 +8,7 @@
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
module GHC.Core.Op.Monad (
module GHC.Core.Opt.Monad (
-- * Configuration of the core-to-core passes
CoreToDo(..), runWhen, runMaybe,
......@@ -153,7 +153,7 @@ pprPassDetails (CoreDoSimplify n md) = vcat [ text "Max iterations =" <+> int n
, ppr md ]
pprPassDetails _ = Outputable.empty
data SimplMode -- See comments in GHC.Core.Op.Simplify.Monad
data SimplMode -- See comments in GHC.Core.Opt.Simplify.Monad
= SimplMode
{ sm_names :: [String] -- Name(s) of the phase
, sm_phase :: CompilerPhase
......@@ -194,7 +194,7 @@ data FloatOutSwitches = FloatOutSwitches {
-- ^ True <=> float out over-saturated applications
-- based on arity information.
-- See Note [Floating over-saturated applications]
-- in GHC.Core.Op.SetLevels
-- in GHC.Core.Opt.SetLevels
floatToTopLevelOnly :: Bool -- ^ Allow floating to the top level only.
instance Outputable FloatOutSwitches where
-- Created this hs-boot file to remove circular dependencies from the use of
-- Plugins. Plugins needs CoreToDo and CoreM types to define core-to-core
-- transformations.
-- However GHC.Core.Op.Monad does much more than defining these, and because Plugins are
-- However GHC.Core.Opt.Monad does much more than defining these, and because Plugins are
-- activated in various modules, the imports become circular. To solve this I
-- extracted CoreToDo and CoreM into this file.
-- I needed to write the whole definition of these types, otherwise it created
-- a data-newtype conflict.
module GHC.Core.Op.Monad ( CoreToDo, CoreM ) where
module GHC.Core.Opt.Monad ( CoreToDo, CoreM ) where
import GhcPrelude
......@@ -14,7 +14,7 @@ core expression with (hopefully) improved usage information.
{-# LANGUAGE CPP, BangPatterns, MultiWayIf, ViewPatterns #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
module GHC.Core.Op.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) where
module GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) where
#include "HsVersions.h"
......@@ -289,7 +289,7 @@ But what is the graph? NOT the same graph as was used for Note
'f' that is *always* inlined if it is applicable. We do *not* disable
rules for loop-breakers. It's up to whoever makes the rules to make
sure that the rules themselves always terminate. See Note [Rules for
recursive functions] in GHC.Core.Op.Simplify
recursive functions] in GHC.Core.Opt.Simplify
Hence, if
f's RHS (or its INLINE template if it has one) mentions g, and
......@@ -634,7 +634,7 @@ Consider this group, which is typical of what SpecConstr builds:
So 'f' and 'fs' are in the same Rec group (since f refers to fs via its RULE).
But watch out! If 'fs' is not chosen as a loop breaker, we may get an infinite loop:
- the RULE is applied in f's RHS (see Note [Self-recursive rules] in GHC.Core.Op.Simplify
- the RULE is applied in f's RHS (see Note [Self-recursive rules] in GHC.Core.Opt.Simplify
- fs is inlined (say it's small)
- now there's another opportunity to apply the RULE
......@@ -1689,7 +1689,7 @@ So, when analysing the RHS of x3 we notice that x3 will itself
definitely inline the next time round, and so we analyse x3's rhs in
an ordinary context, not rhsCtxt. Hence the "certainly_inline" stuff.