summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Config
diff options
context:
space:
mode:
authorNorman Ramsey <nr@cs.tufts.edu>2022-02-07 10:42:36 -0500
committerCheng Shao <astrohavoc@gmail.com>2022-05-21 03:11:04 +0000
commit4aa3c5bde8c54f6ab8cbb2a574f7654590c077ca (patch)
tree43e79b6f797f12a3eb040252a20ac80659c55514 /compiler/GHC/Driver/Config
parent36b8a57cb30c1374cce749b6f1554a2d438336b9 (diff)
downloadhaskell-4aa3c5bde8c54f6ab8cbb2a574f7654590c077ca.tar.gz
Change `Backend` type and remove direct dependencieswip/backend-as-record
With this change, `Backend` becomes an abstract type (there are no more exposed value constructors). Decisions that were formerly made by asking "is the current back end equal to (or different from) this named value constructor?" are now made by interrogating the back end about its properties, which are functions exported by `GHC.Driver.Backend`. There is a description of how to migrate code using `Backend` in the user guide. Clients using the GHC API can find a backdoor to access the Backend datatype in GHC.Driver.Backend.Internal. Bumps haddock submodule. Fixes #20927
Diffstat (limited to 'compiler/GHC/Driver/Config')
-rw-r--r--compiler/GHC/Driver/Config/Cmm.hs5
-rw-r--r--compiler/GHC/Driver/Config/StgToCmm.hs13
-rw-r--r--compiler/GHC/Driver/Config/Tidy.hs6
3 files changed, 11 insertions, 13 deletions
diff --git a/compiler/GHC/Driver/Config/Cmm.hs b/compiler/GHC/Driver/Config/Cmm.hs
index 38bab62048..5e7ebf72dd 100644
--- a/compiler/GHC/Driver/Config/Cmm.hs
+++ b/compiler/GHC/Driver/Config/Cmm.hs
@@ -3,7 +3,6 @@ module GHC.Driver.Config.Cmm
) where
import GHC.Cmm.Config
-import GHC.Cmm.Switch (backendSupportsSwitch)
import GHC.Driver.Session
import GHC.Driver.Backend
@@ -21,8 +20,8 @@ initCmmConfig dflags = CmmConfig
, cmmOptSink = gopt Opt_CmmSink dflags
, cmmGenStackUnwindInstr = debugLevel dflags > 0
, cmmExternalDynamicRefs = gopt Opt_ExternalDynamicRefs dflags
- , cmmDoCmmSwitchPlans = not . backendSupportsSwitch . backend $ dflags
- , cmmSplitProcPoints = (backend dflags /= NCG)
+ , cmmDoCmmSwitchPlans = not . backendHasNativeSwitch . backend $ dflags
+ , cmmSplitProcPoints = not (backendSupportsUnsplitProcPoints (backend dflags))
|| not (platformTablesNextToCode platform)
|| usingInconsistentPicReg
}
diff --git a/compiler/GHC/Driver/Config/StgToCmm.hs b/compiler/GHC/Driver/Config/StgToCmm.hs
index 7ec80f24d3..b0b28bf158 100644
--- a/compiler/GHC/Driver/Config/StgToCmm.hs
+++ b/compiler/GHC/Driver/Config/StgToCmm.hs
@@ -8,6 +8,7 @@ import GHC.Driver.Backend
import GHC.Driver.Session
import GHC.Platform
import GHC.Platform.Profile
+import GHC.Utils.Error
import GHC.Unit.Module
import GHC.Utils.Outputable
@@ -60,9 +61,11 @@ initStgToCmmConfig dflags mod = StgToCmmConfig
} where profile = targetProfile dflags
platform = profilePlatform profile
bk_end = backend dflags
- ncg = bk_end == NCG
- llvm = bk_end == LLVM
b_blob = if not ncg then Nothing else binBlobThreshold dflags
+ (ncg, llvm) = case backendPrimitiveImplementation bk_end of
+ GenericPrimitives -> (False, False)
+ NcgPrimitives -> (True, False)
+ LlvmPrimitives -> (False, True)
x86ish = case platformArch platform of
ArchX86 -> True
ArchX86_64 -> True
@@ -71,6 +74,6 @@ initStgToCmmConfig dflags mod = StgToCmmConfig
ArchPPC -> True
ArchPPC_64 _ -> True
_ -> False
- vec_err = case backend dflags of
- LLVM -> Nothing
- _ -> Just (unlines ["SIMD vector instructions require the LLVM back-end.", "Please use -fllvm."])
+ vec_err = case backendSimdValidity (backend dflags) of
+ IsValid -> Nothing
+ NotValid msg -> Just msg
diff --git a/compiler/GHC/Driver/Config/Tidy.hs b/compiler/GHC/Driver/Config/Tidy.hs
index d7ad76fc87..89bdf31b2c 100644
--- a/compiler/GHC/Driver/Config/Tidy.hs
+++ b/compiler/GHC/Driver/Config/Tidy.hs
@@ -62,12 +62,8 @@ initStaticPtrOpts hsc_env = do
-- If we are compiling for the interpreter we will insert any necessary
-- SPT entries dynamically, otherwise we add a C stub to do so
- , opt_gen_cstub = case backend dflags of
- Interpreter -> False
- _ -> True
-
+ , opt_gen_cstub = backendWritesFiles (backend dflags)
, opt_mk_string = mk_string
, opt_static_ptr_info_datacon = static_ptr_info_datacon
, opt_static_ptr_datacon = static_ptr_datacon
}
-