diff options
author | Luite Stegeman <stegeman@gmail.com> | 2021-01-22 00:09:17 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-20 07:49:15 -0400 |
commit | 1f94e0f7601f8e22fdd81a47f130650265a44196 (patch) | |
tree | d06d02317049b56763b2f1da27f71f3663efa5a0 /compiler/GHC/Stg | |
parent | 7de3532f0317032f75b76150c5d3a6f76178be04 (diff) | |
download | haskell-1f94e0f7601f8e22fdd81a47f130650265a44196.tar.gz |
Generate GHCi bytecode from STG instead of Core and support unboxed
tuples and sums.
fixes #1257
Diffstat (limited to 'compiler/GHC/Stg')
-rw-r--r-- | compiler/GHC/Stg/Lint.hs | 8 | ||||
-rw-r--r-- | compiler/GHC/Stg/Pipeline.hs | 7 | ||||
-rw-r--r-- | compiler/GHC/Stg/Syntax.hs | 15 |
3 files changed, 22 insertions, 8 deletions
diff --git a/compiler/GHC/Stg/Lint.hs b/compiler/GHC/Stg/Lint.hs index 1e12e9bab9..8464cb8786 100644 --- a/compiler/GHC/Stg/Lint.hs +++ b/compiler/GHC/Stg/Lint.hs @@ -42,6 +42,7 @@ import GHC.Prelude import GHC.Stg.Syntax import GHC.Driver.Session +import GHC.Core.Lint ( interactiveInScope ) import GHC.Data.Bag ( Bag, emptyBag, isEmptyBag, snocBag, bagToList ) import GHC.Types.Basic ( TopLevelFlag(..), isTopLevel ) import GHC.Types.CostCentre ( isCurrentCCS ) @@ -57,6 +58,7 @@ import GHC.Types.SrcLoc import GHC.Utils.Logger import GHC.Utils.Outputable import GHC.Unit.Module ( Module ) +import GHC.Runtime.Context ( InteractiveContext ) import qualified GHC.Utils.Error as Err import Control.Applicative ((<|>)) import Control.Monad @@ -64,13 +66,14 @@ import Control.Monad lintStgTopBindings :: forall a . (OutputablePass a, BinderP a ~ Id) => Logger -> DynFlags + -> InteractiveContext -> Module -- ^ module being compiled -> Bool -- ^ have we run Unarise yet? -> String -- ^ who produced the STG? -> [GenStgTopBinding a] -> IO () -lintStgTopBindings logger dflags this_mod unarised whodunnit binds +lintStgTopBindings logger dflags ictxt this_mod unarised whodunnit binds = {-# SCC "StgLint" #-} case initL this_mod unarised opts top_level_binds (lint_binds binds) of Nothing -> @@ -89,7 +92,8 @@ lintStgTopBindings logger dflags this_mod unarised whodunnit binds opts = initStgPprOpts dflags -- 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 = mkVarSet (bindersOfTopBinds binds) + top_level_binds = extendVarSetList (mkVarSet (bindersOfTopBinds binds)) + (interactiveInScope ictxt) lint_binds :: [GenStgTopBinding a] -> LintM () diff --git a/compiler/GHC/Stg/Pipeline.hs b/compiler/GHC/Stg/Pipeline.hs index c05450c0f7..d9f1342b66 100644 --- a/compiler/GHC/Stg/Pipeline.hs +++ b/compiler/GHC/Stg/Pipeline.hs @@ -24,6 +24,7 @@ import GHC.Stg.Unarise ( unarise ) import GHC.Stg.CSE ( stgCse ) import GHC.Stg.Lift ( stgLiftLams ) import GHC.Unit.Module ( Module ) +import GHC.Runtime.Context ( InteractiveContext ) import GHC.Driver.Session import GHC.Utils.Error @@ -49,11 +50,11 @@ runStgM mask (StgM m) = evalStateT m mask stg2stg :: Logger -> DynFlags -- includes spec of what stg-to-stg passes to do + -> InteractiveContext -> Module -- module being compiled -> [StgTopBinding] -- input program -> IO [StgTopBinding] -- output program - -stg2stg logger dflags this_mod binds +stg2stg logger dflags ictxt this_mod binds = do { dump_when Opt_D_dump_stg_from_core "Initial STG:" binds ; showPass logger dflags "Stg2Stg" -- Do the main business! @@ -75,7 +76,7 @@ stg2stg logger dflags this_mod binds where stg_linter unarised | gopt Opt_DoStgLinting dflags - = lintStgTopBindings logger dflags this_mod unarised + = lintStgTopBindings logger dflags ictxt this_mod unarised | otherwise = \ _whodunnit _binds -> return () diff --git a/compiler/GHC/Stg/Syntax.hs b/compiler/GHC/Stg/Syntax.hs index 03ba9b5549..6e2107e9d6 100644 --- a/compiler/GHC/Stg/Syntax.hs +++ b/compiler/GHC/Stg/Syntax.hs @@ -58,7 +58,8 @@ module GHC.Stg.Syntax ( bindersOf, bindersOfTop, bindersOfTopBinds, -- ppr - StgPprOpts(..), initStgPprOpts, panicStgPprOpts, + StgPprOpts(..), initStgPprOpts, + panicStgPprOpts, shortStgPprOpts, pprStgArg, pprStgExpr, pprStgRhs, pprStgBinding, pprGenStgTopBinding, pprStgTopBinding, pprGenStgTopBindings, pprStgTopBindings @@ -691,6 +692,13 @@ panicStgPprOpts = StgPprOpts { stgSccEnabled = True } +-- | STG pretty-printing options used for short messages +shortStgPprOpts :: StgPprOpts +shortStgPprOpts = StgPprOpts + { stgSccEnabled = False + } + + pprGenStgTopBinding :: OutputablePass pass => StgPprOpts -> GenStgTopBinding pass -> SDoc pprGenStgTopBinding opts b = case b of @@ -778,9 +786,10 @@ pprStgExpr opts e = case e of , hang (text "} in ") 2 (pprStgExpr opts expr) ] - StgTick tickish expr -> sdocOption sdocSuppressTicks $ \case + StgTick _tickish expr -> sdocOption sdocSuppressTicks $ \case True -> pprStgExpr opts expr - False -> sep [ ppr tickish, pprStgExpr opts expr ] + False -> pprStgExpr opts expr + -- XXX sep [ ppr tickish, pprStgExpr opts expr ] -- Don't indent for a single case alternative. StgCase expr bndr alt_type [alt] |