summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Main.hs
diff options
context:
space:
mode:
authorDominik Peteler <haskell+gitlab@with-h.at>2022-07-04 23:47:16 +0200
committerDominik Peteler <haskell+gitlab@with-h.at>2022-07-22 10:09:02 +0200
commit7b889fa968750224d6f82baa63bc81513f0a4049 (patch)
tree8a23c7313aabc80422100b1dc121666e59d77433 /compiler/GHC/Driver/Main.hs
parente2f0094c315746ff15b8d9650cf318f81d8416d7 (diff)
downloadhaskell-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/Driver/Main.hs')
-rw-r--r--compiler/GHC/Driver/Main.hs28
1 files changed, 18 insertions, 10 deletions
diff --git a/compiler/GHC/Driver/Main.hs b/compiler/GHC/Driver/Main.hs
index 237352877a..739ac5b46a 100644
--- a/compiler/GHC/Driver/Main.hs
+++ b/compiler/GHC/Driver/Main.hs
@@ -113,7 +113,9 @@ import GHC.Driver.Errors
import GHC.Driver.Errors.Types
import GHC.Driver.CodeOutput
import GHC.Driver.Config.Cmm.Parser (initCmmParserConfig)
-import GHC.Driver.Config.Core.Lint ( endPassHscEnvIO, lintInteractiveExpr )
+import GHC.Driver.Config.Core.Opt.Simplify ( initSimplifyExprOpts )
+import GHC.Driver.Config.Core.Lint ( endPassHscEnvIO )
+import GHC.Driver.Config.Core.Lint.Interactive ( lintInteractiveExpr )
import GHC.Driver.Config.CoreToStg.Prep
import GHC.Driver.Config.Logger (initLogFlags)
import GHC.Driver.Config.Parser (initParserOpts)
@@ -156,13 +158,14 @@ import GHC.Iface.Ext.Binary ( readHieFile, writeHieFile , hie_file_result)
import GHC.Iface.Ext.Debug ( diffFile, validateScopes )
import GHC.Core
+import GHC.Core.Lint.Interactive ( interactiveInScope )
import GHC.Core.Tidy ( tidyExpr )
import GHC.Core.Type ( Type, Kind )
import GHC.Core.Multiplicity
import GHC.Core.Utils ( exprType )
import GHC.Core.ConLike
-import GHC.Core.Opt.Monad ( CoreToDo (..))
import GHC.Core.Opt.Pipeline
+import GHC.Core.Opt.Pipeline.Types ( CoreToDo (..))
import GHC.Core.TyCon
import GHC.Core.InstEnv
import GHC.Core.FamInstEnv
@@ -1696,7 +1699,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do
corePrepPgm
(hsc_logger hsc_env)
cp_cfg
- (initCorePrepPgmConfig (hsc_IC hsc_env) (hsc_dflags hsc_env))
+ (initCorePrepPgmConfig (hsc_dflags hsc_env) (interactiveInScope $ hsc_IC hsc_env))
this_mod location core_binds data_tycons
----------------- Convert to STG ------------------
@@ -1779,7 +1782,7 @@ hscInteractive hsc_env cgguts location = do
corePrepPgm
(hsc_logger hsc_env)
cp_cfg
- (initCorePrepPgmConfig (hsc_IC hsc_env) (hsc_dflags hsc_env))
+ (initCorePrepPgmConfig (hsc_dflags hsc_env) (interactiveInScope $ hsc_IC hsc_env))
this_mod location core_binds data_tycons
(stg_binds, _infotable_prov, _caf_ccs__caf_cc_stacks)
@@ -1972,7 +1975,7 @@ myCoreToStg logger dflags ictxt for_bytecode this_mod ml prepd_binds = do
stg_binds_with_fvs
<- {-# SCC "Stg2Stg" #-}
- stg2stg logger ictxt (initStgPipelineOpts dflags for_bytecode)
+ stg2stg logger (interactiveInScope ictxt) (initStgPipelineOpts dflags for_bytecode)
this_mod stg_binds
putDumpFileMaybe logger Opt_D_dump_stg_cg "CodeGenInput STG:" FormatSTG
@@ -2126,7 +2129,7 @@ hscParsedDecls hsc_env decls = runInteractiveHsc hsc_env $ do
corePrepPgm
(hsc_logger hsc_env)
cp_cfg
- (initCorePrepPgmConfig (hsc_IC hsc_env) (hsc_dflags hsc_env))
+ (initCorePrepPgmConfig (hsc_dflags hsc_env) (interactiveInScope $ hsc_IC hsc_env))
this_mod iNTERACTIVELoc core_binds data_tycons
(stg_binds, _infotable_prov, _caf_ccs__caf_cc_stacks)
@@ -2340,7 +2343,12 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr
= do { {- Simplify it -}
-- Question: should we call SimpleOpt.simpleOptExpr here instead?
-- It is, well, simpler, and does less inlining etc.
- simpl_expr <- simplifyExpr hsc_env ds_expr
+ let dflags = hsc_dflags hsc_env
+ ; let logger = hsc_logger hsc_env
+ ; let ic = hsc_IC hsc_env
+ ; let unit_env = hsc_unit_env hsc_env
+ ; let simplify_expr_opts = initSimplifyExprOpts dflags ic
+ ; simpl_expr <- simplifyExpr logger (ue_eps unit_env) simplify_expr_opts ds_expr
{- Tidy it (temporary, until coreSat does cloning) -}
; let tidy_expr = tidyExpr emptyTidyEnv simpl_expr
@@ -2348,7 +2356,7 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr
{- Prepare for codegen -}
; cp_cfg <- initCorePrepConfig hsc_env
; prepd_expr <- corePrepExpr
- (hsc_logger hsc_env) cp_cfg
+ logger cp_cfg
tidy_expr
{- Lint if necessary -}
@@ -2362,8 +2370,8 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr
; let ictxt = hsc_IC hsc_env
; (binding_id, stg_expr, _, _) <-
- myCoreToStgExpr (hsc_logger hsc_env)
- (hsc_dflags hsc_env)
+ myCoreToStgExpr logger
+ dflags
ictxt
True
(icInteractiveModule ictxt)