X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fmain%2FDriverPhases.hs;h=2efe293bd63cfde7e3a882dd3ed1259c6e5f7373;hb=70b6c54b3c140d96b69287f8f400f88a0b7e9c18;hp=b6c213c3f9569f9d0828ec9fe63c27d093830e19;hpb=dc7a3d8cec60b14b2fc6f79e69a78691e1477b40;p=ghc-hetmet.git diff --git a/ghc/compiler/main/DriverPhases.hs b/ghc/compiler/main/DriverPhases.hs index b6c213c..2efe293 100644 --- a/ghc/compiler/main/DriverPhases.hs +++ b/ghc/compiler/main/DriverPhases.hs @@ -1,21 +1,26 @@ ----------------------------------------------------------------------------- --- $Id: DriverPhases.hs,v 1.2 2000/11/13 14:34:37 sewardj Exp $ +-- $Id: DriverPhases.hs,v 1.25 2003/06/04 15:47:59 simonmar Exp $ -- -- GHC Driver -- --- (c) Simon Marlow 2000 +-- (c) The University of Glasgow 2002 -- ----------------------------------------------------------------------------- +#include "../includes/config.h" + module DriverPhases ( Phase(..), + happensBefore, startPhase, -- :: String -> Phase phaseInputExt, -- :: Phase -> String - haskellish_file, - haskellish_suffix, - cish_file, - cish_suffix + haskellish_file, haskellish_suffix, + haskellish_src_file, haskellish_src_suffix, + objish_file, objish_suffix, + cish_file, cish_suffix, + isExtCore_file, extcoreish_suffix, + isSourceFile -- :: FilePath -> Bool ) where import DriverUtil @@ -36,9 +41,9 @@ import DriverUtil -} data Phase - = MkDependHS -- haskell dependency generation - | Unlit + = Unlit | Cpp + | HsPp | Hsc | Cc | HCc -- Haskellised C (as opposed to vanilla C) compilation @@ -46,16 +51,37 @@ data Phase | SplitMangle -- after mangler if splitting | SplitAs | As - | Ln - deriving (Eq) + | Ln +#ifdef ILX + | Ilx2Il + | Ilasm +#endif + deriving (Eq, Show) + +-- Partial ordering on phases: we want to know which phases will occur before +-- which others. This is used for sanity checking, to ensure that the +-- pipeline will stop at some point (see DriverPipeline.runPipeline). +x `happensBefore` y + | x `elem` haskell_pipe = y `elem` tail (dropWhile (/= x) haskell_pipe) + | x `elem` c_pipe = y `elem` tail (dropWhile (/= x) c_pipe) + | otherwise = False + +haskell_pipe = [Unlit,Cpp,HsPp,Hsc,HCc,Mangle,As,Ln] +c_pipe = [Cc,As,Ln] -- the first compilation phase for a given file is determined -- by its suffix. startPhase "lhs" = Unlit startPhase "hs" = Cpp -startPhase "hspp" = Hsc -- not sure this will work ... +startPhase "hscpp" = HsPp +startPhase "hspp" = Hsc +startPhase "hcr" = Hsc startPhase "hc" = HCc startPhase "c" = Cc +startPhase "cpp" = Cc +startPhase "C" = Cc +startPhase "cc" = Cc +startPhase "cxx" = Cc startPhase "raw_s" = Mangle startPhase "s" = As startPhase "S" = As @@ -66,7 +92,8 @@ startPhase _ = Ln -- all unknown file types -- the input requirements of the next phase. phaseInputExt Unlit = "lhs" phaseInputExt Cpp = "lpp" -- intermediate only -phaseInputExt Hsc = "hspp" -- intermediate only +phaseInputExt HsPp = "hscpp" +phaseInputExt Hsc = "hspp" phaseInputExt HCc = "hc" phaseInputExt Cc = "c" phaseInputExt Mangle = "raw_s" @@ -74,11 +101,31 @@ phaseInputExt SplitMangle = "split_s" -- not really generated phaseInputExt As = "s" phaseInputExt SplitAs = "split_s" -- not really generated phaseInputExt Ln = "o" -phaseInputExt MkDependHS = "dep" +#ifdef ILX +phaseInputExt Ilx2Il = "ilx" +phaseInputExt Ilasm = "il" +#endif + +haskellish_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s" ]) +haskellish_src_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr"]) +cish_suffix = (`elem` [ "c", "cpp", "C", "cc", "cxx", "s", "S" ]) +extcoreish_suffix = (`elem` [ "hcr" ]) -haskellish_suffix = (`elem` [ "hs", "lhs", "hc" ]) -cish_suffix = (`elem` [ "c", "s", "S" ]) -- maybe .cc et al.?? +-- Use the appropriate suffix for the system on which +-- the GHC-compiled code will run +#if mingw32_TARGET_OS || cygwin32_TARGET_OS +objish_suffix = (`elem` [ "o", "O", "obj", "OBJ" ]) +#else +objish_suffix = (`elem` [ "o" ]) +#endif -haskellish_file f = haskellish_suffix suf where (_,suf) = splitFilename f -cish_file f = cish_suffix suf where (_,suf) = splitFilename f +haskellish_file = haskellish_suffix . getFileSuffix +haskellish_src_file = haskellish_src_suffix . getFileSuffix +cish_file = cish_suffix . getFileSuffix +isExtCore_file = extcoreish_suffix . getFileSuffix +objish_file = objish_suffix . getFileSuffix +isSourceFile :: FilePath -> Bool +isSourceFile f = + haskellish_file f || + cish_file f