Propagate scalar variables and tycons for vectorisation through 'HscTypes.VectInfo'.
[ghc-hetmet.git] / compiler / utils / Platform.hs
1
2 -- | A description of the platform we're compiling for.
3 --      Used by the native code generator.
4 --      In the future, this module should be the only one that references
5 --      the evil #defines for each TARGET_ARCH and TARGET_OS
6 --
7 module Platform (
8         Platform(..),
9         Arch(..),
10         OS(..),
11
12         defaultTargetPlatform,
13         osElfTarget
14 )
15
16 where
17
18 #include "HsVersions.h"
19
20
21 -- | Contains enough information for the native code generator to emit
22 --      code for this platform.
23 data Platform
24         = Platform 
25         { platformArch  :: Arch
26         , platformOS    :: OS }
27
28
29 -- | Architectures that the native code generator knows about.
30 --      TODO: It might be nice to extend these constructors with information
31 --      about what instruction set extensions an architecture might support.
32 --
33 data Arch
34         = ArchUnknown
35         | ArchX86
36         | ArchX86_64
37         | ArchPPC
38         | ArchPPC_64
39         | ArchSPARC
40         deriving (Show, Eq)
41         
42
43 -- | Operating systems that the native code generator knows about.
44 --      Having OSUnknown should produce a sensible default, but no promises.
45 data OS
46         = OSUnknown
47         | OSLinux
48         | OSDarwin
49         | OSSolaris2
50         | OSMinGW32
51         | OSFreeBSD
52         | OSOpenBSD
53         deriving (Show, Eq)
54
55
56 -- | This predicates tells us whether the OS supports ELF-like shared libraries.
57 osElfTarget :: OS -> Bool
58 osElfTarget OSLinux   = True
59 osElfTarget OSFreeBSD = True
60 osElfTarget OSOpenBSD = True
61 osElfTarget OSSolaris2 = True
62 osElfTarget _         = False
63
64 -- | This is the target platform as far as the #ifdefs are concerned.
65 --      These are set in includes/ghcplatform.h by the autoconf scripts
66 defaultTargetPlatform :: Platform
67 defaultTargetPlatform
68         = Platform defaultTargetArch defaultTargetOS
69
70
71 -- | Move the evil TARGET_ARCH #ifdefs into Haskell land.
72 defaultTargetArch :: Arch
73 #if i386_TARGET_ARCH
74 defaultTargetArch       = ArchX86
75 #elif x86_64_TARGET_ARCH
76 defaultTargetArch       = ArchX86_64
77 #elif powerpc_TARGET_ARCH
78 defaultTargetArch       = ArchPPC
79 #elif powerpc64_TARGET_ARCH
80 defaultTargetArch       = ArchPPC_64
81 #elif sparc_TARGET_ARCH
82 defaultTargetArch       = ArchSPARC
83 #else
84 defaultTargetArch       = ArchUnknown
85 #endif
86
87
88 -- | Move the evil TARGET_OS #ifdefs into Haskell land.
89 defaultTargetOS :: OS
90 #if   linux_TARGET_OS
91 defaultTargetOS = OSLinux
92 #elif darwin_TARGET_OS
93 defaultTargetOS = OSDarwin
94 #elif solaris2_TARGET_OS
95 defaultTargetOS = OSSolaris2
96 #elif mingw32_TARGET_OS
97 defaultTargetOS = OSMinGW32
98 #elif freebsd_TARGET_OS
99 defaultTargetOS = OSFreeBSD
100 #elif openbsd_TARGET_OS
101 defaultTargetOS = OSOpenBSD
102 #else
103 defaultTargetOS = OSUnknown
104 #endif
105