summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Config/CoreToStg/Prep.hs
blob: a0dab0351981491e31a0ef7ed42186d117905097 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module GHC.Driver.Config.CoreToStg.Prep
  ( initCorePrepConfig
  , initCorePrepPgmConfig
  ) where

import GHC.Prelude

import GHC.Driver.Env
import GHC.Driver.Session
import GHC.Driver.Config.Core.Lint
import GHC.Runtime.Context ( InteractiveContext )
import GHC.Tc.Utils.Env

import GHC.CoreToStg.Prep

initCorePrepConfig :: HscEnv -> IO CorePrepConfig
initCorePrepConfig hsc_env = do
   convertNumLit <- do
     let platform = targetPlatform $ hsc_dflags hsc_env
         home_unit = hsc_home_unit hsc_env
         lookup_global = lookupGlobal hsc_env
     mkConvertNumLiteral platform home_unit lookup_global
   return $ CorePrepConfig
      { cp_catchNonexhaustiveCases = gopt Opt_CatchNonexhaustiveCases $ hsc_dflags hsc_env
      , cp_convertNumLit = convertNumLit
      }

initCorePrepPgmConfig :: InteractiveContext -> DynFlags -> CorePrepPgmConfig
initCorePrepPgmConfig ic dflags = CorePrepPgmConfig
  { cpPgm_endPassConfig     = initEndPassConfig ic dflags
  , cpPgm_generateDebugInfo = needSourceNotes dflags
  }