diff options
author | Dominik Peteler <haskell+gitlab@with-h.at> | 2022-07-04 23:47:16 +0200 |
---|---|---|
committer | Dominik Peteler <haskell+gitlab@with-h.at> | 2022-07-22 10:09:02 +0200 |
commit | 7b889fa968750224d6f82baa63bc81513f0a4049 (patch) | |
tree | 8a23c7313aabc80422100b1dc121666e59d77433 /compiler/GHC/Stg | |
parent | e2f0094c315746ff15b8d9650cf318f81d8416d7 (diff) | |
download | haskell-wip/refactor-latecc.tar.gz |
Refactored Simplify passwip/refactor-latecc
* Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify
namespace and GHC.Core.Opt.Stats.
Also removed services from configuration records.
* Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration.
* Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm`
and moved the Simplify driver to GHC.Core.Opt.Simplify.
* Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env.
* Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment
in GHC.Core.Opt.Simplify.Monad.
* Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions
for those in a new module GHC.Driver.Config.Core.Opt.Simplify.
Also added initialization functions for `SimplMode` to that module.
* Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types
and the counting types and functions (`SimplCount` and `Tick`) to new
module GHC.Core.Opt.Stats.
* Added getter functions for the fields of `SimplMode`. The pedantic bottoms
option and the platform are retrieved from the ArityOpts and RuleOpts and the
getter functions allow us to retrieve values from `SpecEnv` without the
knowledge where the data is stored exactly.
* Moved the coercion optimization options from the top environment to
`SimplMode`. This way the values left in the top environment are those
dealing with monadic functionality, namely logging, IO related stuff and
counting. Added a note "The environments of the Simplify pass".
* Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of
`CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead.
* Prep work before removing `InteractiveContext` from `HscEnv`.
Diffstat (limited to 'compiler/GHC/Stg')
-rw-r--r-- | compiler/GHC/Stg/Lint.hs | 8 | ||||
-rw-r--r-- | compiler/GHC/Stg/Pipeline.hs | 12 |
2 files changed, 9 insertions, 11 deletions
diff --git a/compiler/GHC/Stg/Lint.hs b/compiler/GHC/Stg/Lint.hs index 63154a48bd..15586cfce9 100644 --- a/compiler/GHC/Stg/Lint.hs +++ b/compiler/GHC/Stg/Lint.hs @@ -92,7 +92,6 @@ import GHC.Prelude import GHC.Stg.Syntax import GHC.Stg.Utils -import GHC.Core.Lint ( interactiveInScope ) import GHC.Core.DataCon import GHC.Core ( AltCon(..) ) import GHC.Core.Type @@ -112,7 +111,6 @@ import GHC.Utils.Error ( mkLocMessage, DiagOpts ) import qualified GHC.Utils.Error as Err import GHC.Unit.Module ( Module ) -import GHC.Runtime.Context ( InteractiveContext ) import GHC.Data.Bag ( Bag, emptyBag, isEmptyBag, snocBag, bagToList ) @@ -129,14 +127,14 @@ lintStgTopBindings :: forall a . (OutputablePass a, BinderP a ~ Id) -> Logger -> DiagOpts -> StgPprOpts - -> InteractiveContext + -> [Var] -- ^ extra vars in scope from GHCi -> Module -- ^ module being compiled -> Bool -- ^ have we run Unarise yet? -> String -- ^ who produced the STG? -> [GenStgTopBinding a] -> IO () -lintStgTopBindings platform logger diag_opts opts ictxt this_mod unarised whodunnit binds +lintStgTopBindings platform logger diag_opts opts extra_vars this_mod unarised whodunnit binds = {-# SCC "StgLint" #-} case initL platform diag_opts this_mod unarised opts top_level_binds (lint_binds binds) of Nothing -> @@ -155,7 +153,7 @@ lintStgTopBindings platform logger diag_opts opts ictxt this_mod unarised whodun -- Bring all top-level binds into scope because CoreToStg does not generate -- bindings in dependency order (so we may see a use before its definition). top_level_binds = extendVarSetList (mkVarSet (bindersOfTopBinds binds)) - (interactiveInScope ictxt) + extra_vars lint_binds :: [GenStgTopBinding a] -> LintM () diff --git a/compiler/GHC/Stg/Pipeline.hs b/compiler/GHC/Stg/Pipeline.hs index f6bf55d398..c5f7bc2da3 100644 --- a/compiler/GHC/Stg/Pipeline.hs +++ b/compiler/GHC/Stg/Pipeline.hs @@ -29,9 +29,9 @@ import GHC.Stg.BcPrep ( bcPrep ) import GHC.Stg.CSE ( stgCse ) import GHC.Stg.Lift ( StgLiftConfig, stgLiftLams ) import GHC.Unit.Module ( Module ) -import GHC.Runtime.Context ( InteractiveContext ) import GHC.Utils.Error +import GHC.Types.Var import GHC.Types.Unique.Supply import GHC.Utils.Outputable import GHC.Utils.Logger @@ -62,12 +62,12 @@ runStgM :: Char -> StgM a -> IO a runStgM mask (StgM m) = runReaderT m mask stg2stg :: Logger - -> InteractiveContext + -> [Var] -- ^ extra vars in scope from GHCi -> StgPipelineOpts - -> Module -- module being compiled - -> [StgTopBinding] -- input program + -> Module -- ^ module being compiled + -> [StgTopBinding] -- ^ input program -> IO [CgStgTopBinding] -- output program -stg2stg logger ictxt opts this_mod binds +stg2stg logger extra_vars opts this_mod binds = do { dump_when Opt_D_dump_stg_from_core "Initial STG:" binds ; showPass logger "Stg2Stg" -- Do the main business! @@ -94,7 +94,7 @@ stg2stg logger ictxt opts this_mod binds = lintStgTopBindings (stgPlatform opts) logger diag_opts ppr_opts - ictxt this_mod unarised + extra_vars this_mod unarised | otherwise = \ _whodunnit _binds -> return () |