1 -----------------------------------------------------------------------------
2 -- $Id: DriverPhases.hs,v 1.25 2003/06/04 15:47:59 simonmar 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 isSourceFile -- :: FilePath -> Bool
28 -----------------------------------------------------------------------------
32 Phase of the | Suffix saying | Flag saying | (suffix of)
33 compilation system | ``start here''| ``stop after''| output file
35 literate pre-processor | .lhs | - | -
36 C pre-processor (opt.) | - | -E | -
37 Haskell compiler | .hs | -C, -S | .hc, .s
38 C compiler (opt.) | .hc or .c | -S | .s
39 assembler | .s or .S | -c | .o
40 linker | other | - | a.out
49 | HCc -- Haskellised C (as opposed to vanilla C) compilation
50 | Mangle -- assembly mangling, now done by a separate script.
51 | SplitMangle -- after mangler if splitting
61 -- Partial ordering on phases: we want to know which phases will occur before
62 -- which others. This is used for sanity checking, to ensure that the
63 -- pipeline will stop at some point (see DriverPipeline.runPipeline).
65 | x `elem` haskell_pipe = y `elem` tail (dropWhile (/= x) haskell_pipe)
66 | x `elem` c_pipe = y `elem` tail (dropWhile (/= x) c_pipe)
69 haskell_pipe = [Unlit,Cpp,HsPp,Hsc,HCc,Mangle,As,Ln]
72 -- the first compilation phase for a given file is determined
74 startPhase "lhs" = Unlit
76 startPhase "hscpp" = HsPp
77 startPhase "hspp" = Hsc
78 startPhase "hcr" = Hsc
85 startPhase "raw_s" = Mangle
89 startPhase _ = Ln -- all unknown file types
91 -- the output suffix for a given phase is uniquely determined by
92 -- the input requirements of the next phase.
93 phaseInputExt Unlit = "lhs"
94 phaseInputExt Cpp = "lpp" -- intermediate only
95 phaseInputExt HsPp = "hscpp"
96 phaseInputExt Hsc = "hspp"
97 phaseInputExt HCc = "hc"
98 phaseInputExt Cc = "c"
99 phaseInputExt Mangle = "raw_s"
100 phaseInputExt SplitMangle = "split_s" -- not really generated
101 phaseInputExt As = "s"
102 phaseInputExt SplitAs = "split_s" -- not really generated
103 phaseInputExt Ln = "o"
105 phaseInputExt Ilx2Il = "ilx"
106 phaseInputExt Ilasm = "il"
109 haskellish_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s" ])
110 haskellish_src_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr"])
111 cish_suffix = (`elem` [ "c", "cpp", "C", "cc", "cxx", "s", "S" ])
112 extcoreish_suffix = (`elem` [ "hcr" ])
114 -- Use the appropriate suffix for the system on which
115 -- the GHC-compiled code will run
116 #if mingw32_TARGET_OS || cygwin32_TARGET_OS
117 objish_suffix = (`elem` [ "o", "O", "obj", "OBJ" ])
119 objish_suffix = (`elem` [ "o" ])
122 haskellish_file = haskellish_suffix . getFileSuffix
123 haskellish_src_file = haskellish_src_suffix . getFileSuffix
124 cish_file = cish_suffix . getFileSuffix
125 isExtCore_file = extcoreish_suffix . getFileSuffix
126 objish_file = objish_suffix . getFileSuffix
128 isSourceFile :: FilePath -> Bool