module GHC.Driver.Config.Core.Rules
  ( initRuleOpts
  ) where

import GHC.Prelude

import GHC.Driver.Flags
import GHC.Driver.DynFlags ( DynFlags, gopt, targetPlatform, homeUnitId_ )

import GHC.Core.Rules.Config

import GHC.Unit.Types     ( primUnitId )

-- | Initialize RuleOpts from DynFlags
initRuleOpts :: DynFlags -> RuleOpts
initRuleOpts :: DynFlags -> RuleOpts
initRuleOpts DynFlags
dflags = RuleOpts
  { roPlatform :: Platform
roPlatform                = DynFlags -> Platform
targetPlatform DynFlags
dflags
  , roNumConstantFolding :: Bool
roNumConstantFolding      = GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_NumConstantFolding DynFlags
dflags
  , roExcessRationalPrecision :: Bool
roExcessRationalPrecision = GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_ExcessPrecision DynFlags
dflags
    -- disable bignum rules in ghc-prim
  , roBignumRules :: Bool
roBignumRules             = DynFlags -> UnitId
homeUnitId_ DynFlags
dflags UnitId -> UnitId -> Bool
forall a. Eq a => a -> a -> Bool
/= UnitId
primUnitId
  }