blob: 8f227d2a2b96e376f9e8c935e457ffa86a6de1d7 (
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
34
35
36
37
38
39
40
41
42
43
|
{-# LANGUAGE MultiWayIf #-}
-- | Code generation backends
module GHC.Driver.Backend
( Backend (..)
, platformDefaultBackend
, platformNcgSupported
)
where
import GHC.Prelude
import GHC.Platform
-- | Backend
data Backend
= NCG -- ^ Native code generator backend
| LLVM -- ^ LLVM backend
| ViaC -- ^ Via-C backend
| Interpreter -- ^ Interpreter
deriving (Eq,Ord,Show,Read)
-- | Default backend to use for the given platform.
platformDefaultBackend :: Platform -> Backend
platformDefaultBackend platform = if
| platformUnregisterised platform -> ViaC
| platformNcgSupported platform -> NCG
| otherwise -> LLVM
-- | Is the platform supported by the Native Code Generator?
platformNcgSupported :: Platform -> Bool
platformNcgSupported platform = if
| platformUnregisterised platform -> False -- NCG doesn't support unregisterised ABI
| ncgValidArch -> True
| otherwise -> False
where
ncgValidArch = case platformArch platform of
ArchX86 -> True
ArchX86_64 -> True
ArchPPC -> True
ArchPPC_64 {} -> True
ArchSPARC -> True
_ -> False
|