DriverPhases.hs 3.29 KB
Newer Older
1
-----------------------------------------------------------------------------
2
-- $Id: DriverPhases.hs,v 1.15 2002/01/04 16:02:04 simonmar Exp $
3 4 5
--
-- GHC Driver
--
6
-- (c) The University of Glasgow 2002
7 8 9
--
-----------------------------------------------------------------------------

rrt's avatar
rrt committed
10 11
#include "../includes/config.h"

12 13 14 15 16
module DriverPhases (
   Phase(..),
   startPhase,		-- :: String -> Phase
   phaseInputExt, 	-- :: Phase -> String

17
   haskellish_file, haskellish_suffix,
18
   haskellish_src_file, haskellish_src_suffix,
19 20
   objish_file, objish_suffix,
   cish_file, cish_suffix
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
 ) where

import DriverUtil

-----------------------------------------------------------------------------
-- Phases

{-
   Phase of the           | Suffix saying | Flag saying   | (suffix of)
   compilation system     | ``start here''| ``stop after''| output file
   
   literate pre-processor | .lhs          | -             | -
   C pre-processor (opt.) | -             | -E            | -
   Haskell compiler       | .hs           | -C, -S        | .hc, .s
   C compiler (opt.)      | .hc or .c     | -S            | .s
   assembler              | .s  or .S     | -c            | .o
   linker                 | other         | -             | a.out
-}

data Phase 
	= MkDependHS	-- haskell dependency generation
	| Unlit
	| Cpp
sof's avatar
sof committed
44
	| HsPp
45
	| Hsc
46 47 48 49 50 51
	| Cc
	| HCc		-- Haskellised C (as opposed to vanilla C) compilation
	| Mangle	-- assembly mangling, now done by a separate script.
	| SplitMangle	-- after mangler if splitting
	| SplitAs
	| As
rrt's avatar
rrt committed
52 53 54 55 56
	| Ln
#ifdef ILX
        | Ilx2Il
	| Ilasm
#endif
57
  deriving (Eq, Show)
58 59 60 61 62

-- the first compilation phase for a given file is determined
-- by its suffix.
startPhase "lhs"   = Unlit
startPhase "hs"    = Cpp
sof's avatar
sof committed
63
startPhase "hscpp" = HsPp
64
startPhase "hspp"  = Hsc
65 66
startPhase "hc"    = HCc
startPhase "c"     = Cc
67 68 69 70
startPhase "cpp"   = Cc
startPhase "C"     = Cc
startPhase "cc"    = Cc
startPhase "cxx"   = Cc
71 72 73
startPhase "raw_s" = Mangle
startPhase "s"     = As
startPhase "S"     = As
74
startPhase "o"     = Ln
75 76 77 78 79 80
startPhase _       = Ln	   -- all unknown file types

-- the output suffix for a given phase is uniquely determined by
-- the input requirements of the next phase.
phaseInputExt Unlit       = "lhs"
phaseInputExt Cpp         = "lpp"	-- intermediate only
sof's avatar
sof committed
81
phaseInputExt HsPp        = "hscpp"
82
phaseInputExt Hsc         = "hspp"
83 84 85 86 87 88 89 90
phaseInputExt HCc         = "hc"
phaseInputExt Cc          = "c"
phaseInputExt Mangle      = "raw_s"
phaseInputExt SplitMangle = "split_s"	-- not really generated
phaseInputExt As          = "s"
phaseInputExt SplitAs     = "split_s"   -- not really generated
phaseInputExt Ln          = "o"
phaseInputExt MkDependHS  = "dep"
rrt's avatar
rrt committed
91 92 93 94
#ifdef ILX
phaseInputExt Ilx2Il      = "ilx"
phaseInputExt Ilasm       = "il"
#endif
95

sof's avatar
sof committed
96 97
haskellish_suffix     = (`elem` [ "hs", "hspp", "hscpp", "lhs", "hc", "raw_s" ])
haskellish_src_suffix = (`elem` [ "hs", "hspp", "hscpp", "lhs" ])
98
cish_suffix           = (`elem` [ "c", "cpp", "C", "cc", "cxx", "s", "S" ])
99

100 101 102 103 104
#if mingw32_TARGET_OS || cygwin32_TARGET_OS
objish_suffix     = (`elem` [ "o", "O", "obj", "OBJ" ])
#else
objish_suffix     = (`elem` [ "o" ])
#endif
105

106 107 108 109
haskellish_file     = haskellish_suffix     . getFileSuffix
haskellish_src_file = haskellish_src_suffix . getFileSuffix
cish_file           = cish_suffix           . getFileSuffix
objish_file         = objish_suffix         . getFileSuffix