3a7053f9dd46682f2430ecbf624a8a076455402b
[ghc-hetmet.git] / ghc / compiler / main / DriverPhases.hs
1 -----------------------------------------------------------------------------
2 -- $Id: DriverPhases.hs,v 1.5 2001/02/27 12:36:37 rrt Exp $
3 --
4 -- GHC Driver
5 --
6 -- (c) Simon Marlow 2000
7 --
8 -----------------------------------------------------------------------------
9
10 module DriverPhases (
11    Phase(..),
12    startPhase,          -- :: String -> Phase
13    phaseInputExt,       -- :: Phase -> String
14
15    haskellish_file,
16    haskellish_suffix,
17    cish_file,
18    cish_suffix
19  ) where
20
21 import DriverUtil
22
23 -----------------------------------------------------------------------------
24 -- Phases
25
26 {-
27    Phase of the           | Suffix saying | Flag saying   | (suffix of)
28    compilation system     | ``start here''| ``stop after''| output file
29    
30    literate pre-processor | .lhs          | -             | -
31    C pre-processor (opt.) | -             | -E            | -
32    Haskell compiler       | .hs           | -C, -S        | .hc, .s
33    C compiler (opt.)      | .hc or .c     | -S            | .s
34    assembler              | .s  or .S     | -c            | .o
35    linker                 | other         | -             | a.out
36 -}
37
38 data Phase 
39         = MkDependHS    -- haskell dependency generation
40         | Unlit
41         | Cpp
42         | Hsc
43         | Cc
44         | HCc           -- Haskellised C (as opposed to vanilla C) compilation
45 #ifdef ILX
46         | Ilx           -- .NET extended IL
47 #endif
48         | Mangle        -- assembly mangling, now done by a separate script.
49         | SplitMangle   -- after mangler if splitting
50         | SplitAs
51         | As
52         | Ln 
53   deriving (Eq, Show)
54
55 -- the first compilation phase for a given file is determined
56 -- by its suffix.
57 startPhase "lhs"   = Unlit
58 startPhase "hs"    = Cpp
59 startPhase "hspp"  = Hsc
60 startPhase "hc"    = HCc
61 startPhase "c"     = Cc
62 startPhase "raw_s" = Mangle
63 startPhase "s"     = As
64 startPhase "S"     = As
65 startPhase "o"     = Ln
66 startPhase _       = Ln    -- all unknown file types
67
68 -- the output suffix for a given phase is uniquely determined by
69 -- the input requirements of the next phase.
70 phaseInputExt Unlit       = "lhs"
71 phaseInputExt Cpp         = "lpp"       -- intermediate only
72 phaseInputExt Hsc         = "hspp"
73 phaseInputExt HCc         = "hc"
74 phaseInputExt Cc          = "c"
75 #ifdef ILX
76 phaseInputExt Ilx         = "ilx"
77 #endif
78 phaseInputExt Mangle      = "raw_s"
79 phaseInputExt SplitMangle = "split_s"   -- not really generated
80 phaseInputExt As          = "s"
81 phaseInputExt SplitAs     = "split_s"   -- not really generated
82 phaseInputExt Ln          = "o"
83 phaseInputExt MkDependHS  = "dep"
84
85 haskellish_suffix = (`elem` [ "hs", "hspp", "lhs", "hc" ])
86 cish_suffix       = (`elem` [ "c", "s", "S" ])  -- maybe .cc et al.??
87
88 haskellish_file f = haskellish_suffix suf where (_,suf) = splitFilename f
89 cish_file f       = cish_suffix suf       where (_,suf) = splitFilename f
90