summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Config/Cmm.hs
blob: 38bab62048bdc5e295033b203a96dbcce79d5f2f (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
33
module GHC.Driver.Config.Cmm
  ( initCmmConfig
  ) where

import GHC.Cmm.Config
import GHC.Cmm.Switch (backendSupportsSwitch)

import GHC.Driver.Session
import GHC.Driver.Backend

import GHC.Platform

import GHC.Prelude

initCmmConfig :: DynFlags -> CmmConfig
initCmmConfig dflags = CmmConfig
  { cmmProfile             = targetProfile                dflags
  , cmmOptControlFlow      = gopt Opt_CmmControlFlow      dflags
  , cmmDoLinting           = gopt Opt_DoCmmLinting        dflags
  , cmmOptElimCommonBlks   = gopt Opt_CmmElimCommonBlocks dflags
  , cmmOptSink             = gopt Opt_CmmSink             dflags
  , cmmGenStackUnwindInstr = debugLevel dflags > 0
  , cmmExternalDynamicRefs = gopt Opt_ExternalDynamicRefs dflags
  , cmmDoCmmSwitchPlans    = not . backendSupportsSwitch . backend $ dflags
  , cmmSplitProcPoints     = (backend dflags /= NCG)
                             || not (platformTablesNextToCode platform)
                             || usingInconsistentPicReg
  }
  where platform                = targetPlatform dflags
        usingInconsistentPicReg =
          case (platformArch platform, platformOS platform, positionIndependent dflags)
          of   (ArchX86, OSDarwin, pic) -> pic
               _                        -> False