GitLab will be upgraded on June 2nd 2020 at 2.00 pm (AEDT) to 3.00 pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to local Gitlab admin team.

Commit 7eff9168 authored by nathyong's avatar nathyong

Export TyCons with STG as STG-Simple Intermediate

parent 18834f48
......@@ -15,12 +15,14 @@ cabal-version: >=1.10
hs-source-dirs: src
ghc-options: -Wall
exposed-modules: Compiler.Mu
, Compiler.Mu.FromSTG
, Compiler.Mu.Types
, Compiler.Mu.PprMu
, Language.Haskell.GHC.Simple.Extra
build-depends: base >= 4.7 && < 5
, text
, mtl
, ghc
, ghc-simple
, containers
......@@ -41,8 +43,10 @@ executable anuhc-exe
test-suite anuhc-test
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Spec.hs
main-is: TestMain.hs
build-depends: base
, tasty
, tasty-program
, ghc
, ghc-paths
, ghc-simple
{-# LANGUAGE FlexibleInstances, CPP #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-- | Lower level building blocks for custom code generation.
module Language.Haskell.GHC.Simple.Extra (
) where
-- GHC scaffolding
import GHC hiding (Warning)
import GhcMonad (liftIO)
import HscTypes
import CostCentre
import CorePrep
import StgSyn
import CoreSyn
import CoreToStg
import SimplStg
import DriverPipeline
import Language.Haskell.GHC.Simple.Types
instance Intermediate ([TyCon], [StgBinding], CollectedCCs) where
prepare = toSimplifiedStgPlus
-- | Compile a 'ModSummary' into a list of simplified 'StgBinding's.
-- See <>
-- for more information about STG and how it relates to core and Haskell.
toSimplifiedStgPlus :: ModSummary -> CgGuts -> CompPipeline ([TyCon], [StgBinding], CollectedCCs)
toSimplifiedStgPlus ms cgguts = do
env <- hsc_env `fmap` getPipeState
let dfs = hsc_dflags env
liftIO $ do
prog <- prepareCore env dfs ms cgguts
stg <- coreToStg dfs (ms_mod ms) prog
(binds, ccs) <- stg2stg dfs (ms_mod ms) stg
return (cg_tycons cgguts, binds, ccs)
-- | Prepare a core module for code generation.
prepareCore :: HscEnv -> DynFlags -> ModSummary -> CgGuts -> IO CoreProgram
prepareCore env dfs _ms p = do
#if __GLASGOW_HASKELL__ >= 800
liftIO $ corePrepPgm env (ms_mod _ms) (ms_location _ms) (cg_binds p) (cg_tycons p)
#elif __GLASGOW_HASKELL__ >= 710
liftIO $ corePrepPgm env (ms_location _ms) (cg_binds p) (cg_tycons p)
liftIO $ corePrepPgm dfs env (cg_binds p) (cg_tycons p)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment