1 -----------------------------------------------------------------------------
2 -- $Id: DriverPhases.hs,v 1.27 2003/06/26 21:55:47 sof Exp $
6 -- (c) The University of Glasgow 2002
8 -----------------------------------------------------------------------------
10 #include "../includes/config.h"
15 startPhase, -- :: String -> Phase
16 phaseInputExt, -- :: Phase -> String
18 haskellish_file, haskellish_suffix,
19 haskellish_src_file, haskellish_src_suffix,
20 objish_file, objish_suffix,
21 cish_file, cish_suffix,
22 isExtCore_file, extcoreish_suffix,
23 haskellish_user_src_file,
24 isSourceFile -- :: FilePath -> Bool
29 -----------------------------------------------------------------------------
33 Phase of the | Suffix saying | Flag saying | (suffix of)
34 compilation system | ``start here''| ``stop after''| output file
36 literate pre-processor | .lhs | - | -
37 C pre-processor (opt.) | - | -E | -
38 Haskell compiler | .hs | -C, -S | .hc, .s
39 C compiler (opt.) | .hc or .c | -S | .s
40 assembler | .s or .S | -c | .o
41 linker | other | - | a.out
50 | HCc -- Haskellised C (as opposed to vanilla C) compilation
51 | Mangle -- assembly mangling, now done by a separate script.
52 | SplitMangle -- after mangler if splitting
62 -- Partial ordering on phases: we want to know which phases will occur before
63 -- which others. This is used for sanity checking, to ensure that the
64 -- pipeline will stop at some point (see DriverPipeline.runPipeline).
66 | x `elem` haskell_pipe = y `elem` tail (dropWhile (/= x) haskell_pipe)
67 | x `elem` c_pipe = y `elem` tail (dropWhile (/= x) c_pipe)
70 haskell_pipe = [Unlit,Cpp,HsPp,Hsc,HCc,Mangle,SplitMangle,As,SplitAs,Ln]
73 -- the first compilation phase for a given file is determined
75 startPhase "lhs" = Unlit
77 startPhase "hscpp" = HsPp
78 startPhase "hspp" = Hsc
79 startPhase "hcr" = Hsc
86 startPhase "raw_s" = Mangle
90 startPhase _ = Ln -- all unknown file types
92 -- the output suffix for a given phase is uniquely determined by
93 -- the input requirements of the next phase.
94 phaseInputExt Unlit = "lhs"
95 phaseInputExt Cpp = "lpp" -- intermediate only
96 phaseInputExt HsPp = "hscpp"
97 phaseInputExt Hsc = "hspp"
98 phaseInputExt HCc = "hc"
99 phaseInputExt Cc = "c"
100 phaseInputExt Mangle = "raw_s"
101 phaseInputExt SplitMangle = "split_s" -- not really generated
102 phaseInputExt As = "s"
103 phaseInputExt SplitAs = "split_s" -- not really generated
104 phaseInputExt Ln = "o"
106 phaseInputExt Ilx2Il = "ilx"
107 phaseInputExt Ilasm = "il"
110 haskellish_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s" ])
111 haskellish_src_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr"])
112 cish_suffix = (`elem` [ "c", "cpp", "C", "cc", "cxx", "s", "S" ])
113 extcoreish_suffix = (`elem` [ "hcr" ])
114 haskellish_user_src_suffix = (`elem` [ "hs", "lhs" ])
116 -- Use the appropriate suffix for the system on which
117 -- the GHC-compiled code will run
118 #if mingw32_TARGET_OS || cygwin32_TARGET_OS
119 objish_suffix = (`elem` [ "o", "O", "obj", "OBJ" ])
121 objish_suffix = (`elem` [ "o" ])
124 haskellish_file = haskellish_suffix . getFileSuffix
125 haskellish_src_file = haskellish_src_suffix . getFileSuffix
126 cish_file = cish_suffix . getFileSuffix
127 isExtCore_file = extcoreish_suffix . getFileSuffix
128 objish_file = objish_suffix . getFileSuffix
129 haskellish_user_src_file = haskellish_user_src_suffix . getFileSuffix
131 isSourceFile :: FilePath -> Bool