summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-08-05 15:01:19 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-08-06 13:34:08 -0400
commit63348155404c64334fa864454132630f9d2a4d7f (patch)
tree94bf180a328863dbd150d87a712d43c2cfa6bbda /compiler
parentd2a432258fa00e22ca386ef30d0a77ff5b277db8 (diff)
downloadhaskell-63348155404c64334fa864454132630f9d2a4d7f.tar.gz
Use a type alias for Ways
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Driver/Session.hs4
-rw-r--r--compiler/GHC/Platform/Profile.hs6
-rw-r--r--compiler/GHC/Platform/Ways.hs13
-rw-r--r--compiler/GHC/Unit/State.hs2
4 files changed, 13 insertions, 12 deletions
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index 795cbf2256..69972fdef4 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -534,7 +534,7 @@ data DynFlags = DynFlags {
homeUnitInstantiations:: [(ModuleName, Module)], -- ^ How to instantiate `homeUnitInstanceOfId` unit
-- ways
- ways :: Set Way, -- ^ Way flags from the command line
+ ways :: Ways, -- ^ Way flags from the command line
-- For object splitting
splitInfo :: Maybe (String,Int),
@@ -1433,7 +1433,7 @@ defaultDynFlags mySettings llvmConfig =
cfgWeightInfo = defaultCfgWeights
}
-defaultWays :: Settings -> Set Way
+defaultWays :: Settings -> Ways
defaultWays settings = if pc_DYNAMIC_BY_DEFAULT (sPlatformConstants settings)
then Set.singleton WayDyn
else Set.empty
diff --git a/compiler/GHC/Platform/Profile.hs b/compiler/GHC/Platform/Profile.hs
index 5875e5d56d..b9011d35b5 100644
--- a/compiler/GHC/Platform/Profile.hs
+++ b/compiler/GHC/Platform/Profile.hs
@@ -13,8 +13,6 @@ import GHC.Prelude
import GHC.Platform
import GHC.Platform.Ways
-import Data.Set
-
-- | A platform profile fully describes the kind of objects that are generated
-- for a platform.
--
@@ -22,8 +20,8 @@ import Data.Set
-- (profiling, debug, dynamic) also modify the ABI.
--
data Profile = Profile
- { profilePlatform :: !Platform -- ^ Platform
- , profileWays :: !(Set Way) -- ^ Ways
+ { profilePlatform :: !Platform -- ^ Platform
+ , profileWays :: !Ways -- ^ Ways
}
-- | Get platform constants
diff --git a/compiler/GHC/Platform/Ways.hs b/compiler/GHC/Platform/Ways.hs
index c672ab656d..c4ba0e18de 100644
--- a/compiler/GHC/Platform/Ways.hs
+++ b/compiler/GHC/Platform/Ways.hs
@@ -20,6 +20,7 @@
-- this compilation.
module GHC.Platform.Ways
( Way(..)
+ , Ways
, hasWay
, allowed_combination
, wayGeneralFlags
@@ -61,12 +62,14 @@ data Way
| WayDyn -- ^ Dynamic linking
deriving (Eq, Ord, Show)
+type Ways = Set Way
+
-- | Test if a ways is enabled
-hasWay :: Set Way -> Way -> Bool
+hasWay :: Ways -> Way -> Bool
hasWay ws w = Set.member w ws
-- | Check if a combination of ways is allowed
-allowed_combination :: Set Way -> Bool
+allowed_combination :: Ways -> Bool
allowed_combination ways = not disallowed
where
disallowed = or [ hasWay ways x && hasWay ways y
@@ -76,13 +79,13 @@ allowed_combination ways = not disallowed
couples = [] -- we don't have any disallowed combination of ways nowadays
-- | Unique tag associated to a list of ways
-waysTag :: Set Way -> String
+waysTag :: Ways -> String
waysTag = concat . intersperse "_" . map wayTag . Set.toAscList
-- | Unique build-tag associated to a list of ways
--
-- RTS only ways are filtered out because they have no impact on the build.
-waysBuildTag :: Set Way -> String
+waysBuildTag :: Ways -> String
waysBuildTag ws = waysTag (Set.filter (not . wayRTSOnly) ws)
@@ -195,7 +198,7 @@ foreign import ccall unsafe "rts_isDynamic" rtsIsDynamicIO :: IO Int
-- | Return host "full" ways (i.e. ways that have an impact on the compilation,
-- not RTS only ways). These ways must be used when compiling codes targeting
-- the internal interpreter.
-hostFullWays :: Set Way
+hostFullWays :: Ways
hostFullWays = Set.unions
[ if hostIsDynamic then Set.singleton WayDyn else Set.empty
, if hostIsProfiled then Set.singleton WayProf else Set.empty
diff --git a/compiler/GHC/Unit/State.hs b/compiler/GHC/Unit/State.hs
index 93c0b86dc8..db99ffa2ac 100644
--- a/compiler/GHC/Unit/State.hs
+++ b/compiler/GHC/Unit/State.hs
@@ -315,7 +315,7 @@ instance Monoid UnitVisibility where
-- | Unit configuration
data UnitConfig = UnitConfig
{ unitConfigPlatformArchOS :: !ArchOS -- ^ Platform arch and OS
- , unitConfigWays :: !(Set Way) -- ^ Ways to use
+ , unitConfigWays :: !Ways -- ^ Ways to use
, unitConfigProgramName :: !String
-- ^ Name of the compiler (e.g. "GHC", "GHCJS"). Used to fetch environment
-- variables such as "GHC[JS]_PACKAGE_PATH".