summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2019-12-23 23:15:25 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-12-31 14:22:32 -0500
commiteb6082358cdb5f271a8e4c74044a12f97352c52f (patch)
tree6d5aed29c2050081bd1283ba7d43ceb562ce6761
parent0d42b287c3fe2510433a7fb744531a0765ad8ac8 (diff)
downloadhaskell-eb6082358cdb5f271a8e4c74044a12f97352c52f.tar.gz
Module hierarchy (#13009): Stg
-rw-r--r--compiler/GHC/CoreToStg.hs (renamed from compiler/stgSyn/CoreToStg.hs)6
-rw-r--r--compiler/GHC/CoreToStg/Prep.hs (renamed from compiler/coreSyn/CorePrep.hs)2
-rw-r--r--compiler/GHC/Stg/CSE.hs (renamed from compiler/simplStg/StgCse.hs)4
-rw-r--r--compiler/GHC/Stg/FVs.hs (renamed from compiler/stgSyn/StgFVs.hs)4
-rw-r--r--compiler/GHC/Stg/Lift.hs (renamed from compiler/simplStg/StgLiftLams/Transformation.hs)117
-rw-r--r--compiler/GHC/Stg/Lift/Analysis.hs (renamed from compiler/simplStg/StgLiftLams/Analysis.hs)20
-rw-r--r--compiler/GHC/Stg/Lift/Monad.hs (renamed from compiler/simplStg/StgLiftLams/LiftM.hs)8
-rw-r--r--compiler/GHC/Stg/Lint.hs (renamed from compiler/stgSyn/StgLint.hs)6
-rw-r--r--compiler/GHC/Stg/Pipeline.hs (renamed from compiler/simplStg/SimplStg.hs)16
-rw-r--r--compiler/GHC/Stg/Stats.hs (renamed from compiler/simplStg/StgStats.hs)4
-rw-r--r--compiler/GHC/Stg/Subst.hs (renamed from compiler/stgSyn/StgSubst.hs)2
-rw-r--r--compiler/GHC/Stg/Syntax.hs (renamed from compiler/stgSyn/StgSyn.hs)6
-rw-r--r--compiler/GHC/Stg/Unarise.hs (renamed from compiler/simplStg/UnariseStg.hs)8
-rw-r--r--compiler/GHC/StgToCmm.hs6
-rw-r--r--compiler/GHC/StgToCmm/Bind.hs6
-rw-r--r--compiler/GHC/StgToCmm/Bind.hs-boot2
-rw-r--r--compiler/GHC/StgToCmm/Closure.hs10
-rw-r--r--compiler/GHC/StgToCmm/DataCon.hs4
-rw-r--r--compiler/GHC/StgToCmm/Env.hs2
-rw-r--r--compiler/GHC/StgToCmm/Expr.hs10
-rw-r--r--compiler/GHC/StgToCmm/Foreign.hs4
-rw-r--r--compiler/GHC/StgToCmm/Heap.hs2
-rw-r--r--compiler/GHC/StgToCmm/Layout.hs2
-rw-r--r--compiler/GHC/StgToCmm/Prim.hs2
-rw-r--r--compiler/GHC/StgToCmm/Ticky.hs2
-rw-r--r--compiler/GHC/StgToCmm/Utils.hs2
-rw-r--r--compiler/GHC/Types/RepType.hs (renamed from compiler/simplStg/RepType.hs)6
-rw-r--r--compiler/basicTypes/Id.hs2
-rw-r--r--compiler/cmm/CmmUtils.hs2
-rw-r--r--compiler/coreSyn/CoreLint.hs2
-rw-r--r--compiler/deSugar/DsForeign.hs2
-rw-r--r--compiler/ghc.cabal.in31
-rw-r--r--compiler/ghci/ByteCodeGen.hs2
-rw-r--r--compiler/ghci/ByteCodeItbls.hs2
-rw-r--r--compiler/ghci/RtClosureInspect.hs2
-rw-r--r--compiler/main/HscMain.hs10
-rw-r--r--compiler/main/InteractiveEval.hs2
-rw-r--r--compiler/main/TidyPgm.hs2
-rw-r--r--compiler/prelude/PrimOp.hs2
-rw-r--r--compiler/prelude/TysWiredIn.hs12
-rw-r--r--compiler/simplStg/StgLiftLams.hs102
-rw-r--r--compiler/stranal/WwLib.hs2
-rw-r--r--compiler/typecheck/TcType.hs2
-rw-r--r--compiler/types/TyCon.hs8
-rw-r--r--testsuite/tests/codeGen/should_run/T13825-unit.hs2
-rw-r--r--testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs2
46 files changed, 226 insertions, 228 deletions
diff --git a/compiler/stgSyn/CoreToStg.hs b/compiler/GHC/CoreToStg.hs
index 4982ad68f4..1ee5febd2e 100644
--- a/compiler/stgSyn/CoreToStg.hs
+++ b/compiler/GHC/CoreToStg.hs
@@ -11,7 +11,7 @@
-- And, as we have the info in hand, we may convert some lets to
-- let-no-escapes.
-module CoreToStg ( coreToStg ) where
+module GHC.CoreToStg ( coreToStg ) where
#include "HsVersions.h"
@@ -21,10 +21,10 @@ import CoreSyn
import CoreUtils ( exprType, findDefault, isJoinBind
, exprIsTickedString_maybe )
import CoreArity ( manifestArity )
-import StgSyn
+import GHC.Stg.Syntax
import Type
-import RepType
+import GHC.Types.RepType
import TyCon
import MkId ( coercionTokenId )
import Id
diff --git a/compiler/coreSyn/CorePrep.hs b/compiler/GHC/CoreToStg/Prep.hs
index 227ad8542c..ea020c5f9e 100644
--- a/compiler/coreSyn/CorePrep.hs
+++ b/compiler/GHC/CoreToStg/Prep.hs
@@ -7,7 +7,7 @@ Core pass to saturate constructors and PrimOps
{-# LANGUAGE BangPatterns, CPP, MultiWayIf #-}
-module CorePrep (
+module GHC.CoreToStg.Prep (
corePrepPgm, corePrepExpr, cvtLitInteger, cvtLitNatural,
lookupMkIntegerName, lookupIntegerSDataConName,
lookupMkNaturalName, lookupNaturalSDataConName
diff --git a/compiler/simplStg/StgCse.hs b/compiler/GHC/Stg/CSE.hs
index 269738e488..66f5004b49 100644
--- a/compiler/simplStg/StgCse.hs
+++ b/compiler/GHC/Stg/CSE.hs
@@ -84,13 +84,13 @@ Solution: do unarise first.
-}
-module StgCse (stgCse) where
+module GHC.Stg.CSE (stgCse) where
import GhcPrelude
import DataCon
import Id
-import StgSyn
+import GHC.Stg.Syntax
import Outputable
import VarEnv
import CoreSyn (AltCon(..))
diff --git a/compiler/stgSyn/StgFVs.hs b/compiler/GHC/Stg/FVs.hs
index ad02642aa9..65f80d97af 100644
--- a/compiler/stgSyn/StgFVs.hs
+++ b/compiler/GHC/Stg/FVs.hs
@@ -1,12 +1,12 @@
-- | Free variable analysis on STG terms.
-module StgFVs (
+module GHC.Stg.FVs (
annTopBindingsFreeVars,
annBindingFreeVars
) where
import GhcPrelude
-import StgSyn
+import GHC.Stg.Syntax
import Id
import VarSet
import CoreSyn ( Tickish(Breakpoint) )
diff --git a/compiler/simplStg/StgLiftLams/Transformation.hs b/compiler/GHC/Stg/Lift.hs
index bef39a1856..cafcafbd42 100644
--- a/compiler/simplStg/StgLiftLams/Transformation.hs
+++ b/compiler/GHC/Stg/Lift.hs
@@ -1,8 +1,19 @@
{-# LANGUAGE CPP #-}
--- | (Mostly) textbook instance of the lambda lifting transformation,
--- selecting which bindings to lambda lift by consulting 'goodToLift'.
-module StgLiftLams.Transformation (stgLiftLams) where
+-- | Implements a selective lambda lifter, running late in the optimisation
+-- pipeline.
+--
+-- If you are interested in the cost model that is employed to decide whether
+-- to lift a binding or not, look at "GHC.Stg.Lift.Analysis".
+-- "GHC.Stg.Lift.Monad" contains the transformation monad that hides away some
+-- plumbing of the transformation.
+module GHC.Stg.Lift
+ (
+ -- * Late lambda lifting in STG
+ -- $note
+ stgLiftLams
+ )
+where
#include "HsVersions.h"
@@ -12,10 +23,10 @@ import BasicTypes
import DynFlags
import Id
import IdInfo
-import StgFVs ( annBindingFreeVars )
-import StgLiftLams.Analysis
-import StgLiftLams.LiftM
-import StgSyn
+import GHC.Stg.FVs ( annBindingFreeVars )
+import GHC.Stg.Lift.Analysis
+import GHC.Stg.Lift.Monad
+import GHC.Stg.Syntax
import Outputable
import UniqSupply
import Util
@@ -23,7 +34,99 @@ import VarSet
import Control.Monad ( when )
import Data.Maybe ( isNothing )
+-- Note [Late lambda lifting in STG]
+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+-- $note
+-- See also the <https://gitlab.haskell.org/ghc/ghc/wikis/late-lam-lift wiki page>
+-- and #9476.
+--
+-- The basic idea behind lambda lifting is to turn locally defined functions
+-- into top-level functions. Free variables are then passed as additional
+-- arguments at *call sites* instead of having a closure allocated for them at
+-- *definition site*. Example:
+--
+-- @
+-- let x = ...; y = ... in
+-- let f = {x y} \a -> a + x + y in
+-- let g = {f x} \b -> f b + x in
+-- g 5
+-- @
+--
+-- Lambda lifting @f@ would
+--
+-- 1. Turn @f@'s free variables into formal parameters
+-- 2. Update @f@'s call site within @g@ to @f x y b@
+-- 3. Update @g@'s closure: Add @y@ as an additional free variable, while
+-- removing @f@, because @f@ no longer allocates and can be floated to
+-- top-level.
+-- 4. Actually float the binding of @f@ to top-level, eliminating the @let@
+-- in the process.
+--
+-- This results in the following program (with free var annotations):
+--
+-- @
+-- f x y a = a + x + y;
+-- let x = ...; y = ... in
+-- let g = {x y} \b -> f x y b + x in
+-- g 5
+-- @
+--
+-- This optimisation is all about lifting only when it is beneficial to do so.
+-- The above seems like a worthwhile lift, judging from heap allocation:
+-- We eliminate @f@'s closure, saving to allocate a closure with 2 words, while
+-- not changing the size of @g@'s closure.
+--
+-- You can probably sense that there's some kind of cost model at play here.
+-- And you are right! But we also employ a couple of other heuristics for the
+-- lifting decision which are outlined in "GHC.Stg.Lift.Analysis#when".
+--
+-- The transformation is done in "GHC.Stg.Lift", which calls out to
+-- 'GHC.Stg.Lift.Analysis.goodToLift' for its lifting decision. It relies on
+-- "GHC.Stg.Lift.Monad", which abstracts some subtle STG invariants into a
+-- monadic substrate.
+--
+-- Suffice to say: We trade heap allocation for stack allocation.
+-- The additional arguments have to passed on the stack (or in registers,
+-- depending on architecture) every time we call the function to save a single
+-- heap allocation when entering the let binding. Nofib suggests a mean
+-- improvement of about 1% for this pass, so it seems like a worthwhile thing to
+-- do. Compile-times went up by 0.6%, so all in all a very modest change.
+--
+-- For a concrete example, look at @spectral/atom@. There's a call to 'zipWith'
+-- that is ultimately compiled to something like this
+-- (module desugaring/lowering to actual STG):
+--
+-- @
+-- propagate dt = ...;
+-- runExperiment ... =
+-- let xs = ... in
+-- let ys = ... in
+-- let go = {dt go} \xs ys -> case (xs, ys) of
+-- ([], []) -> []
+-- (x:xs', y:ys') -> propagate dt x y : go xs' ys'
+-- in go xs ys
+-- @
+--
+-- This will lambda lift @go@ to top-level, speeding up the resulting program
+-- by roughly one percent:
+--
+-- @
+-- propagate dt = ...;
+-- go dt xs ys = case (xs, ys) of
+-- ([], []) -> []
+-- (x:xs', y:ys') -> propagate dt x y : go dt xs' ys'
+-- runExperiment ... =
+-- let xs = ... in
+-- let ys = ... in
+-- in go dt xs ys
+-- @
+
+
+
-- | Lambda lifts bindings to top-level deemed worth lifting (see 'goodToLift').
+--
+-- (Mostly) textbook instance of the lambda lifting transformation, selecting
+-- which bindings to lambda lift by consulting 'goodToLift'.
stgLiftLams :: DynFlags -> UniqSupply -> [InStgTopBinding] -> [OutStgTopBinding]
stgLiftLams dflags us = runLiftM dflags us . foldr liftTopLvl (pure ())
diff --git a/compiler/simplStg/StgLiftLams/Analysis.hs b/compiler/GHC/Stg/Lift/Analysis.hs
index 8bcd6f6cb5..02d439cef7 100644
--- a/compiler/simplStg/StgLiftLams/Analysis.hs
+++ b/compiler/GHC/Stg/Lift/Analysis.hs
@@ -5,7 +5,7 @@
-- | Provides the heuristics for when it's beneficial to lambda lift bindings.
-- Most significantly, this employs a cost model to estimate impact on heap
-- allocations, by looking at an STG expression's 'Skeleton'.
-module StgLiftLams.Analysis (
+module GHC.Stg.Lift.Analysis (
-- * #when# When to lift
-- $when
@@ -27,7 +27,7 @@ import Demand
import DynFlags
import Id
import SMRep ( WordOff )
-import StgSyn
+import GHC.Stg.Syntax
import qualified GHC.StgToCmm.ArgRep as StgToCmm.ArgRep
import qualified GHC.StgToCmm.Closure as StgToCmm.Closure
import qualified GHC.StgToCmm.Layout as StgToCmm.Layout
@@ -45,7 +45,7 @@ import Data.Maybe ( mapMaybe )
-- 1. It tags the syntax tree with analysis information in the form of
-- 'BinderInfo' at each binder and 'Skeleton's at each let-binding
-- by 'tagSkeletonTopBind' and friends.
--- 2. The resulting syntax tree is treated by the "StgLiftLams.Transformation"
+-- 2. The resulting syntax tree is treated by the "GHC.Stg.Lift"
-- module, calling out to 'goodToLift' to decide if a binding is worthwhile
-- to lift.
-- 'goodToLift' consults argument occurrence information in 'BinderInfo'
@@ -78,7 +78,7 @@ import Data.Maybe ( mapMaybe )
-- [Closure growth] introduced when former free variables have to be available
-- at call sites may actually lead to an increase in overall allocations
-- resulting from a lift. Estimating closure growth is described in
--- "StgLiftLams.Analysis#clogro" and is what most of this module is ultimately
+-- "GHC.Stg.Lift.Analysis#clogro" and is what most of this module is ultimately
-- concerned with.
--
-- There's a <https://gitlab.haskell.org/ghc/ghc/wikis/late-lam-lift wiki page> with
@@ -145,7 +145,7 @@ data BinderInfo
= BindsClosure !Id !Bool -- ^ Let(-no-escape)-bound thing with a flag
-- indicating whether it occurs as an argument
-- or in a nullary application
- -- (see "StgLiftLams.Analysis#arg_occs").
+ -- (see "GHC.Stg.Lift.Analysis#arg_occs").
| BoringBinder !Id -- ^ Every other kind of binder
-- | Gets the bound 'Id' out a 'BinderInfo'.
@@ -214,7 +214,7 @@ tagSkeletonTopBind bind = bind'
-- | Tags binders of an 'StgExpr' with its 'BinderInfo' and let bindings with
-- their 'Skeleton's. Additionally, returns its 'Skeleton' and the set of binder
-- occurrences in argument and nullary application position
--- (cf. "StgLiftLams.Analysis#arg_occs").
+-- (cf. "GHC.Stg.Lift.Analysis#arg_occs").
tagSkeletonExpr :: CgStgExpr -> (Skeleton, IdSet, LlStgExpr)
tagSkeletonExpr (StgLit lit)
= (NilSk, emptyVarSet, StgLit lit)
@@ -227,7 +227,7 @@ tagSkeletonExpr (StgApp f args)
where
arg_occs
-- This checks for nullary applications, which we treat the same as
- -- argument occurrences, see "StgLiftLams.Analysis#arg_occs".
+ -- argument occurrences, see "GHC.Stg.Lift.Analysis#arg_occs".
| null args = unitVarSet f
| otherwise = mkArgOccs args
tagSkeletonExpr (StgLam _ _) = pprPanic "stgLiftLams" (text "StgLam")
@@ -352,13 +352,13 @@ tagSkeletonAlt (con, bndrs, rhs)
arg_occs = alt_arg_occs `delVarSetList` bndrs
-- | Combines several heuristics to decide whether to lambda-lift a given
--- @let@-binding to top-level. See "StgLiftLams.Analysis#when" for details.
+-- @let@-binding to top-level. See "GHC.Stg.Lift.Analysis#when" for details.
goodToLift
:: DynFlags
-> TopLevelFlag
-> RecFlag
-> (DIdSet -> DIdSet) -- ^ An expander function, turning 'InId's into
- -- 'OutId's. See 'StgLiftLams.LiftM.liftedIdsExpander'.
+ -- 'OutId's. See 'GHC.Stg.Lift.Monad.liftedIdsExpander'.
-> [(BinderInfo, LlStgRhs)]
-> Skeleton
-> Maybe DIdSet -- ^ @Just abs_ids@ <=> This binding is beneficial to
@@ -507,7 +507,7 @@ idClosureFootprint dflags
-- | @closureGrowth expander sizer f fvs@ computes the closure growth in words
-- as a result of lifting @f@ to top-level. If there was any growing closure
-- under a multi-shot lambda, the result will be 'infinity'.
--- Also see "StgLiftLams.Analysis#clogro".
+-- Also see "GHC.Stg.Lift.Analysis#clogro".
closureGrowth
:: (DIdSet -> DIdSet)
-- ^ Expands outer free ids that were lifted to their free vars
diff --git a/compiler/simplStg/StgLiftLams/LiftM.hs b/compiler/GHC/Stg/Lift/Monad.hs
index 710eb1f289..7d17e53cd9 100644
--- a/compiler/simplStg/StgLiftLams/LiftM.hs
+++ b/compiler/GHC/Stg/Lift/Monad.hs
@@ -4,7 +4,7 @@
-- | Hides away distracting bookkeeping while lambda lifting into a 'LiftM'
-- monad.
-module StgLiftLams.LiftM (
+module GHC.Stg.Lift.Monad (
decomposeStgBinding, mkStgBinding,
Env (..),
-- * #floats# Handling floats
@@ -33,8 +33,8 @@ import IdInfo
import Name
import Outputable
import OrdList
-import StgSubst
-import StgSyn
+import GHC.Stg.Subst
+import GHC.Stg.Syntax
import Type
import UniqSupply
import Util
@@ -137,7 +137,7 @@ emptyEnv dflags = Env dflags emptySubst emptyVarEnv False
-- business and will just manipulate it indirectly through actions in 'LiftM'.
-- | We need to detect when we are lifting something out of the RHS of a
--- recursive binding (c.f. "StgLiftLams.LiftM#floats"), in which case that
+-- recursive binding (c.f. "GHC.Stg.Lift.Monad#floats"), in which case that
-- binding needs to be added to the same top-level recursive group. This
-- requires we detect a certain nesting structure, which is encoded by
-- 'StartBindingGroup' and 'EndBindingGroup'.
diff --git a/compiler/stgSyn/StgLint.hs b/compiler/GHC/Stg/Lint.hs
index f83b44859c..e7044a89e0 100644
--- a/compiler/stgSyn/StgLint.hs
+++ b/compiler/GHC/Stg/Lint.hs
@@ -35,11 +35,11 @@ basic properties listed above.
{-# LANGUAGE ScopedTypeVariables, FlexibleContexts, TypeFamilies,
DeriveFunctor #-}
-module StgLint ( lintStgTopBindings ) where
+module GHC.Stg.Lint ( lintStgTopBindings ) where
import GhcPrelude
-import StgSyn
+import GHC.Stg.Syntax
import DynFlags
import Bag ( Bag, emptyBag, isEmptyBag, snocBag, bagToList )
@@ -52,7 +52,7 @@ import CoreSyn ( AltCon(..) )
import Name ( getSrcLoc, nameIsLocalOrFrom )
import ErrUtils ( MsgDoc, Severity(..), mkLocMessage )
import Type
-import RepType
+import GHC.Types.RepType
import SrcLoc
import Outputable
import Module ( Module )
diff --git a/compiler/simplStg/SimplStg.hs b/compiler/GHC/Stg/Pipeline.hs
index 2b6eeded42..13b403fc53 100644
--- a/compiler/simplStg/SimplStg.hs
+++ b/compiler/GHC/Stg/Pipeline.hs
@@ -9,19 +9,19 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
-module SimplStg ( stg2stg ) where
+module GHC.Stg.Pipeline ( stg2stg ) where
#include "HsVersions.h"
import GhcPrelude
-import StgSyn
+import GHC.Stg.Syntax
-import StgLint ( lintStgTopBindings )
-import StgStats ( showStgStats )
-import UnariseStg ( unarise )
-import StgCse ( stgCse )
-import StgLiftLams ( stgLiftLams )
+import GHC.Stg.Lint ( lintStgTopBindings )
+import GHC.Stg.Stats ( showStgStats )
+import GHC.Stg.Unarise ( unarise )
+import GHC.Stg.CSE ( stgCse )
+import GHC.Stg.Lift ( stgLiftLams )
import Module ( Module )
import DynFlags
@@ -128,7 +128,7 @@ getStgToDo dflags =
filter (/= StgDoNothing)
[ mandatory StgUnarise
-- Important that unarisation comes first
- -- See Note [StgCse after unarisation] in StgCse
+ -- See Note [StgCse after unarisation] in GHC.Stg.CSE
, optional Opt_StgCSE StgCSE
, optional Opt_StgLiftLams StgLiftLams
, optional Opt_StgStats StgStats
diff --git a/compiler/simplStg/StgStats.hs b/compiler/GHC/Stg/Stats.hs
index 05a0cf988a..c70184e60b 100644
--- a/compiler/simplStg/StgStats.hs
+++ b/compiler/GHC/Stg/Stats.hs
@@ -23,13 +23,13 @@ The program gather statistics about
{-# LANGUAGE CPP #-}
-module StgStats ( showStgStats ) where
+module GHC.Stg.Stats ( showStgStats ) where
#include "HsVersions.h"
import GhcPrelude
-import StgSyn
+import GHC.Stg.Syntax
import Id (Id)
import Panic
diff --git a/compiler/stgSyn/StgSubst.hs b/compiler/GHC/Stg/Subst.hs
index 0616c6c529..84b9f29c3c 100644
--- a/compiler/stgSyn/StgSubst.hs
+++ b/compiler/GHC/Stg/Subst.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE CPP #-}
-module StgSubst where
+module GHC.Stg.Subst where
#include "HsVersions.h"
diff --git a/compiler/stgSyn/StgSyn.hs b/compiler/GHC/Stg/Syntax.hs
index 052ef2b6c7..b82fea5de2 100644
--- a/compiler/stgSyn/StgSyn.hs
+++ b/compiler/GHC/Stg/Syntax.hs
@@ -19,7 +19,7 @@ generation.
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ConstraintKinds #-}
-module StgSyn (
+module GHC.Stg.Syntax (
StgArg(..),
GenStgTopBinding(..), GenStgBinding(..), GenStgExpr(..), GenStgRhs(..),
@@ -81,7 +81,7 @@ import PprCore ( {- instances -} )
import PrimOp ( PrimOp, PrimCall )
import TyCon ( PrimRep(..), TyCon )
import Type ( Type )
-import RepType ( typePrimRep1 )
+import GHC.Types.RepType ( typePrimRep1 )
import Util
import Data.List.NonEmpty ( NonEmpty, toList )
@@ -238,7 +238,7 @@ literals.
-- which can't be let-bound
| StgConApp DataCon
[StgArg] -- Saturated
- [Type] -- See Note [Types in StgConApp] in UnariseStg
+ [Type] -- See Note [Types in StgConApp] in GHC.Stg.Unarise
| StgOpApp StgOp -- Primitive op or foreign call
[StgArg] -- Saturated.
diff --git a/compiler/simplStg/UnariseStg.hs b/compiler/GHC/Stg/Unarise.hs
index 0bfc15645c..bc2ce4cb87 100644
--- a/compiler/simplStg/UnariseStg.hs
+++ b/compiler/GHC/Stg/Unarise.hs
@@ -194,7 +194,7 @@ STG programs after unarisation have these invariants:
{-# LANGUAGE CPP, TupleSections #-}
-module UnariseStg (unarise) where
+module GHC.Stg.Unarise (unarise) where
#include "HsVersions.h"
@@ -210,8 +210,8 @@ import MkCore (aBSENT_SUM_FIELD_ERROR_ID)
import MkId (voidPrimId, voidArgId)
import MonadUtils (mapAccumLM)
import Outputable
-import RepType
-import StgSyn
+import GHC.Types.RepType
+import GHC.Stg.Syntax
import Type
import TysPrim (intPrimTy,wordPrimTy,word64PrimTy)
import TysWiredIn
@@ -353,7 +353,7 @@ unariseExpr rho (StgCase scrut bndr alt_ty alts)
alts' <- unariseAlts rho alt_ty bndr alts
return (StgCase scrut' bndr alt_ty alts')
-- bndr may have a unboxed sum/tuple type but it will be
- -- dead after unarise (checked in StgLint)
+ -- dead after unarise (checked in GHC.Stg.Lint)
unariseExpr rho (StgLet ext bind e)
= StgLet ext <$> unariseBinding rho bind <*> unariseExpr rho e
diff --git a/compiler/GHC/StgToCmm.hs b/compiler/GHC/StgToCmm.hs
index f02d361fa4..10a9dc2c6a 100644
--- a/compiler/GHC/StgToCmm.hs
+++ b/compiler/GHC/StgToCmm.hs
@@ -30,7 +30,7 @@ import Cmm
import CmmUtils
import CLabel
-import StgSyn
+import GHC.Stg.Syntax
import DynFlags
import ErrUtils
@@ -38,7 +38,7 @@ import HscTypes
import CostCentre
import Id
import IdInfo
-import RepType
+import GHC.Types.RepType
import DataCon
import TyCon
import Module
@@ -147,7 +147,7 @@ cgTopRhs :: DynFlags -> RecFlag -> Id -> CgStgRhs -> (CgIdInfo, FCode ())
cgTopRhs dflags _rec bndr (StgRhsCon _cc con args)
= cgTopRhsCon dflags bndr con (assertNonVoidStgArgs args)
-- con args are always non-void,
- -- see Note [Post-unarisation invariants] in UnariseStg
+ -- see Note [Post-unarisation invariants] in GHC.Stg.Unarise
cgTopRhs dflags rec bndr (StgRhsClosure fvs cc upd_flag args body)
= ASSERT(isEmptyDVarSet fvs) -- There should be no free variables
diff --git a/compiler/GHC/StgToCmm/Bind.hs b/compiler/GHC/StgToCmm/Bind.hs
index d373b79d0c..3eeb575da7 100644
--- a/compiler/GHC/StgToCmm/Bind.hs
+++ b/compiler/GHC/StgToCmm/Bind.hs
@@ -36,7 +36,7 @@ import Cmm
import CmmInfo
import CmmUtils
import CLabel
-import StgSyn
+import GHC.Stg.Syntax
import CostCentre
import Id
import IdInfo
@@ -206,7 +206,7 @@ cgRhs id (StgRhsCon cc con args)
= withNewTickyCounterCon (idName id) $
buildDynCon id True cc con (assertNonVoidStgArgs args)
-- con args are always non-void,
- -- see Note [Post-unarisation invariants] in UnariseStg
+ -- see Note [Post-unarisation invariants] in GHC.Stg.Unarise
{- See Note [GC recovery] in compiler/GHC.StgToCmm/Closure.hs -}
cgRhs id (StgRhsClosure fvs cc upd_flag args body)
@@ -275,7 +275,7 @@ mkRhsClosure dflags bndr _cc
, let (_, _, params_w_offsets) = mkVirtConstrOffsets dflags (addIdReps (assertNonVoidIds params))
-- pattern binders are always non-void,
- -- see Note [Post-unarisation invariants] in UnariseStg
+ -- see Note [Post-unarisation invariants] in GHC.Stg.Unarise
, Just the_offset <- assocMaybe params_w_offsets (NonVoid selectee)
, let offset_into_int = bytesToWordsRoundUp dflags the_offset
diff --git a/compiler/GHC/StgToCmm/Bind.hs-boot b/compiler/GHC/StgToCmm/Bind.hs-boot
index d16c34ebd3..6e8b2bdf7a 100644
--- a/compiler/GHC/StgToCmm/Bind.hs-boot
+++ b/compiler/GHC/StgToCmm/Bind.hs-boot
@@ -1,6 +1,6 @@
module GHC.StgToCmm.Bind where
import GHC.StgToCmm.Monad( FCode )
-import StgSyn( CgStgBinding )
+import GHC.Stg.Syntax( CgStgBinding )
cgBind :: CgStgBinding -> FCode ()
diff --git a/compiler/GHC/StgToCmm/Closure.hs b/compiler/GHC/StgToCmm/Closure.hs
index 07d3edab9a..df8cb046c4 100644
--- a/compiler/GHC/StgToCmm/Closure.hs
+++ b/compiler/GHC/StgToCmm/Closure.hs
@@ -66,7 +66,7 @@ module GHC.StgToCmm.Closure (
import GhcPrelude
-import StgSyn
+import GHC.Stg.Syntax
import SMRep
import Cmm
import PprCmmExpr() -- For Outputable instances
@@ -82,7 +82,7 @@ import Type
import TyCoRep
import TcType
import TyCon
-import RepType
+import GHC.Types.RepType
import BasicTypes
import Outputable
import DynFlags
@@ -142,7 +142,7 @@ nonVoidIds ids = [NonVoid id | id <- ids, not (isVoidTy (idType id))]
-- | Used in places where some invariant ensures that all these Ids are
-- non-void; e.g. constructor field binders in case expressions.
--- See Note [Post-unarisation invariants] in UnariseStg.
+-- See Note [Post-unarisation invariants] in GHC.Stg.Unarise.
assertNonVoidIds :: [Id] -> [NonVoid Id]
assertNonVoidIds ids = ASSERT(not (any (isVoidTy . idType) ids))
coerce ids
@@ -152,7 +152,7 @@ nonVoidStgArgs args = [NonVoid arg | arg <- args, not (isVoidTy (stgArgType arg)
-- | Used in places where some invariant ensures that all these arguments are
-- non-void; e.g. constructor arguments.
--- See Note [Post-unarisation invariants] in UnariseStg.
+-- See Note [Post-unarisation invariants] in GHC.Stg.Unarise.
assertNonVoidStgArgs :: [StgArg] -> [NonVoid StgArg]
assertNonVoidStgArgs args = ASSERT(not (any (isVoidTy . stgArgType) args))
coerce args
@@ -169,7 +169,7 @@ assertNonVoidStgArgs args = ASSERT(not (any (isVoidTy . stgArgType) args))
-- See Note [Post-unarisation invariants]
idPrimRep :: Id -> PrimRep
idPrimRep id = typePrimRep1 (idType id)
- -- See also Note [VoidRep] in RepType
+ -- See also Note [VoidRep] in GHC.Types.RepType
-- | Assumes that Ids have one PrimRep, which holds after unarisation.
-- See Note [Post-unarisation invariants]
diff --git a/compiler/GHC/StgToCmm/DataCon.hs b/compiler/GHC/StgToCmm/DataCon.hs
index c7ad444e41..1e929663df 100644
--- a/compiler/GHC/StgToCmm/DataCon.hs
+++ b/compiler/GHC/StgToCmm/DataCon.hs
@@ -19,7 +19,7 @@ module GHC.StgToCmm.DataCon (
import GhcPrelude
-import StgSyn
+import GHC.Stg.Syntax
import CoreSyn ( AltCon(..) )
import GHC.StgToCmm.Monad
@@ -40,7 +40,7 @@ import DataCon
import DynFlags
import FastString
import Id
-import RepType (countConRepArgs)
+import GHC.Types.RepType (countConRepArgs)
import Literal
import PrelInfo
import Outputable
diff --git a/compiler/GHC/StgToCmm/Env.hs b/compiler/GHC/StgToCmm/Env.hs
index e32c6a1ecb..45b09a3d26 100644
--- a/compiler/GHC/StgToCmm/Env.hs
+++ b/compiler/GHC/StgToCmm/Env.hs
@@ -41,7 +41,7 @@ import Id
import MkGraph
import Name
import Outputable
-import StgSyn
+import GHC.Stg.Syntax
import Type
import TysPrim
import UniqFM
diff --git a/compiler/GHC/StgToCmm/Expr.hs b/compiler/GHC/StgToCmm/Expr.hs
index 38d35fc031..f39d02839c 100644
--- a/compiler/GHC/StgToCmm/Expr.hs
+++ b/compiler/GHC/StgToCmm/Expr.hs
@@ -28,7 +28,7 @@ import GHC.StgToCmm.Ticky
import GHC.StgToCmm.Utils
import GHC.StgToCmm.Closure
-import StgSyn
+import GHC.Stg.Syntax
import MkGraph
import BlockId
@@ -42,7 +42,7 @@ import Id
import PrimOp
import TyCon
import Type ( isUnliftedType )
-import RepType ( isVoidTy, countConRepArgs )
+import GHC.Types.RepType ( isVoidTy, countConRepArgs )
import CostCentre ( CostCentreStack, currentCCS )
import Maybes
import Util
@@ -585,7 +585,7 @@ isSimpleOp (StgPrimCallOp _) _ = return False
chooseReturnBndrs :: Id -> AltType -> [CgStgAlt] -> [NonVoid Id]
-- These are the binders of a case that are assigned by the evaluation of the
-- scrutinee.
--- They're non-void, see Note [Post-unarisation invariants] in UnariseStg.
+-- They're non-void, see Note [Post-unarisation invariants] in GHC.Stg.Unarise.
chooseReturnBndrs bndr (PrimAlt _) _alts
= assertNonVoidIds [bndr]
@@ -882,7 +882,7 @@ cgAltRhss gc_plan bndr alts = do
maybeAltHeapCheck gc_plan $
do { _ <- bindConArgs con base_reg (assertNonVoidIds bndrs)
-- alt binders are always non-void,
- -- see Note [Post-unarisation invariants] in UnariseStg
+ -- see Note [Post-unarisation invariants] in GHC.Stg.Unarise
; _ <- cgExpr rhs
; return con }
forkAlts (map cg_alt alts)
@@ -910,7 +910,7 @@ cgConApp con stg_args
do { (idinfo, fcode_init) <- buildDynCon (dataConWorkId con) False
currentCCS con (assertNonVoidStgArgs stg_args)
-- con args are always non-void,
- -- see Note [Post-unarisation invariants] in UnariseStg
+ -- see Note [Post-unarisation invariants] in GHC.Stg.Unarise
-- The first "con" says that the name bound to this
-- closure is "con", which is a bit of a fudge, but
-- it only affects profiling (hence the False)
diff --git a/compiler/GHC/StgToCmm/Foreign.hs b/compiler/GHC/StgToCmm/Foreign.hs
index dacaff41ba..3ef0872c2e 100644
--- a/compiler/GHC/StgToCmm/Foreign.hs
+++ b/compiler/GHC/StgToCmm/Foreign.hs
@@ -20,7 +20,7 @@ module GHC.StgToCmm.Foreign (
import GhcPrelude hiding( succ, (<*>) )
-import StgSyn
+import GHC.Stg.Syntax
import GHC.StgToCmm.Prof (storeCurCCS, ccsType)
import GHC.StgToCmm.Env
import GHC.StgToCmm.Monad
@@ -33,7 +33,7 @@ import Cmm
import CmmUtils
import MkGraph
import Type
-import RepType
+import GHC.Types.RepType
import CLabel
import SMRep
import ForeignCall
diff --git a/compiler/GHC/StgToCmm/Heap.hs b/compiler/GHC/StgToCmm/Heap.hs
index a1f016c13c..d36cad5788 100644
--- a/compiler/GHC/StgToCmm/Heap.hs
+++ b/compiler/GHC/StgToCmm/Heap.hs
@@ -22,7 +22,7 @@ module GHC.StgToCmm.Heap (
import GhcPrelude hiding ((<*>))
-import StgSyn
+import GHC.Stg.Syntax
import CLabel
import GHC.StgToCmm.Layout
import GHC.StgToCmm.Utils
diff --git a/compiler/GHC/StgToCmm/Layout.hs b/compiler/GHC/StgToCmm/Layout.hs
index f4834376ed..6d7825eb93 100644
--- a/compiler/GHC/StgToCmm/Layout.hs
+++ b/compiler/GHC/StgToCmm/Layout.hs
@@ -48,7 +48,7 @@ import Cmm
import CmmUtils
import CmmInfo
import CLabel
-import StgSyn
+import GHC.Stg.Syntax
import Id
import TyCon ( PrimRep(..), primRepSizeB )
import BasicTypes ( RepArity )
diff --git a/compiler/GHC/StgToCmm/Prim.hs b/compiler/GHC/StgToCmm/Prim.hs
index 3728c0cac2..85924d984e 100644
--- a/compiler/GHC/StgToCmm/Prim.hs
+++ b/compiler/GHC/StgToCmm/Prim.hs
@@ -40,7 +40,7 @@ import GHC.Platform
import BasicTypes
import BlockId
import MkGraph
-import StgSyn
+import GHC.Stg.Syntax
import Cmm
import Module ( rtsUnitId )
import Type ( Type, tyConAppTyCon )
diff --git a/compiler/GHC/StgToCmm/Ticky.hs b/compiler/GHC/StgToCmm/Ticky.hs
index 7548f3de13..9eeb134cc9 100644
--- a/compiler/GHC/StgToCmm/Ticky.hs
+++ b/compiler/GHC/StgToCmm/Ticky.hs
@@ -111,7 +111,7 @@ import GHC.StgToCmm.Closure
import GHC.StgToCmm.Utils
import GHC.StgToCmm.Monad
-import StgSyn
+import GHC.Stg.Syntax
import CmmExpr
import MkGraph
import CmmUtils
diff --git a/compiler/GHC/StgToCmm/Utils.hs b/compiler/GHC/StgToCmm/Utils.hs
index 0b3a8d8b08..34fb93468c 100644
--- a/compiler/GHC/StgToCmm/Utils.hs
+++ b/compiler/GHC/StgToCmm/Utils.hs
@@ -75,7 +75,7 @@ import UniqSupply (MonadUnique(..))
import DynFlags
import FastString
import Outputable
-import RepType
+import GHC.Types.RepType
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as BS8
diff --git a/compiler/simplStg/RepType.hs b/compiler/GHC/Types/RepType.hs
index e6eb907f19..cdda659688 100644
--- a/compiler/simplStg/RepType.hs
+++ b/compiler/GHC/Types/RepType.hs
@@ -1,7 +1,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
-module RepType
+module GHC.Types.RepType
(
-- * Code generator views onto Types
UnaryType, NvUnaryType, isNvUnaryType,
@@ -133,7 +133,7 @@ isVoidTy = null . typePrimRep
{- **********************************************************************
* *
Unboxed sums
- See Note [Translating unboxed sums to unboxed tuples] in UnariseStg.hs
+ See Note [Translating unboxed sums to unboxed tuples] in GHC.Stg.Unarise
* *
********************************************************************** -}
@@ -366,7 +366,7 @@ data RuntimeRep = VecRep VecCount VecElem -- ^ a SIMD vector type
It's all in 1-1 correspondence with PrimRep except for TupleRep and SumRep,
which describe unboxed products and sums respectively. RuntimeRep is defined
in the library ghc-prim:GHC.Types. It is also "wired-in" to GHC: see
-TysWiredIn.runtimeRepTyCon. The unarisation pass, in StgUnarise, transforms the
+TysWiredIn.runtimeRepTyCon. The unarisation pass, in GHC.Stg.Unarise, transforms the
program, so that that every variable has a type that has a PrimRep. For
example, unarisation transforms our utup function above, to take two Int
arguments instead of one (# Int, Int #) argument.
diff --git a/compiler/basicTypes/Id.hs b/compiler/basicTypes/Id.hs
index c8872a30e7..d29a25cc02 100644
--- a/compiler/basicTypes/Id.hs
+++ b/compiler/basicTypes/Id.hs
@@ -133,7 +133,7 @@ import Var( Id, CoVar, JoinId,
import qualified Var
import Type
-import RepType
+import GHC.Types.RepType
import TysPrim
import DataCon
import Demand
diff --git a/compiler/cmm/CmmUtils.hs b/compiler/cmm/CmmUtils.hs
index 1a28f94a0c..8920d2d6b9 100644
--- a/compiler/cmm/CmmUtils.hs
+++ b/compiler/cmm/CmmUtils.hs
@@ -71,7 +71,7 @@ module CmmUtils(
import GhcPrelude
import TyCon ( PrimRep(..), PrimElemRep(..) )
-import RepType ( UnaryType, SlotTy (..), typePrimRep1 )
+import GHC.Types.RepType ( UnaryType, SlotTy (..), typePrimRep1 )
import SMRep
import Cmm
diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs
index 6f551c009f..4aeb2cf698 100644
--- a/compiler/coreSyn/CoreLint.hs
+++ b/compiler/coreSyn/CoreLint.hs
@@ -47,7 +47,7 @@ import ErrUtils
import Coercion
import SrcLoc
import Type
-import RepType
+import GHC.Types.RepType
import TyCoRep -- checks validity of types/coercions
import TyCoSubst
import TyCoFVs
diff --git a/compiler/deSugar/DsForeign.hs b/compiler/deSugar/DsForeign.hs
index 999fe02e12..0a3755e94b 100644
--- a/compiler/deSugar/DsForeign.hs
+++ b/compiler/deSugar/DsForeign.hs
@@ -31,7 +31,7 @@ import Literal
import Module
import Name
import Type
-import RepType
+import GHC.Types.RepType
import TyCon
import Coercion
import TcEnv
diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in
index 2d3e3254ff..7fd83c9d8b 100644
--- a/compiler/ghc.cabal.in
+++ b/compiler/ghc.cabal.in
@@ -175,9 +175,7 @@ Library
profiling
rename
simplCore
- simplStg
specialise
- stgSyn
stranal
typecheck
types
@@ -311,7 +309,6 @@ Library
CoreArity
CoreFVs
CoreLint
- CorePrep
CoreSubst
CoreOpt
CoreSyn
@@ -454,23 +451,23 @@ Library
SimplMonad
SimplUtils
Simplify
- SimplStg
- StgStats
- StgCse
- StgLiftLams
- StgLiftLams.Analysis
- StgLiftLams.LiftM
- StgLiftLams.Transformation
- StgSubst
- UnariseStg
- RepType
+ GHC.Stg.Pipeline
+ GHC.Stg.Stats
+ GHC.Stg.CSE
+ GHC.Stg.Lift
+ GHC.Stg.Lift.Analysis
+ GHC.Stg.Lift.Monad
+ GHC.Stg.Subst
+ GHC.Stg.Unarise
+ GHC.Stg.Lint
+ GHC.Stg.Syntax
+ GHC.Stg.FVs
+ GHC.CoreToStg
+ GHC.CoreToStg.Prep
+ GHC.Types.RepType
Rules
SpecConstr
Specialise
- CoreToStg
- StgLint
- StgSyn
- StgFVs
CallArity
DmdAnal
Exitify
diff --git a/compiler/ghci/ByteCodeGen.hs b/compiler/ghci/ByteCodeGen.hs
index 4a8e138daf..90931a4d74 100644
--- a/compiler/ghci/ByteCodeGen.hs
+++ b/compiler/ghci/ByteCodeGen.hs
@@ -37,7 +37,7 @@ import Literal
import PrimOp
import CoreFVs
import Type
-import RepType
+import GHC.Types.RepType
import DataCon
import TyCon
import Util
diff --git a/compiler/ghci/ByteCodeItbls.hs b/compiler/ghci/ByteCodeItbls.hs
index 11d90bf5ed..2138482051 100644
--- a/compiler/ghci/ByteCodeItbls.hs
+++ b/compiler/ghci/ByteCodeItbls.hs
@@ -19,7 +19,7 @@ import Name ( Name, getName )
import NameEnv
import DataCon ( DataCon, dataConRepArgTys, dataConIdentity )
import TyCon ( TyCon, tyConFamilySize, isDataTyCon, tyConDataCons )
-import RepType
+import GHC.Types.RepType
import GHC.StgToCmm.Layout ( mkVirtConstrSizes )
import GHC.StgToCmm.Closure ( tagForCon, NonVoid (..) )
import Util
diff --git a/compiler/ghci/RtClosureInspect.hs b/compiler/ghci/RtClosureInspect.hs
index 9fe18a57cf..da60eff5b6 100644
--- a/compiler/ghci/RtClosureInspect.hs
+++ b/compiler/ghci/RtClosureInspect.hs
@@ -33,7 +33,7 @@ import HscTypes
import DataCon
import Type
-import RepType
+import GHC.Types.RepType
import qualified Unify as U
import Var
import TcRnMonad
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index 81f3caa033..016cad9303 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -123,16 +123,16 @@ import MkIface
import Desugar
import SimplCore
import TidyPgm
-import CorePrep
-import CoreToStg ( coreToStg )
+import GHC.CoreToStg.Prep
+import GHC.CoreToStg ( coreToStg )
+import GHC.Stg.Syntax
+import GHC.Stg.FVs ( annTopBindingsFreeVars )
+import GHC.Stg.Pipeline ( stg2stg )
import qualified GHC.StgToCmm as StgToCmm ( codeGen )
-import StgSyn
-import StgFVs ( annTopBindingsFreeVars )
import CostCentre
import ProfInit
import TyCon
import Name
-import SimplStg ( stg2stg )
import Cmm
import CmmParse ( parseCmmFile )
import CmmBuildInfoTables
diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs
index ac48c3f24f..eefa93ea02 100644
--- a/compiler/main/InteractiveEval.hs
+++ b/compiler/main/InteractiveEval.hs
@@ -61,7 +61,7 @@ import FamInstEnv ( FamInst )
import CoreFVs ( orphNamesOfFamInst )
import TyCon
import Type hiding( typeKind )
-import RepType
+import GHC.Types.RepType
import TcType
import Constraint
import TcOrigin
diff --git a/compiler/main/TidyPgm.hs b/compiler/main/TidyPgm.hs
index 47e89560b2..e94e0aaac0 100644
--- a/compiler/main/TidyPgm.hs
+++ b/compiler/main/TidyPgm.hs
@@ -21,7 +21,7 @@ import CoreUnfold
import CoreFVs
import CoreTidy
import CoreMonad
-import CorePrep
+import GHC.CoreToStg.Prep
import CoreUtils (rhsIsStatic)
import CoreStats (coreBindsStats, CoreStats(..))
import CoreSeq (seqBinds)
diff --git a/compiler/prelude/PrimOp.hs b/compiler/prelude/PrimOp.hs
index f338a6094f..55a8bf339f 100644
--- a/compiler/prelude/PrimOp.hs
+++ b/compiler/prelude/PrimOp.hs
@@ -38,7 +38,7 @@ import Name
import PrelNames ( gHC_PRIMOPWRAPPERS )
import TyCon ( TyCon, isPrimTyCon, PrimRep(..) )
import Type
-import RepType ( typePrimRep1, tyConPrimRep1 )
+import GHC.Types.RepType ( typePrimRep1, tyConPrimRep1 )
import BasicTypes ( Arity, Fixity(..), FixityDirection(..), Boxity(..),
SourceText(..) )
import SrcLoc ( wiredInSrcSpan )
diff --git a/compiler/prelude/TysWiredIn.hs b/compiler/prelude/TysWiredIn.hs
index ba427efee7..f4db7572c0 100644
--- a/compiler/prelude/TysWiredIn.hs
+++ b/compiler/prelude/TysWiredIn.hs
@@ -144,7 +144,7 @@ import Id
import Constants ( mAX_TUPLE_SIZE, mAX_CTUPLE_SIZE, mAX_SUM_SIZE )
import Module ( Module )
import Type
-import RepType
+import GHC.Types.RepType
import DataCon
import {-# SOURCE #-} ConLike
import TyCon
@@ -184,7 +184,7 @@ kept in sync with each other. The rule is this: use the order as declared
in GHC.Types. All places where such lists exist should contain a reference
to this Note, so a search for this Note's name should find all the lists.
-See also Note [Getting from RuntimeRep to PrimRep] in RepType.
+See also Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType.
************************************************************************
* *
@@ -1185,7 +1185,7 @@ vecRepDataCon = pcSpecialDataCon vecRepDataConName [ mkTyConTy vecCountTyCon
runtimeRepTyCon
(RuntimeRep prim_rep_fun)
where
- -- See Note [Getting from RuntimeRep to PrimRep] in RepType
+ -- See Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType
prim_rep_fun [count, elem]
| VecCount n <- tyConRuntimeRepInfo (tyConAppTyCon count)
, VecElem e <- tyConRuntimeRepInfo (tyConAppTyCon elem)
@@ -1200,7 +1200,7 @@ tupleRepDataCon :: DataCon
tupleRepDataCon = pcSpecialDataCon tupleRepDataConName [ mkListTy runtimeRepTy ]
runtimeRepTyCon (RuntimeRep prim_rep_fun)
where
- -- See Note [Getting from RuntimeRep to PrimRep] in RepType
+ -- See Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType
prim_rep_fun [rr_ty_list]
= concatMap (runtimeRepPrimRep doc) rr_tys
where
@@ -1216,7 +1216,7 @@ sumRepDataCon :: DataCon
sumRepDataCon = pcSpecialDataCon sumRepDataConName [ mkListTy runtimeRepTy ]
runtimeRepTyCon (RuntimeRep prim_rep_fun)
where
- -- See Note [Getting from RuntimeRep to PrimRep] in RepType
+ -- See Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType
prim_rep_fun [rr_ty_list]
= map slotPrimRep (ubxSumRepType prim_repss)
where
@@ -1230,7 +1230,7 @@ sumRepDataConTyCon :: TyCon
sumRepDataConTyCon = promoteDataCon sumRepDataCon
-- See Note [Wiring in RuntimeRep]
--- See Note [Getting from RuntimeRep to PrimRep] in RepType
+-- See Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType
runtimeRepSimpleDataCons :: [DataCon]
liftedRepDataCon :: DataCon
runtimeRepSimpleDataCons@(liftedRepDataCon : _)
diff --git a/compiler/simplStg/StgLiftLams.hs b/compiler/simplStg/StgLiftLams.hs
deleted file mode 100644
index c3a9c8a478..0000000000
--- a/compiler/simplStg/StgLiftLams.hs
+++ /dev/null
@@ -1,102 +0,0 @@
--- | Implements a selective lambda lifter, running late in the optimisation
--- pipeline.
---
--- The transformation itself is implemented in "StgLiftLams.Transformation".
--- If you are interested in the cost model that is employed to decide whether
--- to lift a binding or not, look at "StgLiftLams.Analysis".
--- "StgLiftLams.LiftM" contains the transformation monad that hides away some
--- plumbing of the transformation.
-module StgLiftLams (
- -- * Late lambda lifting in STG
- -- $note
- Transformation.stgLiftLams
- ) where
-
-import qualified StgLiftLams.Transformation as Transformation
-
--- Note [Late lambda lifting in STG]
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- $note
--- See also the <https://gitlab.haskell.org/ghc/ghc/wikis/late-lam-lift wiki page>
--- and #9476.
---
--- The basic idea behind lambda lifting is to turn locally defined functions
--- into top-level functions. Free variables are then passed as additional
--- arguments at *call sites* instead of having a closure allocated for them at
--- *definition site*. Example:
---
--- @
--- let x = ...; y = ... in
--- let f = {x y} \a -> a + x + y in
--- let g = {f x} \b -> f b + x in
--- g 5
--- @
---
--- Lambda lifting @f@ would
---
--- 1. Turn @f@'s free variables into formal parameters
--- 2. Update @f@'s call site within @g@ to @f x y b@
--- 3. Update @g@'s closure: Add @y@ as an additional free variable, while
--- removing @f@, because @f@ no longer allocates and can be floated to
--- top-level.
--- 4. Actually float the binding of @f@ to top-level, eliminating the @let@
--- in the process.
---
--- This results in the following program (with free var annotations):
---
--- @
--- f x y a = a + x + y;
--- let x = ...; y = ... in
--- let g = {x y} \b -> f x y b + x in
--- g 5
--- @
---
--- This optimisation is all about lifting only when it is beneficial to do so.
--- The above seems like a worthwhile lift, judging from heap allocation:
--- We eliminate @f@'s closure, saving to allocate a closure with 2 words, while
--- not changing the size of @g@'s closure.
---
--- You can probably sense that there's some kind of cost model at play here.
--- And you are right! But we also employ a couple of other heuristics for the
--- lifting decision which are outlined in "StgLiftLams.Analysis#when".
---
--- The transformation is done in "StgLiftLams.Transformation", which calls out
--- to 'StgLiftLams.Analysis.goodToLift' for its lifting decision.
--- It relies on "StgLiftLams.LiftM", which abstracts some subtle STG invariants
--- into a monadic substrate.
---
--- Suffice to say: We trade heap allocation for stack allocation.
--- The additional arguments have to passed on the stack (or in registers,
--- depending on architecture) every time we call the function to save a single
--- heap allocation when entering the let binding. Nofib suggests a mean
--- improvement of about 1% for this pass, so it seems like a worthwhile thing to
--- do. Compile-times went up by 0.6%, so all in all a very modest change.
---
--- For a concrete example, look at @spectral/atom@. There's a call to 'zipWith'
--- that is ultimately compiled to something like this
--- (module desugaring/lowering to actual STG):
---
--- @
--- propagate dt = ...;
--- runExperiment ... =
--- let xs = ... in
--- let ys = ... in
--- let go = {dt go} \xs ys -> case (xs, ys) of
--- ([], []) -> []
--- (x:xs', y:ys') -> propagate dt x y : go xs' ys'
--- in go xs ys
--- @
---
--- This will lambda lift @go@ to top-level, speeding up the resulting program
--- by roughly one percent:
---
--- @
--- propagate dt = ...;
--- go dt xs ys = case (xs, ys) of
--- ([], []) -> []
--- (x:xs', y:ys') -> propagate dt x y : go dt xs' ys'
--- runExperiment ... =
--- let xs = ... in
--- let ys = ... in
--- in go dt xs ys
--- @
diff --git a/compiler/stranal/WwLib.hs b/compiler/stranal/WwLib.hs
index f8b398fbcd..6feb1ff065 100644
--- a/compiler/stranal/WwLib.hs
+++ b/compiler/stranal/WwLib.hs
@@ -31,7 +31,7 @@ import VarEnv ( mkInScopeSet )
import VarSet ( VarSet )
import Type
import Predicate ( isClassPred )
-import RepType ( isVoidTy, typePrimRep )
+import GHC.Types.RepType ( isVoidTy, typePrimRep )
import Coercion
import FamInstEnv
import BasicTypes ( Boxity(..) )
diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs
index 90680f093f..cd2cb7c725 100644
--- a/compiler/typecheck/TcType.hs
+++ b/compiler/typecheck/TcType.hs
@@ -203,7 +203,7 @@ import VarSet
import Coercion
import Type
import Predicate
-import RepType
+import GHC.Types.RepType
import TyCon
-- others:
diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs
index 7166f85c02..9157c33c4e 100644
--- a/compiler/types/TyCon.hs
+++ b/compiler/types/TyCon.hs
@@ -1035,7 +1035,7 @@ mkDataTyConRhs cons
-- constructor of 'PrimRep'. This data structure allows us to store this
-- information right in the 'TyCon'. The other approach would be to look
-- up things like @RuntimeRep@'s @PrimRep@ by known-key every time.
--- See also Note [Getting from RuntimeRep to PrimRep] in RepType
+-- See also Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType
data RuntimeRepInfo
= NoRRI -- ^ an ordinary promoted data con
| RuntimeRep ([Type] -> [PrimRep])
@@ -1411,14 +1411,14 @@ On the other hand, CmmType includes some "nonsense" values, such as
CmmType GcPtrCat W32 on a 64-bit machine.
The PrimRep type is closely related to the user-visible RuntimeRep type.
-See Note [RuntimeRep and PrimRep] in RepType.
+See Note [RuntimeRep and PrimRep] in GHC.Types.RepType.
-}
-- | A 'PrimRep' is an abstraction of a type. It contains information that
-- the code generator needs in order to pass arguments, return results,
--- and store values of this type. See also Note [RuntimeRep and PrimRep] in RepType
--- and Note [VoidRep] in RepType.
+-- and store values of this type. See also Note [RuntimeRep and PrimRep] in
+-- GHC.Types.RepType and Note [VoidRep] in GHC.Types.RepType.
data PrimRep
= VoidRep
| LiftedRep
diff --git a/testsuite/tests/codeGen/should_run/T13825-unit.hs b/testsuite/tests/codeGen/should_run/T13825-unit.hs
index 34a13acb50..24fc463b91 100644
--- a/testsuite/tests/codeGen/should_run/T13825-unit.hs
+++ b/testsuite/tests/codeGen/should_run/T13825-unit.hs
@@ -1,7 +1,7 @@
module Main where
import DynFlags
-import RepType
+import GHC.Types.RepType
import SMRep
import GHC.StgToCmm.Layout
import GHC.StgToCmm.Closure
diff --git a/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs b/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs
index 0b6384b6ba..73552d63f9 100644
--- a/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs
+++ b/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs
@@ -4,7 +4,7 @@ import BasicTypes
import GHC
import GhcMonad
import Outputable
-import RepType
+import GHC.Types.RepType
import TysPrim
import TysWiredIn
import UniqSet